@adhdev/daemon-standalone 0.7.42 → 0.7.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -18785,6 +18785,9 @@ var init_ghostty_vt_backend = __esm2({
18785
18785
  getText() {
18786
18786
  return this.terminal.formatPlainText({ trim: true }) || "";
18787
18787
  }
18788
+ getCursorPosition() {
18789
+ return this.terminal.getCursorPosition();
18790
+ }
18788
18791
  dispose() {
18789
18792
  this.terminal.dispose();
18790
18793
  }
@@ -18841,6 +18844,13 @@ var init_xterm_backend = __esm2({
18841
18844
  while (last > first && !lines[last - 1]?.trim()) last--;
18842
18845
  return lines.slice(first, last).join("\n");
18843
18846
  }
18847
+ getCursorPosition() {
18848
+ const buffer = this.terminal.buffer.active;
18849
+ return {
18850
+ col: Math.max(0, buffer.cursorX || 0),
18851
+ row: Math.max(0, buffer.cursorY || 0)
18852
+ };
18853
+ }
18844
18854
  dispose() {
18845
18855
  this.terminal.dispose();
18846
18856
  }
@@ -18927,6 +18937,9 @@ var init_terminal_screen = __esm2({
18927
18937
  getText() {
18928
18938
  return this.terminal.getText();
18929
18939
  }
18940
+ getCursorPosition() {
18941
+ return this.terminal.getCursorPosition();
18942
+ }
18930
18943
  dispose() {
18931
18944
  this.terminal.dispose();
18932
18945
  }
@@ -18956,6 +18969,7 @@ var init_pty_transport = __esm2({
18956
18969
  this.handle = handle;
18957
18970
  }
18958
18971
  ready = Promise.resolve();
18972
+ terminalQueriesHandled = false;
18959
18973
  get pid() {
18960
18974
  return this.handle.pid;
18961
18975
  }
@@ -19007,6 +19021,32 @@ function stripTerminalNoise(str) {
19007
19021
  function sanitizeTerminalText(str) {
19008
19022
  return stripTerminalNoise(stripAnsi(str));
19009
19023
  }
19024
+ function buildCliSpawnEnv(baseEnv, overrides) {
19025
+ const env = {};
19026
+ const source = { ...baseEnv, ...overrides || {} };
19027
+ for (const [key, value] of Object.entries(source)) {
19028
+ if (typeof value !== "string") continue;
19029
+ env[key] = value;
19030
+ }
19031
+ for (const key of Object.keys(env)) {
19032
+ if (key === "INIT_CWD" || key === "NO_COLOR" || key === "FORCE_COLOR" || key === "npm_command" || key === "npm_execpath" || key === "npm_node_execpath" || key.startsWith("npm_") || key.startsWith("npm_config_") || key.startsWith("npm_package_") || key.startsWith("npm_lifecycle_") || key.startsWith("PNPM_") || key.startsWith("YARN_") || key.startsWith("BUN_")) {
19033
+ delete env[key];
19034
+ }
19035
+ }
19036
+ return env;
19037
+ }
19038
+ function computeTerminalQueryTail(buffer) {
19039
+ const prefixes = ["\x1B[6n", "\x1B[?6n"];
19040
+ const maxLength = prefixes.reduce((n, value) => Math.max(n, value.length), 0) - 1;
19041
+ const start = Math.max(0, buffer.length - maxLength);
19042
+ for (let i = start; i < buffer.length; i++) {
19043
+ const suffix = buffer.slice(i);
19044
+ if (prefixes.some((pattern) => suffix.length < pattern.length && pattern.startsWith(suffix))) {
19045
+ return suffix;
19046
+ }
19047
+ }
19048
+ return "";
19049
+ }
19010
19050
  function findBinary(name) {
19011
19051
  const isWin = os12.platform() === "win32";
19012
19052
  try {
@@ -19093,36 +19133,6 @@ function promptLikelyVisible(screenText, promptSnippet) {
19093
19133
  ).length;
19094
19134
  return matched >= required2;
19095
19135
  }
19096
- function splitHistoryLines(text) {
19097
- return String(text || "").split("\n").map((line) => line.replace(/\s+$/, ""));
19098
- }
19099
- function normalizeHistoryLine(line) {
19100
- return String(line || "").replace(/\s+/g, " ").trim();
19101
- }
19102
- function mergeTerminalHistory(existing, snapshot) {
19103
- const next = String(snapshot || "").trim();
19104
- if (!next) return existing;
19105
- const prev = String(existing || "").trim();
19106
- if (!prev) return next;
19107
- if (prev === next || prev.endsWith(next)) return prev;
19108
- const prevLines = splitHistoryLines(prev);
19109
- const nextLines = splitHistoryLines(next);
19110
- const prevNorm = prevLines.map(normalizeHistoryLine);
19111
- const nextNorm = nextLines.map(normalizeHistoryLine);
19112
- const maxOverlap = Math.min(prevLines.length, nextLines.length);
19113
- for (let overlap = maxOverlap; overlap >= 1; overlap -= 1) {
19114
- const prevTail = prevNorm.slice(prevNorm.length - overlap);
19115
- const nextHead = nextNorm.slice(0, overlap);
19116
- if (prevTail.every((line, index) => line === nextHead[index])) {
19117
- return [...prevLines, ...nextLines.slice(overlap)].join("\n").trim();
19118
- }
19119
- }
19120
- const compactPrev = prevNorm.join("\n");
19121
- const compactNext = nextNorm.join("\n");
19122
- if (compactPrev.includes(compactNext)) return prev;
19123
- return `${prev}
19124
- ${next}`.trim();
19125
- }
19126
19136
  function parsePatternEntry(x) {
19127
19137
  if (x instanceof RegExp) return x;
19128
19138
  if (x && typeof x === "object" && typeof x.source === "string") {
@@ -19235,6 +19245,7 @@ var init_provider_cli_adapter = __esm2({
19235
19245
  pendingOutputParseTimer = null;
19236
19246
  ptyOutputBuffer = "";
19237
19247
  ptyOutputFlushTimer = null;
19248
+ pendingTerminalQueryTail = "";
19238
19249
  // Server log forwarding
19239
19250
  serverConn = null;
19240
19251
  logBuffer = [];
@@ -19266,9 +19277,7 @@ var init_provider_cli_adapter = __esm2({
19266
19277
  /** Full accumulated raw PTY output (with ANSI) */
19267
19278
  accumulatedRawBuffer = "";
19268
19279
  /** Current visible terminal screen snapshot */
19269
- terminalScreen = new TerminalScreen(40, 120);
19270
- /** Rolling append-only terminal transcript built from screen snapshots */
19271
- terminalHistory = "";
19280
+ terminalScreen = new TerminalScreen(30, 100);
19272
19281
  /** Max accumulated buffer size (last 50KB) */
19273
19282
  static MAX_ACCUMULATED_BUFFER = 5e4;
19274
19283
  currentTurnScope = null;
@@ -19290,15 +19299,13 @@ var init_provider_cli_adapter = __esm2({
19290
19299
  return text.slice(start);
19291
19300
  }
19292
19301
  buildParseInput(baseMessages, partialResponse, scope) {
19293
- const buffer = scope ? this.sliceFromOffset(this.terminalHistory, scope.terminalHistoryStart) || this.sliceFromOffset(this.accumulatedBuffer, scope.bufferStart) || this.accumulatedBuffer : this.accumulatedBuffer;
19302
+ const buffer = scope ? this.sliceFromOffset(this.accumulatedBuffer, scope.bufferStart) || this.accumulatedBuffer : this.accumulatedBuffer;
19294
19303
  const rawBuffer = scope ? this.sliceFromOffset(this.accumulatedRawBuffer, scope.rawBufferStart) || this.accumulatedRawBuffer : this.accumulatedRawBuffer;
19295
- const terminalHistory = scope ? this.sliceFromOffset(this.terminalHistory, scope.terminalHistoryStart) || this.terminalHistory : this.terminalHistory;
19296
19304
  return {
19297
19305
  buffer,
19298
19306
  rawBuffer,
19299
19307
  recentBuffer: buffer.slice(-1e3) || this.recentOutputBuffer,
19300
19308
  screenText: this.terminalScreen.getText(),
19301
- terminalHistory,
19302
19309
  messages: [...baseMessages],
19303
19310
  partialResponse
19304
19311
  };
@@ -19376,13 +19383,10 @@ var init_provider_cli_adapter = __esm2({
19376
19383
  shellArgs = allArgs;
19377
19384
  }
19378
19385
  const ptyOpts = {
19379
- cols: 120,
19380
- rows: 40,
19386
+ cols: 100,
19387
+ rows: 30,
19381
19388
  cwd: this.workingDir,
19382
- env: {
19383
- ...process.env,
19384
- ...spawnConfig.env
19385
- }
19389
+ env: buildCliSpawnEnv(process.env, spawnConfig.env)
19386
19390
  };
19387
19391
  try {
19388
19392
  this.ptyProcess = this.transportFactory.spawn(shellCmd, shellArgs, ptyOpts);
@@ -19400,8 +19404,8 @@ var init_provider_cli_adapter = __esm2({
19400
19404
  }
19401
19405
  this.ptyProcess.onData((data) => {
19402
19406
  if (Date.now() < this.resizeSuppressUntil) return;
19403
- if (data.includes("\x1B[6n") || data.includes("\x1B[?6n")) {
19404
- this.ptyProcess?.write("\x1B[1;1R");
19407
+ if (!this.ptyProcess?.terminalQueriesHandled) {
19408
+ this.respondToTerminalQueries(data);
19405
19409
  }
19406
19410
  this.pendingOutputParseBuffer += data;
19407
19411
  if (!this.pendingOutputParseTimer) {
@@ -19436,8 +19440,8 @@ var init_provider_cli_adapter = __esm2({
19436
19440
  this.spawnAt = Date.now();
19437
19441
  this.startupParseGate = true;
19438
19442
  this.startupBuffer = "";
19439
- this.terminalScreen.reset(40, 120);
19440
- this.terminalHistory = "";
19443
+ this.terminalScreen.reset(30, 100);
19444
+ this.pendingTerminalQueryTail = "";
19441
19445
  this.currentTurnScope = null;
19442
19446
  this.ready = false;
19443
19447
  await this.ptyProcess.ready;
@@ -19447,7 +19451,6 @@ var init_provider_cli_adapter = __esm2({
19447
19451
  // ─── Output Handling ────────────────────────────
19448
19452
  handleOutput(rawData) {
19449
19453
  this.terminalScreen.write(rawData);
19450
- this.terminalHistory = mergeTerminalHistory(this.terminalHistory, this.terminalScreen.getText());
19451
19454
  const cleanData = sanitizeTerminalText(rawData);
19452
19455
  if (this.isWaitingForResponse && cleanData) {
19453
19456
  this.responseBuffer = (this.responseBuffer + cleanData).slice(-8e3);
@@ -19723,8 +19726,7 @@ var init_provider_cli_adapter = __esm2({
19723
19726
  status: this.currentStatus,
19724
19727
  messages: [...this.committedMessages],
19725
19728
  workingDir: this.workingDir,
19726
- activeModal: this.activeModal,
19727
- terminalHistory: this.terminalHistory
19729
+ activeModal: this.activeModal
19728
19730
  };
19729
19731
  }
19730
19732
  /**
@@ -19742,7 +19744,6 @@ var init_provider_cli_adapter = __esm2({
19742
19744
  id: parsed.id || "cli_session",
19743
19745
  status: parsed.status || this.currentStatus,
19744
19746
  title: parsed.title || this.cliName,
19745
- terminalHistory: this.terminalHistory,
19746
19747
  messages: parsed.messages,
19747
19748
  activeModal: parsed.activeModal ?? this.activeModal
19748
19749
  };
@@ -19752,7 +19753,6 @@ var init_provider_cli_adapter = __esm2({
19752
19753
  id: "cli_session",
19753
19754
  status: this.currentStatus,
19754
19755
  title: this.cliName,
19755
- terminalHistory: this.terminalHistory,
19756
19756
  messages: messages.slice(-50).map((message, index) => ({
19757
19757
  id: `msg_${index}`,
19758
19758
  role: message.role,
@@ -19820,10 +19820,9 @@ ${data.message || ""}`.trim();
19820
19820
  prompt: text,
19821
19821
  startedAt: Date.now(),
19822
19822
  bufferStart: this.accumulatedBuffer.length,
19823
- rawBufferStart: this.accumulatedRawBuffer.length,
19824
- terminalHistoryStart: this.terminalHistory.length
19823
+ rawBufferStart: this.accumulatedRawBuffer.length
19825
19824
  };
19826
- LOG.info("CLI", `[${this.cliType}] sendMessage turn scope buffer=${this.currentTurnScope.bufferStart} raw=${this.currentTurnScope.rawBufferStart} terminal=${this.currentTurnScope.terminalHistoryStart} prompt=${JSON.stringify(text).slice(0, 120)}`);
19825
+ LOG.info("CLI", `[${this.cliType}] sendMessage turn scope buffer=${this.currentTurnScope.bufferStart} raw=${this.currentTurnScope.rawBufferStart} prompt=${JSON.stringify(text).slice(0, 120)}`);
19827
19826
  this.submitRetryUsed = false;
19828
19827
  this.submitRetryPromptSnippet = extractPromptRetrySnippet(text);
19829
19828
  const normalizedPromptSnippet = normalizePromptText(this.submitRetryPromptSnippet);
@@ -20008,6 +20007,7 @@ ${data.message || ""}`.trim();
20008
20007
  this.pendingOutputParseTimer = null;
20009
20008
  }
20010
20009
  this.pendingOutputParseBuffer = "";
20010
+ this.pendingTerminalQueryTail = "";
20011
20011
  if (this.ptyOutputFlushTimer) {
20012
20012
  clearTimeout(this.ptyOutputFlushTimer);
20013
20013
  this.ptyOutputFlushTimer = null;
@@ -20047,6 +20047,7 @@ ${data.message || ""}`.trim();
20047
20047
  this.pendingOutputParseTimer = null;
20048
20048
  }
20049
20049
  this.pendingOutputParseBuffer = "";
20050
+ this.pendingTerminalQueryTail = "";
20050
20051
  if (this.ptyOutputFlushTimer) {
20051
20052
  clearTimeout(this.ptyOutputFlushTimer);
20052
20053
  this.ptyOutputFlushTimer = null;
@@ -20073,7 +20074,6 @@ ${data.message || ""}`.trim();
20073
20074
  this.syncMessageViews();
20074
20075
  this.accumulatedBuffer = "";
20075
20076
  this.accumulatedRawBuffer = "";
20076
- this.terminalHistory = "";
20077
20077
  this.currentTurnScope = null;
20078
20078
  this.submitRetryUsed = false;
20079
20079
  this.submitRetryPromptSnippet = "";
@@ -20082,6 +20082,7 @@ ${data.message || ""}`.trim();
20082
20082
  this.pendingOutputParseTimer = null;
20083
20083
  }
20084
20084
  this.pendingOutputParseBuffer = "";
20085
+ this.pendingTerminalQueryTail = "";
20085
20086
  if (this.ptyOutputFlushTimer) {
20086
20087
  clearTimeout(this.ptyOutputFlushTimer);
20087
20088
  this.ptyOutputFlushTimer = null;
@@ -20143,7 +20144,6 @@ ${data.message || ""}`.trim();
20143
20144
  structuredMessages: this.structuredMessages.slice(-20),
20144
20145
  messageCount: this.committedMessages.length,
20145
20146
  screenText: sanitizeTerminalText(this.terminalScreen.getText()).slice(-4e3),
20146
- terminalHistory: this.terminalHistory.slice(-8e3),
20147
20147
  currentTurnScope: this.currentTurnScope,
20148
20148
  startupBuffer: this.startupBuffer.slice(-4e3),
20149
20149
  recentOutputBuffer: this.recentOutputBuffer.slice(-500),
@@ -20171,6 +20171,20 @@ ${data.message || ""}`.trim();
20171
20171
  ptyAlive: !!this.ptyProcess
20172
20172
  };
20173
20173
  }
20174
+ respondToTerminalQueries(data) {
20175
+ if (!this.ptyProcess || !data) return;
20176
+ const combined = this.pendingTerminalQueryTail + data;
20177
+ const regex = /\x1b\[(\?)?6n/g;
20178
+ let match;
20179
+ while ((match = regex.exec(combined)) !== null) {
20180
+ const cursor = this.terminalScreen.getCursorPosition();
20181
+ const row = Math.max(1, (cursor.row | 0) + 1);
20182
+ const col = Math.max(1, (cursor.col | 0) + 1);
20183
+ const response = match[1] ? `\x1B[?${row};${col}R` : `\x1B[${row};${col}R`;
20184
+ this.ptyProcess.write(response);
20185
+ }
20186
+ this.pendingTerminalQueryTail = computeTerminalQueryTail(combined);
20187
+ }
20174
20188
  };
20175
20189
  }
20176
20190
  });
@@ -22149,8 +22163,6 @@ var ChatHistoryWriter = class {
22149
22163
  lastSeenCounts = /* @__PURE__ */ new Map();
22150
22164
  /** Last seen message hash per agent (deduplication) */
22151
22165
  lastSeenHashes = /* @__PURE__ */ new Map();
22152
- /** Last seen append-only terminal transcript per agent */
22153
- lastSeenTerminal = /* @__PURE__ */ new Map();
22154
22166
  rotated = false;
22155
22167
  /**
22156
22168
  * Append new messages to history
@@ -22208,51 +22220,10 @@ var ChatHistoryWriter = class {
22208
22220
  } catch {
22209
22221
  }
22210
22222
  }
22211
- appendTerminalHistory(agentType, terminalHistory, sessionTitle, instanceId) {
22212
- const next = String(terminalHistory || "");
22213
- if (!next.trim()) return;
22214
- try {
22215
- const dedupKey = instanceId ? `${agentType}:${instanceId}:terminal` : `${agentType}:terminal`;
22216
- const prev = this.lastSeenTerminal.get(dedupKey) || "";
22217
- if (prev === next) return;
22218
- let delta = "";
22219
- if (!prev) {
22220
- delta = next;
22221
- } else if (next.startsWith(prev)) {
22222
- delta = next.slice(prev.length);
22223
- } else if (prev.includes(next)) {
22224
- this.lastSeenTerminal.set(dedupKey, next);
22225
- return;
22226
- } else {
22227
- delta = `
22228
-
22229
- [terminal snapshot reset ${(/* @__PURE__ */ new Date()).toISOString()} | ${sessionTitle || agentType}]
22230
- ${next}`;
22231
- }
22232
- if (!delta) {
22233
- this.lastSeenTerminal.set(dedupKey, next);
22234
- return;
22235
- }
22236
- const dir = path4.join(HISTORY_DIR, this.sanitize(agentType));
22237
- fs3.mkdirSync(dir, { recursive: true });
22238
- const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
22239
- const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
22240
- const filePath = path4.join(dir, `${filePrefix}${date5}.terminal.log`);
22241
- fs3.appendFileSync(filePath, delta, "utf-8");
22242
- this.lastSeenTerminal.set(dedupKey, next);
22243
- if (!this.rotated) {
22244
- this.rotated = true;
22245
- this.rotateOldFiles().catch(() => {
22246
- });
22247
- }
22248
- } catch {
22249
- }
22250
- }
22251
22223
  /** Called when agent session is explicitly changed */
22252
22224
  onSessionChange(agentType) {
22253
22225
  this.lastSeenHashes.delete(agentType);
22254
22226
  this.lastSeenCounts.delete(agentType);
22255
- this.lastSeenTerminal.delete(`${agentType}:terminal`);
22256
22227
  }
22257
22228
  /** Delete history files older than 30 days */
22258
22229
  async rotateOldFiles() {
@@ -22943,7 +22914,6 @@ var STATUS_ACTIVE_CHAT_MESSAGE_LIMIT = 60;
22943
22914
  var STATUS_ACTIVE_CHAT_TOTAL_BYTES_LIMIT = 96 * 1024;
22944
22915
  var STATUS_ACTIVE_CHAT_STRING_LIMIT = 4 * 1024;
22945
22916
  var STATUS_ACTIVE_CHAT_FALLBACK_STRING_LIMIT = 1024;
22946
- var STATUS_TERMINAL_HISTORY_LIMIT = 8 * 1024;
22947
22917
  var STATUS_INPUT_CONTENT_LIMIT = 2 * 1024;
22948
22918
  var STATUS_MODAL_MESSAGE_LIMIT = 2 * 1024;
22949
22919
  var STATUS_MODAL_BUTTON_LIMIT = 120;
@@ -22952,11 +22922,6 @@ function truncateString(value, maxChars) {
22952
22922
  if (maxChars <= 12) return value.slice(0, Math.max(0, maxChars));
22953
22923
  return `${value.slice(0, maxChars - 12)}...[truncated]`;
22954
22924
  }
22955
- function truncateStringTail(value, maxChars) {
22956
- if (value.length <= maxChars) return value;
22957
- if (maxChars <= 12) return value.slice(value.length - Math.max(0, maxChars));
22958
- return `...[truncated]${value.slice(value.length - (maxChars - 12))}`;
22959
- }
22960
22925
  function trimStructuredStrings(value, maxChars) {
22961
22926
  if (typeof value === "string") return truncateString(value, maxChars);
22962
22927
  if (Array.isArray(value)) return value.map((item) => trimStructuredStrings(item, maxChars));
@@ -23024,7 +22989,6 @@ function normalizeActiveChatData(activeChat) {
23024
22989
  (button) => truncateString(String(button || ""), STATUS_MODAL_BUTTON_LIMIT)
23025
22990
  )
23026
22991
  } : activeChat.activeModal,
23027
- terminalHistory: activeChat.terminalHistory ? truncateStringTail(activeChat.terminalHistory, STATUS_TERMINAL_HISTORY_LIMIT) : activeChat.terminalHistory,
23028
22992
  inputContent: activeChat.inputContent ? truncateString(activeChat.inputContent, STATUS_INPUT_CONTENT_LIMIT) : activeChat.inputContent
23029
22993
  };
23030
22994
  }
@@ -27033,7 +26997,7 @@ var CliProviderInstance = class {
27033
26997
  this.cliArgs = cliArgs;
27034
26998
  this.type = provider.type;
27035
26999
  this.instanceId = instanceId || crypto3.randomUUID();
27036
- this.presentationMode = "terminal";
27000
+ this.presentationMode = "chat";
27037
27001
  this.adapter = new ProviderCliAdapter(provider, workingDir, cliArgs, transportFactory);
27038
27002
  this.monitor = new StatusMonitor();
27039
27003
  this.historyWriter = new ChatHistoryWriter();
@@ -27080,14 +27044,6 @@ var CliProviderInstance = class {
27080
27044
  const parsedStatus = this.adapter.getScriptParsedStatus?.() || null;
27081
27045
  const runtime = this.adapter.getRuntimeMetadata();
27082
27046
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
27083
- if (adapterStatus.terminalHistory?.trim()) {
27084
- this.historyWriter.appendTerminalHistory(
27085
- this.type,
27086
- adapterStatus.terminalHistory,
27087
- `${this.provider.name} \xB7 ${dirName}`,
27088
- this.instanceId
27089
- );
27090
- }
27091
27047
  return {
27092
27048
  type: this.type,
27093
27049
  name: this.provider.name,
@@ -27100,7 +27056,6 @@ var CliProviderInstance = class {
27100
27056
  status: parsedStatus?.status || adapterStatus.status,
27101
27057
  messages: Array.isArray(parsedStatus?.messages) ? parsedStatus.messages : [],
27102
27058
  activeModal: parsedStatus?.activeModal ?? adapterStatus.activeModal,
27103
- terminalHistory: adapterStatus.terminalHistory,
27104
27059
  inputContent: ""
27105
27060
  },
27106
27061
  workspace: this.workingDir,
@@ -33625,6 +33580,7 @@ var SessionHostRuntimeTransport = class {
33625
33580
  this.ready = this.boot();
33626
33581
  }
33627
33582
  ready;
33583
+ terminalQueriesHandled = true;
33628
33584
  client;
33629
33585
  dataCallbacks = /* @__PURE__ */ new Set();
33630
33586
  exitCallbacks = /* @__PURE__ */ new Set();
@@ -34255,6 +34211,20 @@ async function shutdownDaemonComponents(components) {
34255
34211
  var import_child_process8 = require("child_process");
34256
34212
  var path15 = __toESM(require("path"));
34257
34213
  var SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
34214
+ function buildSessionHostEnv(baseEnv) {
34215
+ const env = {};
34216
+ for (const [key, value] of Object.entries(baseEnv)) {
34217
+ if (typeof value !== "string") continue;
34218
+ env[key] = value;
34219
+ }
34220
+ for (const key of Object.keys(env)) {
34221
+ if (key === "INIT_CWD" || key === "NO_COLOR" || key === "FORCE_COLOR" || key === "npm_command" || key === "npm_execpath" || key === "npm_node_execpath" || key.startsWith("npm_") || key.startsWith("npm_config_") || key.startsWith("npm_package_") || key.startsWith("npm_lifecycle_") || key.startsWith("PNPM_") || key.startsWith("YARN_") || key.startsWith("BUN_")) {
34222
+ delete env[key];
34223
+ }
34224
+ }
34225
+ env.ADHDEV_SESSION_HOST_NAME = SESSION_HOST_APP_NAME;
34226
+ return env;
34227
+ }
34258
34228
  function resolveSessionHostEntry() {
34259
34229
  const localCandidates = [
34260
34230
  path15.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
@@ -34271,10 +34241,7 @@ async function runSessionHostCli(args) {
34271
34241
  const entry = resolveSessionHostEntry();
34272
34242
  const child = (0, import_child_process8.spawn)(process.execPath, [entry, ...args], {
34273
34243
  stdio: "inherit",
34274
- env: {
34275
- ...process.env,
34276
- ADHDEV_SESSION_HOST_NAME: SESSION_HOST_APP_NAME
34277
- }
34244
+ env: buildSessionHostEnv(process.env)
34278
34245
  });
34279
34246
  return await new Promise((resolve12, reject) => {
34280
34247
  child.on("error", reject);
@@ -34290,10 +34257,7 @@ async function ensureSessionHostReady2() {
34290
34257
  detached: true,
34291
34258
  stdio: "ignore",
34292
34259
  windowsHide: true,
34293
- env: {
34294
- ...process.env,
34295
- ADHDEV_SESSION_HOST_NAME: SESSION_HOST_APP_NAME
34296
- }
34260
+ env: buildSessionHostEnv(process.env)
34297
34261
  });
34298
34262
  child.unref();
34299
34263
  }