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/cli/index.js CHANGED
@@ -1495,7 +1495,11 @@ function resolveCommandPath(command) {
1495
1495
  }
1496
1496
  function execAsync(cmd, timeoutMs = 5e3) {
1497
1497
  return new Promise((resolve18) => {
1498
- const child = (0, import_child_process2.exec)(cmd, { encoding: "utf-8", timeout: timeoutMs }, (err, stdout) => {
1498
+ const child = (0, import_child_process2.exec)(cmd, {
1499
+ encoding: "utf-8",
1500
+ timeout: timeoutMs,
1501
+ ...process.platform === "win32" ? { windowsHide: true } : {}
1502
+ }, (err, stdout) => {
1499
1503
  if (err || !stdout?.trim()) {
1500
1504
  resolve18(null);
1501
1505
  } else {
@@ -8106,6 +8110,238 @@ function buildReadChatCommandResult(payload, args) {
8106
8110
  ...debugReadChat ? { debugReadChat } : {}
8107
8111
  };
8108
8112
  }
8113
+ function truncateDebugString(value, maxLength) {
8114
+ if (value.length <= maxLength) return value;
8115
+ return `${value.slice(0, maxLength)}\u2026[truncated ${value.length - maxLength} chars]`;
8116
+ }
8117
+ function redactDebugSecrets(value) {
8118
+ 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]");
8119
+ }
8120
+ function sanitizeDebugBundleValue(value, options = {}, depth = 0, keyHint = "") {
8121
+ const normalizedOptions = { ...DEFAULT_DEBUG_SANITIZE_OPTIONS, ...options };
8122
+ if (value === null || value === void 0) return value;
8123
+ if (typeof value === "number" || typeof value === "boolean") return value;
8124
+ if (typeof value === "bigint") return String(value);
8125
+ if (typeof value === "string") {
8126
+ if (SECRET_KEY_PATTERN.test(keyHint) && value.trim()) return "[REDACTED:secret-field]";
8127
+ return truncateDebugString(redactDebugSecrets(value), normalizedOptions.maxStringLength);
8128
+ }
8129
+ if (typeof value === "function") return `[Function ${value.name || "anonymous"}]`;
8130
+ if (typeof value !== "object") return String(value);
8131
+ if (depth >= normalizedOptions.maxDepth) return "[MaxDepth]";
8132
+ if (Array.isArray(value)) {
8133
+ const items = value.slice(0, normalizedOptions.maxArrayLength).map((item) => sanitizeDebugBundleValue(item, normalizedOptions, depth + 1, keyHint));
8134
+ if (value.length > normalizedOptions.maxArrayLength) {
8135
+ items.push(`[truncated ${value.length - normalizedOptions.maxArrayLength} items]`);
8136
+ }
8137
+ return items;
8138
+ }
8139
+ const record2 = value;
8140
+ const result = {};
8141
+ const entries = Object.entries(record2).slice(0, normalizedOptions.maxObjectKeys);
8142
+ for (const [key, item] of entries) {
8143
+ result[key] = sanitizeDebugBundleValue(item, normalizedOptions, depth + 1, key);
8144
+ }
8145
+ const remaining = Object.keys(record2).length - entries.length;
8146
+ if (remaining > 0) result.__truncatedKeys = remaining;
8147
+ return result;
8148
+ }
8149
+ function summarizeProviderForDebug(provider) {
8150
+ if (!provider) return null;
8151
+ const scripts = provider.scripts && typeof provider.scripts === "object" ? Object.keys(provider.scripts) : [];
8152
+ const controls = Array.isArray(provider.controls) ? provider.controls.map((control) => ({
8153
+ id: control?.id,
8154
+ label: control?.label,
8155
+ type: control?.type,
8156
+ settingKey: control?.settingKey,
8157
+ invokeScript: control?.invokeScript,
8158
+ listScript: control?.listScript,
8159
+ location: control?.location
8160
+ })) : [];
8161
+ return {
8162
+ type: provider.type,
8163
+ name: provider.name,
8164
+ category: provider.category,
8165
+ version: provider.version,
8166
+ canonicalHistory: provider.canonicalHistory,
8167
+ historyBehavior: provider.historyBehavior,
8168
+ webviewMatchText: provider.webviewMatchText,
8169
+ scriptNames: scripts,
8170
+ controls,
8171
+ resume: provider.resume
8172
+ };
8173
+ }
8174
+ function summarizeSessionForDebug(session) {
8175
+ if (!session || typeof session !== "object") return null;
8176
+ return {
8177
+ sessionId: session.sessionId,
8178
+ instanceKey: session.instanceKey,
8179
+ adapterKey: session.adapterKey,
8180
+ providerType: session.providerType,
8181
+ providerName: session.providerName,
8182
+ transport: session.transport,
8183
+ kind: session.kind,
8184
+ cdpManagerKey: session.cdpManagerKey,
8185
+ parentSessionId: session.parentSessionId,
8186
+ providerSessionId: session.providerSessionId,
8187
+ workspace: session.workspace,
8188
+ title: session.title,
8189
+ status: session.status,
8190
+ mode: session.mode,
8191
+ capabilities: session.capabilities
8192
+ };
8193
+ }
8194
+ function summarizeStateForDebug(state) {
8195
+ if (!state || typeof state !== "object") return null;
8196
+ const activeChat = state.activeChat && typeof state.activeChat === "object" ? state.activeChat : null;
8197
+ return {
8198
+ type: state.type,
8199
+ name: state.name,
8200
+ category: state.category,
8201
+ status: state.status,
8202
+ instanceId: state.instanceId,
8203
+ providerSessionId: state.providerSessionId,
8204
+ title: state.title,
8205
+ transport: state.transport,
8206
+ mode: state.mode,
8207
+ workspace: state.workspace,
8208
+ runtime: state.runtime,
8209
+ errorMessage: state.errorMessage,
8210
+ errorReason: state.errorReason,
8211
+ activeChat: activeChat ? {
8212
+ status: activeChat.status,
8213
+ title: activeChat.title,
8214
+ messageCount: Array.isArray(activeChat.messages) ? activeChat.messages.length : void 0,
8215
+ activeModal: activeChat.activeModal,
8216
+ messagesTail: Array.isArray(activeChat.messages) ? activeChat.messages.slice(-10) : void 0
8217
+ } : null,
8218
+ controlValues: state.controlValues,
8219
+ summaryMetadata: state.summaryMetadata
8220
+ };
8221
+ }
8222
+ function buildDebugBundleText(bundle) {
8223
+ return [
8224
+ "# ADHDev Chat Debug Bundle",
8225
+ "",
8226
+ "```json",
8227
+ JSON.stringify(bundle, null, 2),
8228
+ "```"
8229
+ ].join("\n");
8230
+ }
8231
+ async function handleGetChatDebugBundle(h, args) {
8232
+ const provider = h.getProvider(args?.agentType);
8233
+ const transport = getTargetTransport(h, provider);
8234
+ const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
8235
+ const providerType = provider?.type || getCurrentProviderType(h, args?.agentType || "");
8236
+ const adapter = isCliLikeTransport(transport) ? getTargetedCliAdapter(h, args, provider?.type) : null;
8237
+ const targetInstance = getTargetInstance(h, args);
8238
+ let adapterStatus = null;
8239
+ let parsedStatus = null;
8240
+ let adapterDebugSnapshot = null;
8241
+ let partialResponse = "";
8242
+ if (adapter) {
8243
+ try {
8244
+ adapterStatus = adapter.getStatus?.();
8245
+ } catch (error48) {
8246
+ adapterStatus = { error: error48?.message || String(error48) };
8247
+ }
8248
+ try {
8249
+ parsedStatus = typeof adapter.getScriptParsedStatus === "function" ? parseMaybeJson(adapter.getScriptParsedStatus()) : null;
8250
+ } catch (error48) {
8251
+ parsedStatus = { error: error48?.message || String(error48) };
8252
+ }
8253
+ try {
8254
+ adapterDebugSnapshot = typeof adapter.getDebugSnapshot === "function" ? adapter.getDebugSnapshot() : null;
8255
+ } catch (error48) {
8256
+ adapterDebugSnapshot = { error: error48?.message || String(error48) };
8257
+ }
8258
+ try {
8259
+ partialResponse = adapter.getPartialResponse?.() || "";
8260
+ } catch {
8261
+ partialResponse = "";
8262
+ }
8263
+ }
8264
+ let instanceState = null;
8265
+ if (targetInstance?.getState) {
8266
+ try {
8267
+ instanceState = summarizeStateForDebug(targetInstance.getState());
8268
+ } catch (error48) {
8269
+ instanceState = { error: error48?.message || String(error48) };
8270
+ }
8271
+ }
8272
+ let readChat = null;
8273
+ try {
8274
+ const readResult = await handleReadChat(h, { ...args, tailLimit: Math.max(1, Math.min(40, Number(args?.tailLimit || 40))) });
8275
+ readChat = readResult.success ? {
8276
+ success: true,
8277
+ status: readResult.status,
8278
+ title: readResult.title,
8279
+ totalMessages: readResult.totalMessages,
8280
+ returnedMessages: Array.isArray(readResult.messages) ? readResult.messages.length : void 0,
8281
+ syncMode: readResult.syncMode,
8282
+ replaceFrom: readResult.replaceFrom,
8283
+ lastMessageSignature: readResult.lastMessageSignature,
8284
+ providerSessionId: readResult.providerSessionId,
8285
+ transcriptAuthority: readResult.transcriptAuthority,
8286
+ coverage: readResult.coverage,
8287
+ activeModal: readResult.activeModal,
8288
+ messagesTail: Array.isArray(readResult.messages) ? readResult.messages.slice(-20) : [],
8289
+ debugReadChat: readResult.debugReadChat
8290
+ } : { success: false, error: readResult.error };
8291
+ } catch (error48) {
8292
+ readChat = { success: false, error: error48?.message || String(error48) };
8293
+ }
8294
+ const cdp = h.getCdp();
8295
+ const rawBundle = {
8296
+ version: 1,
8297
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
8298
+ target: {
8299
+ targetSessionId,
8300
+ providerType,
8301
+ transport,
8302
+ routeManagerKey: h.currentManagerKey,
8303
+ currentIdeType: h.currentIdeType
8304
+ },
8305
+ session: summarizeSessionForDebug(h.currentSession),
8306
+ provider: summarizeProviderForDebug(provider),
8307
+ daemon: {
8308
+ pid: process.pid,
8309
+ platform: process.platform,
8310
+ nodeVersion: process.version,
8311
+ cwd: process.cwd()
8312
+ },
8313
+ cdp: {
8314
+ requested: !!cdp,
8315
+ connected: !!cdp?.isConnected,
8316
+ managerKey: getCurrentManagerKey(h)
8317
+ },
8318
+ instanceState,
8319
+ cli: adapter ? {
8320
+ cliType: adapter.cliType,
8321
+ cliName: adapter.cliName,
8322
+ workingDir: adapter.workingDir,
8323
+ status: adapterStatus?.status,
8324
+ activeModal: adapterStatus?.activeModal,
8325
+ messageCount: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.length : void 0,
8326
+ messagesTail: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.slice(-20) : void 0,
8327
+ parsedStatus,
8328
+ partialResponse,
8329
+ ready: typeof adapter.isReady === "function" ? adapter.isReady() : void 0,
8330
+ processing: typeof adapter.isProcessing === "function" ? adapter.isProcessing() : void 0,
8331
+ debugSnapshot: adapterDebugSnapshot
8332
+ } : null,
8333
+ readChat,
8334
+ frontend: args?.frontendSnapshot && typeof args.frontendSnapshot === "object" ? args.frontendSnapshot : null,
8335
+ recentLogs: getRecentLogs(80, "debug"),
8336
+ recentDebugTrace: getRecentDebugTrace({ limit: 120 })
8337
+ };
8338
+ const bundle = sanitizeDebugBundleValue(rawBundle);
8339
+ return {
8340
+ success: true,
8341
+ bundle,
8342
+ text: buildDebugBundleText(bundle)
8343
+ };
8344
+ }
8109
8345
  function didProviderConfirmSend(result) {
8110
8346
  const parsed = parseMaybeJson(result);
8111
8347
  if (parsed === true) return true;
@@ -9079,7 +9315,7 @@ async function handleResolveAction(h, args) {
9079
9315
  }
9080
9316
  return { success: false, error: "resolveAction script not available for this provider" };
9081
9317
  }
9082
- var RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget;
9318
+ var RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN;
9083
9319
  var init_chat_commands = __esm({
9084
9320
  "../../oss/packages/daemon-core/src/commands/chat-commands.ts"() {
9085
9321
  "use strict";
@@ -9094,6 +9330,13 @@ var init_chat_commands = __esm({
9094
9330
  RECENT_SEND_WINDOW_MS = 1200;
9095
9331
  READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
9096
9332
  recentSendByTarget = /* @__PURE__ */ new Map();
9333
+ DEFAULT_DEBUG_SANITIZE_OPTIONS = {
9334
+ maxDepth: 8,
9335
+ maxArrayLength: 80,
9336
+ maxObjectKeys: 120,
9337
+ maxStringLength: 16e3
9338
+ };
9339
+ SECRET_KEY_PATTERN = /(?:token|secret|password|passwd|authorization|cookie|api[_-]?key|access[_-]?key|refresh[_-]?token|client[_-]?secret|private[_-]?key)/i;
9097
9340
  }
9098
9341
  });
9099
9342
 
@@ -10361,6 +10604,8 @@ var init_handler = __esm({
10361
10604
  // ─── Chat commands (chat-commands.ts) ───────────────
10362
10605
  case "read_chat":
10363
10606
  return handleReadChat(this, args);
10607
+ case "get_chat_debug_bundle":
10608
+ return handleGetChatDebugBundle(this, args);
10364
10609
  case "chat_history":
10365
10610
  return handleChatHistory(this, args);
10366
10611
  case "send_chat":
@@ -12150,7 +12395,12 @@ function findBinary(name) {
12150
12395
  const isWin = os11.platform() === "win32";
12151
12396
  try {
12152
12397
  const cmd = isWin ? `where ${trimmed}` : `which ${trimmed}`;
12153
- return (0, import_child_process4.execSync)(cmd, { encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }).trim().split("\n")[0].trim();
12398
+ return (0, import_child_process4.execSync)(cmd, {
12399
+ encoding: "utf-8",
12400
+ timeout: 5e3,
12401
+ stdio: ["pipe", "pipe", "pipe"],
12402
+ ...isWin ? { windowsHide: true } : {}
12403
+ }).trim().split("\n")[0].trim();
12154
12404
  } catch {
12155
12405
  return isWin ? `${trimmed}.cmd` : trimmed;
12156
12406
  }
@@ -14835,6 +15085,83 @@ var init_provider_cli_adapter = __esm({
14835
15085
  if (!this.isWaitingForResponse) return "";
14836
15086
  return this.responseBuffer;
14837
15087
  }
15088
+ getDebugSnapshot() {
15089
+ const screenText = this.readTerminalScreenText();
15090
+ const parsedResult = this.parsedStatusCache?.result && typeof this.parsedStatusCache.result === "object" ? this.parsedStatusCache.result : null;
15091
+ return {
15092
+ cliType: this.cliType,
15093
+ cliName: this.cliName,
15094
+ workingDir: this.workingDir,
15095
+ currentStatus: this.currentStatus,
15096
+ ready: this.ready,
15097
+ isWaitingForResponse: this.isWaitingForResponse,
15098
+ activeModal: this.activeModal,
15099
+ parseErrorMessage: this.parseErrorMessage,
15100
+ messageCounts: {
15101
+ committed: this.committedMessages.length,
15102
+ structured: this.structuredMessages.length,
15103
+ visible: this.messages.length,
15104
+ parsedCache: Array.isArray(parsedResult?.messages) ? parsedResult.messages.length : void 0
15105
+ },
15106
+ buffers: {
15107
+ accumulatedLength: this.accumulatedBuffer.length,
15108
+ accumulatedRawLength: this.accumulatedRawBuffer.length,
15109
+ recentOutputLength: this.recentOutputBuffer.length,
15110
+ responseLength: this.responseBuffer.length,
15111
+ startupLength: this.startupBuffer.length,
15112
+ accumulatedTail: this.accumulatedBuffer.slice(-24e3),
15113
+ accumulatedRawTail: this.accumulatedRawBuffer.slice(-24e3),
15114
+ recentOutputTail: this.recentOutputBuffer.slice(-12e3),
15115
+ responseTail: this.responseBuffer.slice(-12e3)
15116
+ },
15117
+ terminal: {
15118
+ screenText,
15119
+ lastScreenSnapshot: this.lastScreenSnapshot,
15120
+ lastScreenText: this.lastScreenText,
15121
+ lastOutputAt: this.lastOutputAt,
15122
+ lastNonEmptyOutputAt: this.lastNonEmptyOutputAt,
15123
+ lastScreenChangeAt: this.lastScreenChangeAt,
15124
+ lastScreenSnapshotReadAt: this.lastScreenSnapshotReadAt
15125
+ },
15126
+ parser: {
15127
+ scriptNames: listCliScriptNames(this.cliScripts),
15128
+ traceSessionId: this.traceSessionId,
15129
+ traceSeq: this.traceSeq,
15130
+ currentTurnScope: this.currentTurnScope,
15131
+ parsedStatusCache: parsedResult ? {
15132
+ id: parsedResult.id,
15133
+ status: parsedResult.status,
15134
+ title: parsedResult.title,
15135
+ providerSessionId: parsedResult.providerSessionId,
15136
+ transcriptAuthority: parsedResult.transcriptAuthority,
15137
+ coverage: parsedResult.coverage,
15138
+ messageCount: Array.isArray(parsedResult.messages) ? parsedResult.messages.length : void 0,
15139
+ activeModal: parsedResult.activeModal
15140
+ } : null,
15141
+ pendingScriptStatus: this.pendingScriptStatus,
15142
+ pendingScriptStatusSince: this.pendingScriptStatusSince
15143
+ },
15144
+ runtimeMetadata: this.getRuntimeMetadata(),
15145
+ statusHistory: this.statusHistory.slice(-80),
15146
+ traceEntries: this.traceEntries.slice(-120),
15147
+ timing: {
15148
+ spawnAt: this.spawnAt,
15149
+ startupFirstOutputAt: this.startupFirstOutputAt,
15150
+ submitPendingUntil: this.submitPendingUntil,
15151
+ responseSettleIgnoreUntil: this.responseSettleIgnoreUntil,
15152
+ responseEpoch: this.responseEpoch,
15153
+ resizeSuppressUntil: this.resizeSuppressUntil,
15154
+ lastApprovalResolvedAt: this.lastApprovalResolvedAt,
15155
+ committedMessagesChangedAt: this.committedMessagesChangedAt
15156
+ },
15157
+ finish: {
15158
+ idleFinishCandidate: this.idleFinishCandidate,
15159
+ finishRetryCount: this.finishRetryCount,
15160
+ submitRetryUsed: this.submitRetryUsed,
15161
+ submitRetryPromptSnippet: this.submitRetryPromptSnippet
15162
+ }
15163
+ };
15164
+ }
14838
15165
  getRuntimeMetadata() {
14839
15166
  if (!this.ptyProcess || typeof this.ptyProcess.getMetadata !== "function") return null;
14840
15167
  return this.ptyProcess.getMetadata();
@@ -32911,7 +33238,8 @@ var init_acp_provider_instance = __esm({
32911
33238
  cwd: this.workingDir,
32912
33239
  env: env3,
32913
33240
  stdio: ["pipe", "pipe", "pipe"],
32914
- shell: spawnConfig.shell || false
33241
+ shell: spawnConfig.shell || false,
33242
+ ...process.platform === "win32" ? { windowsHide: true } : {}
32915
33243
  });
32916
33244
  const AUTH_ERROR_PATTERNS = [
32917
33245
  /unauthorized|unauthenticated/i,
@@ -33610,7 +33938,10 @@ function commandExists(command) {
33610
33938
  return (0, import_fs5.existsSync)(expandExecutable(trimmed));
33611
33939
  }
33612
33940
  try {
33613
- (0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], { stdio: "ignore" });
33941
+ (0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
33942
+ stdio: "ignore",
33943
+ ...process.platform === "win32" ? { windowsHide: true } : {}
33944
+ });
33614
33945
  return true;
33615
33946
  } catch {
33616
33947
  return false;
@@ -38329,7 +38660,7 @@ async function launchMacOS(ide, port, workspace, newWindow) {
38329
38660
  const canUseAppLauncher = !!appName;
38330
38661
  const useAppLauncher = preferredMethod === "app" ? canUseAppLauncher : preferredMethod === "cli" ? false : !canUseCli && canUseAppLauncher;
38331
38662
  if (!useAppLauncher && ide.cliCommand) {
38332
- (0, import_child_process7.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore" }).unref();
38663
+ (0, import_child_process7.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
38333
38664
  } else if (appName) {
38334
38665
  const openArgs = ["-a", appName, "--args", ...args];
38335
38666
  (0, import_child_process7.spawn)("open", openArgs, { detached: true, stdio: "ignore" }).unref();
@@ -38358,7 +38689,7 @@ async function launchLinux(ide, port, workspace, newWindow) {
38358
38689
  const args = ["--remote-debugging-port=" + port];
38359
38690
  if (newWindow) args.push("--new-window");
38360
38691
  if (workspace) args.push(workspace);
38361
- (0, import_child_process7.spawn)(cli, args, { detached: true, stdio: "ignore" }).unref();
38692
+ (0, import_child_process7.spawn)(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
38362
38693
  }
38363
38694
  function getAvailableIdeIds() {
38364
38695
  return getProviderLoader().getAvailableIdeTypes();
@@ -38867,23 +39198,23 @@ function resolveSiblingNpmInvocation(nodeExecutable, platform12 = process.platfo
38867
39198
  if (platform12 === "win32") {
38868
39199
  const npmCliPath = path17.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
38869
39200
  if (fs8.existsSync(npmCliPath)) {
38870
- return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: { shell: false } };
39201
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
38871
39202
  }
38872
39203
  for (const candidate of ["npm.exe", "npm"]) {
38873
39204
  const candidatePath = path17.join(binDir, candidate);
38874
39205
  if (fs8.existsSync(candidatePath)) {
38875
- return { executable: candidatePath, argsPrefix: [], execOptions: { shell: false } };
39206
+ return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
38876
39207
  }
38877
39208
  }
38878
- return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: { shell: false } };
39209
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
38879
39210
  }
38880
39211
  for (const candidate of ["npm"]) {
38881
39212
  const candidatePath = path17.join(binDir, candidate);
38882
39213
  if (fs8.existsSync(candidatePath)) {
38883
- return { executable: candidatePath, argsPrefix: [], execOptions: { shell: false } };
39214
+ return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
38884
39215
  }
38885
39216
  }
38886
- return { executable: "npm", argsPrefix: [], execOptions: { shell: false } };
39217
+ return { executable: "npm", argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
38887
39218
  }
38888
39219
  function findCurrentPackageRoot(currentCliPath, packageName) {
38889
39220
  if (!currentCliPath) return null;
@@ -38954,13 +39285,28 @@ function buildPinnedGlobalInstallCommand(options) {
38954
39285
  execOptions: surface.execOptions || getNpmExecOptions(options.platform)
38955
39286
  };
38956
39287
  }
38957
- function getNpmExecOptions(_platform = process.platform) {
39288
+ function getNpmExecOptions(platform12 = process.platform) {
39289
+ if (platform12 === "win32") {
39290
+ return { shell: false, windowsHide: true };
39291
+ }
38958
39292
  return { shell: false };
38959
39293
  }
39294
+ function execNpmCommandSync(args, options = {}, surface) {
39295
+ const execOptions = surface?.execOptions || getNpmExecOptions();
39296
+ return (0, import_child_process8.execFileSync)(
39297
+ surface?.npmExecutable || "npm",
39298
+ [...surface?.npmArgsPrefix || [], ...args],
39299
+ {
39300
+ ...options,
39301
+ ...execOptions,
39302
+ ...process.platform === "win32" ? { windowsHide: true } : {}
39303
+ }
39304
+ );
39305
+ }
38960
39306
  function killPid(pid) {
38961
39307
  try {
38962
39308
  if (process.platform === "win32") {
38963
- (0, import_child_process8.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
39309
+ (0, import_child_process8.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
38964
39310
  } else {
38965
39311
  process.kill(pid, "SIGTERM");
38966
39312
  }
@@ -38979,7 +39325,7 @@ function getWindowsProcessCommandLine(pid) {
38979
39325
  "Bypass",
38980
39326
  "-Command",
38981
39327
  `(Get-CimInstance Win32_Process -Filter "${pidFilter}").CommandLine`
38982
- ], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
39328
+ ], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
38983
39329
  if (psOut) return psOut;
38984
39330
  } catch {
38985
39331
  }
@@ -38990,7 +39336,7 @@ function getWindowsProcessCommandLine(pid) {
38990
39336
  pidFilter,
38991
39337
  "get",
38992
39338
  "CommandLine"
38993
- ], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
39339
+ ], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
38994
39340
  if (wmicOut) return wmicOut;
38995
39341
  } catch {
38996
39342
  }
@@ -39051,9 +39397,9 @@ function removeDaemonPidFile() {
39051
39397
  }
39052
39398
  function cleanupStaleGlobalInstallDirs(pkgName, surface) {
39053
39399
  const prefixArgs = surface.installPrefix ? ["--prefix", surface.installPrefix] : [];
39054
- const npmRoot = (0, import_child_process8.execFileSync)(surface.npmExecutable, [...surface.npmArgsPrefix || [], "root", "-g", ...prefixArgs], { encoding: "utf8", ...surface.execOptions }).trim();
39400
+ const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
39055
39401
  if (!npmRoot) return;
39056
- const npmPrefix = surface.installPrefix || (0, import_child_process8.execFileSync)(surface.npmExecutable, [...surface.npmArgsPrefix || [], "prefix", "-g", ...prefixArgs], { encoding: "utf8", ...surface.execOptions }).trim();
39402
+ const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
39057
39403
  const binDir = process.platform === "win32" ? npmPrefix : path17.join(npmPrefix, "bin");
39058
39404
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
39059
39405
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
@@ -39875,18 +40221,18 @@ var init_router = __esm({
39875
40221
  case "daemon_upgrade": {
39876
40222
  LOG.info("Upgrade", "Remote upgrade requested from dashboard");
39877
40223
  try {
39878
- const { execSync: execSync8 } = await import("child_process");
39879
40224
  const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
39880
40225
  const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
39881
- const latest = execSync8(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
40226
+ const npmSurface = resolveCurrentGlobalInstallSurface({ packageName: pkgName });
40227
+ const latest = String(execNpmCommandSync(["view", pkgName, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
39882
40228
  LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
39883
40229
  let currentInstalled = null;
39884
40230
  try {
39885
- const currentJson = execSync8(`npm ls -g ${pkgName} --depth=0 --json`, {
40231
+ const currentJson = String(execNpmCommandSync(["ls", "-g", pkgName, "--depth=0", "--json"], {
39886
40232
  encoding: "utf-8",
39887
40233
  timeout: 1e4,
39888
40234
  stdio: ["pipe", "pipe", "pipe"]
39889
- }).trim();
40235
+ }, npmSurface)).trim();
39890
40236
  const parsed = JSON.parse(currentJson);
39891
40237
  currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
39892
40238
  } catch {
@@ -48135,6 +48481,7 @@ __export(src_exports, {
48135
48481
  detectCLIs: () => detectCLIs,
48136
48482
  detectIDEs: () => detectIDEs,
48137
48483
  ensureSessionHostReady: () => ensureSessionHostReady,
48484
+ execNpmCommandSync: () => execNpmCommandSync,
48138
48485
  findCdpManager: () => findCdpManager,
48139
48486
  flattenMessageParts: () => flattenMessageParts,
48140
48487
  forwardAgentStreamsToIdeInstance: () => forwardAgentStreamsToIdeInstance,
@@ -48145,6 +48492,7 @@ __export(src_exports, {
48145
48492
  getDebugRuntimeConfig: () => getDebugRuntimeConfig,
48146
48493
  getHostMemorySnapshot: () => getHostMemorySnapshot,
48147
48494
  getLogLevel: () => getLogLevel,
48495
+ getNpmExecOptions: () => getNpmExecOptions,
48148
48496
  getRecentActivity: () => getRecentActivity,
48149
48497
  getRecentCommands: () => getRecentCommands,
48150
48498
  getRecentDebugTrace: () => getRecentDebugTrace,
@@ -88085,7 +88433,7 @@ var init_adhdev_daemon = __esm({
88085
88433
  init_version();
88086
88434
  init_src();
88087
88435
  init_runtime_defaults();
88088
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.48" });
88436
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.49" });
88089
88437
  AdhdevDaemon = class _AdhdevDaemon {
88090
88438
  localHttpServer = null;
88091
88439
  localWss = null;
@@ -91965,7 +92313,9 @@ async function runDaemonUpgrade(options, pkgVersion3) {
91965
92313
  console.log(source_default.cyan("\n Checking for updates..."));
91966
92314
  let latest;
91967
92315
  try {
91968
- latest = execSync8("npm view adhdev version", { encoding: "utf-8" }).trim();
92316
+ const { execNpmCommandSync: execNpmCommandSync2, resolveCurrentGlobalInstallSurface: resolveCurrentGlobalInstallSurface2 } = await Promise.resolve().then(() => (init_src(), src_exports));
92317
+ const npmSurface = resolveCurrentGlobalInstallSurface2({ packageName: "adhdev" });
92318
+ latest = String(execNpmCommandSync2(["view", "adhdev", "version"], { encoding: "utf-8" }, npmSurface)).trim();
91969
92319
  } catch (e) {
91970
92320
  console.log(source_default.red(`
91971
92321
  \u2717 Failed to check latest version: ${e?.message}