adhdev 0.9.48 → 0.9.49

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
@@ -975,7 +975,11 @@ function resolveCommandPath(command) {
975
975
  }
976
976
  function execAsync(cmd, timeoutMs = 5e3) {
977
977
  return new Promise((resolve16) => {
978
- const child = (0, import_child_process2.exec)(cmd, { encoding: "utf-8", timeout: timeoutMs }, (err, stdout) => {
978
+ const child = (0, import_child_process2.exec)(cmd, {
979
+ encoding: "utf-8",
980
+ timeout: timeoutMs,
981
+ ...process.platform === "win32" ? { windowsHide: true } : {}
982
+ }, (err, stdout) => {
979
983
  if (err || !stdout?.trim()) {
980
984
  resolve16(null);
981
985
  } else {
@@ -7586,6 +7590,238 @@ function buildReadChatCommandResult(payload, args) {
7586
7590
  ...debugReadChat ? { debugReadChat } : {}
7587
7591
  };
7588
7592
  }
7593
+ function truncateDebugString(value, maxLength) {
7594
+ if (value.length <= maxLength) return value;
7595
+ return `${value.slice(0, maxLength)}\u2026[truncated ${value.length - maxLength} chars]`;
7596
+ }
7597
+ function redactDebugSecrets(value) {
7598
+ return value.replace(/(Authorization\s*:\s*Bearer\s+)[^\s'"`]+/gi, "$1[REDACTED:bearer]").replace(/(Bearer\s+)[A-Za-z0-9._~+\/-]{16,}=*/gi, "$1[REDACTED:bearer]").replace(/\b(?:gh[pousr]|github_pat)_[A-Za-z0-9_]{20,}\b/g, "[REDACTED:github-token]").replace(/\bsk-[A-Za-z0-9_-]{16,}\b/g, "[REDACTED:api-key]").replace(/\bxox[baprs]-[A-Za-z0-9-]{12,}\b/g, "[REDACTED:slack-token]").replace(/\b(?:adk|adm)_[A-Za-z0-9_-]{16,}\b/g, "[REDACTED:adhdev-token]").replace(/((?:api[_-]?key|token|secret|password|passwd|client[_-]?secret)\s*[:=]\s*)[^\s,'"`}&]+/gi, "$1[REDACTED:secret]").replace(/([?&](?:api[_-]?key|token|secret|password|client_secret)=)[^&#\s]+/gi, "$1[REDACTED:secret]");
7599
+ }
7600
+ function sanitizeDebugBundleValue(value, options = {}, depth = 0, keyHint = "") {
7601
+ const normalizedOptions = { ...DEFAULT_DEBUG_SANITIZE_OPTIONS, ...options };
7602
+ if (value === null || value === void 0) return value;
7603
+ if (typeof value === "number" || typeof value === "boolean") return value;
7604
+ if (typeof value === "bigint") return String(value);
7605
+ if (typeof value === "string") {
7606
+ if (SECRET_KEY_PATTERN.test(keyHint) && value.trim()) return "[REDACTED:secret-field]";
7607
+ return truncateDebugString(redactDebugSecrets(value), normalizedOptions.maxStringLength);
7608
+ }
7609
+ if (typeof value === "function") return `[Function ${value.name || "anonymous"}]`;
7610
+ if (typeof value !== "object") return String(value);
7611
+ if (depth >= normalizedOptions.maxDepth) return "[MaxDepth]";
7612
+ if (Array.isArray(value)) {
7613
+ const items = value.slice(0, normalizedOptions.maxArrayLength).map((item) => sanitizeDebugBundleValue(item, normalizedOptions, depth + 1, keyHint));
7614
+ if (value.length > normalizedOptions.maxArrayLength) {
7615
+ items.push(`[truncated ${value.length - normalizedOptions.maxArrayLength} items]`);
7616
+ }
7617
+ return items;
7618
+ }
7619
+ const record2 = value;
7620
+ const result = {};
7621
+ const entries = Object.entries(record2).slice(0, normalizedOptions.maxObjectKeys);
7622
+ for (const [key, item] of entries) {
7623
+ result[key] = sanitizeDebugBundleValue(item, normalizedOptions, depth + 1, key);
7624
+ }
7625
+ const remaining = Object.keys(record2).length - entries.length;
7626
+ if (remaining > 0) result.__truncatedKeys = remaining;
7627
+ return result;
7628
+ }
7629
+ function summarizeProviderForDebug(provider) {
7630
+ if (!provider) return null;
7631
+ const scripts = provider.scripts && typeof provider.scripts === "object" ? Object.keys(provider.scripts) : [];
7632
+ const controls = Array.isArray(provider.controls) ? provider.controls.map((control) => ({
7633
+ id: control?.id,
7634
+ label: control?.label,
7635
+ type: control?.type,
7636
+ settingKey: control?.settingKey,
7637
+ invokeScript: control?.invokeScript,
7638
+ listScript: control?.listScript,
7639
+ location: control?.location
7640
+ })) : [];
7641
+ return {
7642
+ type: provider.type,
7643
+ name: provider.name,
7644
+ category: provider.category,
7645
+ version: provider.version,
7646
+ canonicalHistory: provider.canonicalHistory,
7647
+ historyBehavior: provider.historyBehavior,
7648
+ webviewMatchText: provider.webviewMatchText,
7649
+ scriptNames: scripts,
7650
+ controls,
7651
+ resume: provider.resume
7652
+ };
7653
+ }
7654
+ function summarizeSessionForDebug(session) {
7655
+ if (!session || typeof session !== "object") return null;
7656
+ return {
7657
+ sessionId: session.sessionId,
7658
+ instanceKey: session.instanceKey,
7659
+ adapterKey: session.adapterKey,
7660
+ providerType: session.providerType,
7661
+ providerName: session.providerName,
7662
+ transport: session.transport,
7663
+ kind: session.kind,
7664
+ cdpManagerKey: session.cdpManagerKey,
7665
+ parentSessionId: session.parentSessionId,
7666
+ providerSessionId: session.providerSessionId,
7667
+ workspace: session.workspace,
7668
+ title: session.title,
7669
+ status: session.status,
7670
+ mode: session.mode,
7671
+ capabilities: session.capabilities
7672
+ };
7673
+ }
7674
+ function summarizeStateForDebug(state) {
7675
+ if (!state || typeof state !== "object") return null;
7676
+ const activeChat = state.activeChat && typeof state.activeChat === "object" ? state.activeChat : null;
7677
+ return {
7678
+ type: state.type,
7679
+ name: state.name,
7680
+ category: state.category,
7681
+ status: state.status,
7682
+ instanceId: state.instanceId,
7683
+ providerSessionId: state.providerSessionId,
7684
+ title: state.title,
7685
+ transport: state.transport,
7686
+ mode: state.mode,
7687
+ workspace: state.workspace,
7688
+ runtime: state.runtime,
7689
+ errorMessage: state.errorMessage,
7690
+ errorReason: state.errorReason,
7691
+ activeChat: activeChat ? {
7692
+ status: activeChat.status,
7693
+ title: activeChat.title,
7694
+ messageCount: Array.isArray(activeChat.messages) ? activeChat.messages.length : void 0,
7695
+ activeModal: activeChat.activeModal,
7696
+ messagesTail: Array.isArray(activeChat.messages) ? activeChat.messages.slice(-10) : void 0
7697
+ } : null,
7698
+ controlValues: state.controlValues,
7699
+ summaryMetadata: state.summaryMetadata
7700
+ };
7701
+ }
7702
+ function buildDebugBundleText(bundle) {
7703
+ return [
7704
+ "# ADHDev Chat Debug Bundle",
7705
+ "",
7706
+ "```json",
7707
+ JSON.stringify(bundle, null, 2),
7708
+ "```"
7709
+ ].join("\n");
7710
+ }
7711
+ async function handleGetChatDebugBundle(h, args) {
7712
+ const provider = h.getProvider(args?.agentType);
7713
+ const transport = getTargetTransport(h, provider);
7714
+ const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
7715
+ const providerType = provider?.type || getCurrentProviderType(h, args?.agentType || "");
7716
+ const adapter = isCliLikeTransport(transport) ? getTargetedCliAdapter(h, args, provider?.type) : null;
7717
+ const targetInstance = getTargetInstance(h, args);
7718
+ let adapterStatus = null;
7719
+ let parsedStatus = null;
7720
+ let adapterDebugSnapshot = null;
7721
+ let partialResponse = "";
7722
+ if (adapter) {
7723
+ try {
7724
+ adapterStatus = adapter.getStatus?.();
7725
+ } catch (error48) {
7726
+ adapterStatus = { error: error48?.message || String(error48) };
7727
+ }
7728
+ try {
7729
+ parsedStatus = typeof adapter.getScriptParsedStatus === "function" ? parseMaybeJson(adapter.getScriptParsedStatus()) : null;
7730
+ } catch (error48) {
7731
+ parsedStatus = { error: error48?.message || String(error48) };
7732
+ }
7733
+ try {
7734
+ adapterDebugSnapshot = typeof adapter.getDebugSnapshot === "function" ? adapter.getDebugSnapshot() : null;
7735
+ } catch (error48) {
7736
+ adapterDebugSnapshot = { error: error48?.message || String(error48) };
7737
+ }
7738
+ try {
7739
+ partialResponse = adapter.getPartialResponse?.() || "";
7740
+ } catch {
7741
+ partialResponse = "";
7742
+ }
7743
+ }
7744
+ let instanceState = null;
7745
+ if (targetInstance?.getState) {
7746
+ try {
7747
+ instanceState = summarizeStateForDebug(targetInstance.getState());
7748
+ } catch (error48) {
7749
+ instanceState = { error: error48?.message || String(error48) };
7750
+ }
7751
+ }
7752
+ let readChat = null;
7753
+ try {
7754
+ const readResult = await handleReadChat(h, { ...args, tailLimit: Math.max(1, Math.min(40, Number(args?.tailLimit || 40))) });
7755
+ readChat = readResult.success ? {
7756
+ success: true,
7757
+ status: readResult.status,
7758
+ title: readResult.title,
7759
+ totalMessages: readResult.totalMessages,
7760
+ returnedMessages: Array.isArray(readResult.messages) ? readResult.messages.length : void 0,
7761
+ syncMode: readResult.syncMode,
7762
+ replaceFrom: readResult.replaceFrom,
7763
+ lastMessageSignature: readResult.lastMessageSignature,
7764
+ providerSessionId: readResult.providerSessionId,
7765
+ transcriptAuthority: readResult.transcriptAuthority,
7766
+ coverage: readResult.coverage,
7767
+ activeModal: readResult.activeModal,
7768
+ messagesTail: Array.isArray(readResult.messages) ? readResult.messages.slice(-20) : [],
7769
+ debugReadChat: readResult.debugReadChat
7770
+ } : { success: false, error: readResult.error };
7771
+ } catch (error48) {
7772
+ readChat = { success: false, error: error48?.message || String(error48) };
7773
+ }
7774
+ const cdp = h.getCdp();
7775
+ const rawBundle = {
7776
+ version: 1,
7777
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
7778
+ target: {
7779
+ targetSessionId,
7780
+ providerType,
7781
+ transport,
7782
+ routeManagerKey: h.currentManagerKey,
7783
+ currentIdeType: h.currentIdeType
7784
+ },
7785
+ session: summarizeSessionForDebug(h.currentSession),
7786
+ provider: summarizeProviderForDebug(provider),
7787
+ daemon: {
7788
+ pid: process.pid,
7789
+ platform: process.platform,
7790
+ nodeVersion: process.version,
7791
+ cwd: process.cwd()
7792
+ },
7793
+ cdp: {
7794
+ requested: !!cdp,
7795
+ connected: !!cdp?.isConnected,
7796
+ managerKey: getCurrentManagerKey(h)
7797
+ },
7798
+ instanceState,
7799
+ cli: adapter ? {
7800
+ cliType: adapter.cliType,
7801
+ cliName: adapter.cliName,
7802
+ workingDir: adapter.workingDir,
7803
+ status: adapterStatus?.status,
7804
+ activeModal: adapterStatus?.activeModal,
7805
+ messageCount: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.length : void 0,
7806
+ messagesTail: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.slice(-20) : void 0,
7807
+ parsedStatus,
7808
+ partialResponse,
7809
+ ready: typeof adapter.isReady === "function" ? adapter.isReady() : void 0,
7810
+ processing: typeof adapter.isProcessing === "function" ? adapter.isProcessing() : void 0,
7811
+ debugSnapshot: adapterDebugSnapshot
7812
+ } : null,
7813
+ readChat,
7814
+ frontend: args?.frontendSnapshot && typeof args.frontendSnapshot === "object" ? args.frontendSnapshot : null,
7815
+ recentLogs: getRecentLogs(80, "debug"),
7816
+ recentDebugTrace: getRecentDebugTrace({ limit: 120 })
7817
+ };
7818
+ const bundle = sanitizeDebugBundleValue(rawBundle);
7819
+ return {
7820
+ success: true,
7821
+ bundle,
7822
+ text: buildDebugBundleText(bundle)
7823
+ };
7824
+ }
7589
7825
  function didProviderConfirmSend(result) {
7590
7826
  const parsed = parseMaybeJson(result);
7591
7827
  if (parsed === true) return true;
@@ -8559,7 +8795,7 @@ async function handleResolveAction(h, args) {
8559
8795
  }
8560
8796
  return { success: false, error: "resolveAction script not available for this provider" };
8561
8797
  }
8562
- var RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget;
8798
+ var RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN;
8563
8799
  var init_chat_commands = __esm({
8564
8800
  "../../oss/packages/daemon-core/src/commands/chat-commands.ts"() {
8565
8801
  "use strict";
@@ -8574,6 +8810,13 @@ var init_chat_commands = __esm({
8574
8810
  RECENT_SEND_WINDOW_MS = 1200;
8575
8811
  READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
8576
8812
  recentSendByTarget = /* @__PURE__ */ new Map();
8813
+ DEFAULT_DEBUG_SANITIZE_OPTIONS = {
8814
+ maxDepth: 8,
8815
+ maxArrayLength: 80,
8816
+ maxObjectKeys: 120,
8817
+ maxStringLength: 16e3
8818
+ };
8819
+ SECRET_KEY_PATTERN = /(?:token|secret|password|passwd|authorization|cookie|api[_-]?key|access[_-]?key|refresh[_-]?token|client[_-]?secret|private[_-]?key)/i;
8577
8820
  }
8578
8821
  });
8579
8822
 
@@ -9841,6 +10084,8 @@ var init_handler = __esm({
9841
10084
  // ─── Chat commands (chat-commands.ts) ───────────────
9842
10085
  case "read_chat":
9843
10086
  return handleReadChat(this, args);
10087
+ case "get_chat_debug_bundle":
10088
+ return handleGetChatDebugBundle(this, args);
9844
10089
  case "chat_history":
9845
10090
  return handleChatHistory(this, args);
9846
10091
  case "send_chat":
@@ -11193,7 +11438,12 @@ function findBinary(name) {
11193
11438
  const isWin = os10.platform() === "win32";
11194
11439
  try {
11195
11440
  const cmd = isWin ? `where ${trimmed}` : `which ${trimmed}`;
11196
- return (0, import_child_process4.execSync)(cmd, { encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }).trim().split("\n")[0].trim();
11441
+ return (0, import_child_process4.execSync)(cmd, {
11442
+ encoding: "utf-8",
11443
+ timeout: 5e3,
11444
+ stdio: ["pipe", "pipe", "pipe"],
11445
+ ...isWin ? { windowsHide: true } : {}
11446
+ }).trim().split("\n")[0].trim();
11197
11447
  } catch {
11198
11448
  return isWin ? `${trimmed}.cmd` : trimmed;
11199
11449
  }
@@ -13878,6 +14128,83 @@ var init_provider_cli_adapter = __esm({
13878
14128
  if (!this.isWaitingForResponse) return "";
13879
14129
  return this.responseBuffer;
13880
14130
  }
14131
+ getDebugSnapshot() {
14132
+ const screenText = this.readTerminalScreenText();
14133
+ const parsedResult = this.parsedStatusCache?.result && typeof this.parsedStatusCache.result === "object" ? this.parsedStatusCache.result : null;
14134
+ return {
14135
+ cliType: this.cliType,
14136
+ cliName: this.cliName,
14137
+ workingDir: this.workingDir,
14138
+ currentStatus: this.currentStatus,
14139
+ ready: this.ready,
14140
+ isWaitingForResponse: this.isWaitingForResponse,
14141
+ activeModal: this.activeModal,
14142
+ parseErrorMessage: this.parseErrorMessage,
14143
+ messageCounts: {
14144
+ committed: this.committedMessages.length,
14145
+ structured: this.structuredMessages.length,
14146
+ visible: this.messages.length,
14147
+ parsedCache: Array.isArray(parsedResult?.messages) ? parsedResult.messages.length : void 0
14148
+ },
14149
+ buffers: {
14150
+ accumulatedLength: this.accumulatedBuffer.length,
14151
+ accumulatedRawLength: this.accumulatedRawBuffer.length,
14152
+ recentOutputLength: this.recentOutputBuffer.length,
14153
+ responseLength: this.responseBuffer.length,
14154
+ startupLength: this.startupBuffer.length,
14155
+ accumulatedTail: this.accumulatedBuffer.slice(-24e3),
14156
+ accumulatedRawTail: this.accumulatedRawBuffer.slice(-24e3),
14157
+ recentOutputTail: this.recentOutputBuffer.slice(-12e3),
14158
+ responseTail: this.responseBuffer.slice(-12e3)
14159
+ },
14160
+ terminal: {
14161
+ screenText,
14162
+ lastScreenSnapshot: this.lastScreenSnapshot,
14163
+ lastScreenText: this.lastScreenText,
14164
+ lastOutputAt: this.lastOutputAt,
14165
+ lastNonEmptyOutputAt: this.lastNonEmptyOutputAt,
14166
+ lastScreenChangeAt: this.lastScreenChangeAt,
14167
+ lastScreenSnapshotReadAt: this.lastScreenSnapshotReadAt
14168
+ },
14169
+ parser: {
14170
+ scriptNames: listCliScriptNames(this.cliScripts),
14171
+ traceSessionId: this.traceSessionId,
14172
+ traceSeq: this.traceSeq,
14173
+ currentTurnScope: this.currentTurnScope,
14174
+ parsedStatusCache: parsedResult ? {
14175
+ id: parsedResult.id,
14176
+ status: parsedResult.status,
14177
+ title: parsedResult.title,
14178
+ providerSessionId: parsedResult.providerSessionId,
14179
+ transcriptAuthority: parsedResult.transcriptAuthority,
14180
+ coverage: parsedResult.coverage,
14181
+ messageCount: Array.isArray(parsedResult.messages) ? parsedResult.messages.length : void 0,
14182
+ activeModal: parsedResult.activeModal
14183
+ } : null,
14184
+ pendingScriptStatus: this.pendingScriptStatus,
14185
+ pendingScriptStatusSince: this.pendingScriptStatusSince
14186
+ },
14187
+ runtimeMetadata: this.getRuntimeMetadata(),
14188
+ statusHistory: this.statusHistory.slice(-80),
14189
+ traceEntries: this.traceEntries.slice(-120),
14190
+ timing: {
14191
+ spawnAt: this.spawnAt,
14192
+ startupFirstOutputAt: this.startupFirstOutputAt,
14193
+ submitPendingUntil: this.submitPendingUntil,
14194
+ responseSettleIgnoreUntil: this.responseSettleIgnoreUntil,
14195
+ responseEpoch: this.responseEpoch,
14196
+ resizeSuppressUntil: this.resizeSuppressUntil,
14197
+ lastApprovalResolvedAt: this.lastApprovalResolvedAt,
14198
+ committedMessagesChangedAt: this.committedMessagesChangedAt
14199
+ },
14200
+ finish: {
14201
+ idleFinishCandidate: this.idleFinishCandidate,
14202
+ finishRetryCount: this.finishRetryCount,
14203
+ submitRetryUsed: this.submitRetryUsed,
14204
+ submitRetryPromptSnippet: this.submitRetryPromptSnippet
14205
+ }
14206
+ };
14207
+ }
13881
14208
  getRuntimeMetadata() {
13882
14209
  if (!this.ptyProcess || typeof this.ptyProcess.getMetadata !== "function") return null;
13883
14210
  return this.ptyProcess.getMetadata();
@@ -31954,7 +32281,8 @@ var init_acp_provider_instance = __esm({
31954
32281
  cwd: this.workingDir,
31955
32282
  env: env3,
31956
32283
  stdio: ["pipe", "pipe", "pipe"],
31957
- shell: spawnConfig.shell || false
32284
+ shell: spawnConfig.shell || false,
32285
+ ...process.platform === "win32" ? { windowsHide: true } : {}
31958
32286
  });
31959
32287
  const AUTH_ERROR_PATTERNS = [
31960
32288
  /unauthorized|unauthenticated/i,
@@ -32653,7 +32981,10 @@ function commandExists(command) {
32653
32981
  return (0, import_fs5.existsSync)(expandExecutable(trimmed));
32654
32982
  }
32655
32983
  try {
32656
- (0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], { stdio: "ignore" });
32984
+ (0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
32985
+ stdio: "ignore",
32986
+ ...process.platform === "win32" ? { windowsHide: true } : {}
32987
+ });
32657
32988
  return true;
32658
32989
  } catch {
32659
32990
  return false;
@@ -37372,7 +37703,7 @@ async function launchMacOS(ide, port, workspace, newWindow) {
37372
37703
  const canUseAppLauncher = !!appName;
37373
37704
  const useAppLauncher = preferredMethod === "app" ? canUseAppLauncher : preferredMethod === "cli" ? false : !canUseCli && canUseAppLauncher;
37374
37705
  if (!useAppLauncher && ide.cliCommand) {
37375
- (0, import_child_process7.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore" }).unref();
37706
+ (0, import_child_process7.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
37376
37707
  } else if (appName) {
37377
37708
  const openArgs = ["-a", appName, "--args", ...args];
37378
37709
  (0, import_child_process7.spawn)("open", openArgs, { detached: true, stdio: "ignore" }).unref();
@@ -37401,7 +37732,7 @@ async function launchLinux(ide, port, workspace, newWindow) {
37401
37732
  const args = ["--remote-debugging-port=" + port];
37402
37733
  if (newWindow) args.push("--new-window");
37403
37734
  if (workspace) args.push(workspace);
37404
- (0, import_child_process7.spawn)(cli, args, { detached: true, stdio: "ignore" }).unref();
37735
+ (0, import_child_process7.spawn)(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
37405
37736
  }
37406
37737
  function getAvailableIdeIds() {
37407
37738
  return getProviderLoader().getAvailableIdeTypes();
@@ -37910,23 +38241,23 @@ function resolveSiblingNpmInvocation(nodeExecutable, platform12 = process.platfo
37910
38241
  if (platform12 === "win32") {
37911
38242
  const npmCliPath = path16.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
37912
38243
  if (fs8.existsSync(npmCliPath)) {
37913
- return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: { shell: false } };
38244
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
37914
38245
  }
37915
38246
  for (const candidate of ["npm.exe", "npm"]) {
37916
38247
  const candidatePath = path16.join(binDir, candidate);
37917
38248
  if (fs8.existsSync(candidatePath)) {
37918
- return { executable: candidatePath, argsPrefix: [], execOptions: { shell: false } };
38249
+ return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
37919
38250
  }
37920
38251
  }
37921
- return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: { shell: false } };
38252
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
37922
38253
  }
37923
38254
  for (const candidate of ["npm"]) {
37924
38255
  const candidatePath = path16.join(binDir, candidate);
37925
38256
  if (fs8.existsSync(candidatePath)) {
37926
- return { executable: candidatePath, argsPrefix: [], execOptions: { shell: false } };
38257
+ return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
37927
38258
  }
37928
38259
  }
37929
- return { executable: "npm", argsPrefix: [], execOptions: { shell: false } };
38260
+ return { executable: "npm", argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
37930
38261
  }
37931
38262
  function findCurrentPackageRoot(currentCliPath, packageName) {
37932
38263
  if (!currentCliPath) return null;
@@ -37997,13 +38328,28 @@ function buildPinnedGlobalInstallCommand(options) {
37997
38328
  execOptions: surface.execOptions || getNpmExecOptions(options.platform)
37998
38329
  };
37999
38330
  }
38000
- function getNpmExecOptions(_platform = process.platform) {
38331
+ function getNpmExecOptions(platform12 = process.platform) {
38332
+ if (platform12 === "win32") {
38333
+ return { shell: false, windowsHide: true };
38334
+ }
38001
38335
  return { shell: false };
38002
38336
  }
38337
+ function execNpmCommandSync(args, options = {}, surface) {
38338
+ const execOptions = surface?.execOptions || getNpmExecOptions();
38339
+ return (0, import_child_process8.execFileSync)(
38340
+ surface?.npmExecutable || "npm",
38341
+ [...surface?.npmArgsPrefix || [], ...args],
38342
+ {
38343
+ ...options,
38344
+ ...execOptions,
38345
+ ...process.platform === "win32" ? { windowsHide: true } : {}
38346
+ }
38347
+ );
38348
+ }
38003
38349
  function killPid(pid) {
38004
38350
  try {
38005
38351
  if (process.platform === "win32") {
38006
- (0, import_child_process8.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
38352
+ (0, import_child_process8.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
38007
38353
  } else {
38008
38354
  process.kill(pid, "SIGTERM");
38009
38355
  }
@@ -38022,7 +38368,7 @@ function getWindowsProcessCommandLine(pid) {
38022
38368
  "Bypass",
38023
38369
  "-Command",
38024
38370
  `(Get-CimInstance Win32_Process -Filter "${pidFilter}").CommandLine`
38025
- ], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
38371
+ ], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
38026
38372
  if (psOut) return psOut;
38027
38373
  } catch {
38028
38374
  }
@@ -38033,7 +38379,7 @@ function getWindowsProcessCommandLine(pid) {
38033
38379
  pidFilter,
38034
38380
  "get",
38035
38381
  "CommandLine"
38036
- ], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
38382
+ ], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
38037
38383
  if (wmicOut) return wmicOut;
38038
38384
  } catch {
38039
38385
  }
@@ -38094,9 +38440,9 @@ function removeDaemonPidFile() {
38094
38440
  }
38095
38441
  function cleanupStaleGlobalInstallDirs(pkgName, surface) {
38096
38442
  const prefixArgs = surface.installPrefix ? ["--prefix", surface.installPrefix] : [];
38097
- const npmRoot = (0, import_child_process8.execFileSync)(surface.npmExecutable, [...surface.npmArgsPrefix || [], "root", "-g", ...prefixArgs], { encoding: "utf8", ...surface.execOptions }).trim();
38443
+ const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
38098
38444
  if (!npmRoot) return;
38099
- const npmPrefix = surface.installPrefix || (0, import_child_process8.execFileSync)(surface.npmExecutable, [...surface.npmArgsPrefix || [], "prefix", "-g", ...prefixArgs], { encoding: "utf8", ...surface.execOptions }).trim();
38445
+ const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
38100
38446
  const binDir = process.platform === "win32" ? npmPrefix : path16.join(npmPrefix, "bin");
38101
38447
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
38102
38448
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
@@ -38918,18 +39264,18 @@ var init_router = __esm({
38918
39264
  case "daemon_upgrade": {
38919
39265
  LOG.info("Upgrade", "Remote upgrade requested from dashboard");
38920
39266
  try {
38921
- const { execSync: execSync7 } = await import("child_process");
38922
39267
  const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
38923
39268
  const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
38924
- const latest = execSync7(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
39269
+ const npmSurface = resolveCurrentGlobalInstallSurface({ packageName: pkgName });
39270
+ const latest = String(execNpmCommandSync(["view", pkgName, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
38925
39271
  LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
38926
39272
  let currentInstalled = null;
38927
39273
  try {
38928
- const currentJson = execSync7(`npm ls -g ${pkgName} --depth=0 --json`, {
39274
+ const currentJson = String(execNpmCommandSync(["ls", "-g", pkgName, "--depth=0", "--json"], {
38929
39275
  encoding: "utf-8",
38930
39276
  timeout: 1e4,
38931
39277
  stdio: ["pipe", "pipe", "pipe"]
38932
- }).trim();
39278
+ }, npmSurface)).trim();
38933
39279
  const parsed = JSON.parse(currentJson);
38934
39280
  currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
38935
39281
  } catch {
@@ -47178,6 +47524,7 @@ __export(src_exports, {
47178
47524
  detectCLIs: () => detectCLIs,
47179
47525
  detectIDEs: () => detectIDEs,
47180
47526
  ensureSessionHostReady: () => ensureSessionHostReady,
47527
+ execNpmCommandSync: () => execNpmCommandSync,
47181
47528
  findCdpManager: () => findCdpManager,
47182
47529
  flattenMessageParts: () => flattenMessageParts,
47183
47530
  forwardAgentStreamsToIdeInstance: () => forwardAgentStreamsToIdeInstance,
@@ -47188,6 +47535,7 @@ __export(src_exports, {
47188
47535
  getDebugRuntimeConfig: () => getDebugRuntimeConfig,
47189
47536
  getHostMemorySnapshot: () => getHostMemorySnapshot,
47190
47537
  getLogLevel: () => getLogLevel,
47538
+ getNpmExecOptions: () => getNpmExecOptions,
47191
47539
  getRecentActivity: () => getRecentActivity,
47192
47540
  getRecentCommands: () => getRecentCommands,
47193
47541
  getRecentDebugTrace: () => getRecentDebugTrace,
@@ -56943,7 +57291,7 @@ var init_adhdev_daemon = __esm({
56943
57291
  init_version();
56944
57292
  init_src();
56945
57293
  init_runtime_defaults();
56946
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.48" });
57294
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.49" });
56947
57295
  AdhdevDaemon = class _AdhdevDaemon {
56948
57296
  localHttpServer = null;
56949
57297
  localWss = null;