@adhdev/daemon-standalone 0.9.47 → 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
@@ -29342,7 +29342,12 @@ var require_dist2 = __commonJS({
29342
29342
  const isWin = os8.platform() === "win32";
29343
29343
  try {
29344
29344
  const cmd = isWin ? `where ${trimmed}` : `which ${trimmed}`;
29345
- return (0, import_child_process4.execSync)(cmd, { encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }).trim().split("\n")[0].trim();
29345
+ return (0, import_child_process4.execSync)(cmd, {
29346
+ encoding: "utf-8",
29347
+ timeout: 5e3,
29348
+ stdio: ["pipe", "pipe", "pipe"],
29349
+ ...isWin ? { windowsHide: true } : {}
29350
+ }).trim().split("\n")[0].trim();
29346
29351
  } catch {
29347
29352
  return isWin ? `${trimmed}.cmd` : trimmed;
29348
29353
  }
@@ -32027,6 +32032,83 @@ var require_dist2 = __commonJS({
32027
32032
  if (!this.isWaitingForResponse) return "";
32028
32033
  return this.responseBuffer;
32029
32034
  }
32035
+ getDebugSnapshot() {
32036
+ const screenText = this.readTerminalScreenText();
32037
+ const parsedResult = this.parsedStatusCache?.result && typeof this.parsedStatusCache.result === "object" ? this.parsedStatusCache.result : null;
32038
+ return {
32039
+ cliType: this.cliType,
32040
+ cliName: this.cliName,
32041
+ workingDir: this.workingDir,
32042
+ currentStatus: this.currentStatus,
32043
+ ready: this.ready,
32044
+ isWaitingForResponse: this.isWaitingForResponse,
32045
+ activeModal: this.activeModal,
32046
+ parseErrorMessage: this.parseErrorMessage,
32047
+ messageCounts: {
32048
+ committed: this.committedMessages.length,
32049
+ structured: this.structuredMessages.length,
32050
+ visible: this.messages.length,
32051
+ parsedCache: Array.isArray(parsedResult?.messages) ? parsedResult.messages.length : void 0
32052
+ },
32053
+ buffers: {
32054
+ accumulatedLength: this.accumulatedBuffer.length,
32055
+ accumulatedRawLength: this.accumulatedRawBuffer.length,
32056
+ recentOutputLength: this.recentOutputBuffer.length,
32057
+ responseLength: this.responseBuffer.length,
32058
+ startupLength: this.startupBuffer.length,
32059
+ accumulatedTail: this.accumulatedBuffer.slice(-24e3),
32060
+ accumulatedRawTail: this.accumulatedRawBuffer.slice(-24e3),
32061
+ recentOutputTail: this.recentOutputBuffer.slice(-12e3),
32062
+ responseTail: this.responseBuffer.slice(-12e3)
32063
+ },
32064
+ terminal: {
32065
+ screenText,
32066
+ lastScreenSnapshot: this.lastScreenSnapshot,
32067
+ lastScreenText: this.lastScreenText,
32068
+ lastOutputAt: this.lastOutputAt,
32069
+ lastNonEmptyOutputAt: this.lastNonEmptyOutputAt,
32070
+ lastScreenChangeAt: this.lastScreenChangeAt,
32071
+ lastScreenSnapshotReadAt: this.lastScreenSnapshotReadAt
32072
+ },
32073
+ parser: {
32074
+ scriptNames: listCliScriptNames(this.cliScripts),
32075
+ traceSessionId: this.traceSessionId,
32076
+ traceSeq: this.traceSeq,
32077
+ currentTurnScope: this.currentTurnScope,
32078
+ parsedStatusCache: parsedResult ? {
32079
+ id: parsedResult.id,
32080
+ status: parsedResult.status,
32081
+ title: parsedResult.title,
32082
+ providerSessionId: parsedResult.providerSessionId,
32083
+ transcriptAuthority: parsedResult.transcriptAuthority,
32084
+ coverage: parsedResult.coverage,
32085
+ messageCount: Array.isArray(parsedResult.messages) ? parsedResult.messages.length : void 0,
32086
+ activeModal: parsedResult.activeModal
32087
+ } : null,
32088
+ pendingScriptStatus: this.pendingScriptStatus,
32089
+ pendingScriptStatusSince: this.pendingScriptStatusSince
32090
+ },
32091
+ runtimeMetadata: this.getRuntimeMetadata(),
32092
+ statusHistory: this.statusHistory.slice(-80),
32093
+ traceEntries: this.traceEntries.slice(-120),
32094
+ timing: {
32095
+ spawnAt: this.spawnAt,
32096
+ startupFirstOutputAt: this.startupFirstOutputAt,
32097
+ submitPendingUntil: this.submitPendingUntil,
32098
+ responseSettleIgnoreUntil: this.responseSettleIgnoreUntil,
32099
+ responseEpoch: this.responseEpoch,
32100
+ resizeSuppressUntil: this.resizeSuppressUntil,
32101
+ lastApprovalResolvedAt: this.lastApprovalResolvedAt,
32102
+ committedMessagesChangedAt: this.committedMessagesChangedAt
32103
+ },
32104
+ finish: {
32105
+ idleFinishCandidate: this.idleFinishCandidate,
32106
+ finishRetryCount: this.finishRetryCount,
32107
+ submitRetryUsed: this.submitRetryUsed,
32108
+ submitRetryPromptSnippet: this.submitRetryPromptSnippet
32109
+ }
32110
+ };
32111
+ }
32030
32112
  getRuntimeMetadata() {
32031
32113
  if (!this.ptyProcess || typeof this.ptyProcess.getMetadata !== "function") return null;
32032
32114
  return this.ptyProcess.getMetadata();
@@ -32382,6 +32464,7 @@ var require_dist2 = __commonJS({
32382
32464
  detectCLIs: () => detectCLIs,
32383
32465
  detectIDEs: () => detectIDEs,
32384
32466
  ensureSessionHostReady: () => ensureSessionHostReady2,
32467
+ execNpmCommandSync: () => execNpmCommandSync,
32385
32468
  findCdpManager: () => findCdpManager,
32386
32469
  flattenMessageParts: () => flattenMessageParts,
32387
32470
  forwardAgentStreamsToIdeInstance: () => forwardAgentStreamsToIdeInstance2,
@@ -32392,6 +32475,7 @@ var require_dist2 = __commonJS({
32392
32475
  getDebugRuntimeConfig: () => getDebugRuntimeConfig,
32393
32476
  getHostMemorySnapshot: () => getHostMemorySnapshot,
32394
32477
  getLogLevel: () => getLogLevel,
32478
+ getNpmExecOptions: () => getNpmExecOptions,
32395
32479
  getRecentActivity: () => getRecentActivity,
32396
32480
  getRecentCommands: () => getRecentCommands,
32397
32481
  getRecentDebugTrace: () => getRecentDebugTrace,
@@ -33120,7 +33204,11 @@ var require_dist2 = __commonJS({
33120
33204
  }
33121
33205
  function execAsync(cmd, timeoutMs = 5e3) {
33122
33206
  return new Promise((resolve12) => {
33123
- const child = (0, import_child_process2.exec)(cmd, { encoding: "utf-8", timeout: timeoutMs }, (err, stdout) => {
33207
+ const child = (0, import_child_process2.exec)(cmd, {
33208
+ encoding: "utf-8",
33209
+ timeout: timeoutMs,
33210
+ ...process.platform === "win32" ? { windowsHide: true } : {}
33211
+ }, (err, stdout) => {
33124
33212
  if (err || !stdout?.trim()) {
33125
33213
  resolve12(null);
33126
33214
  } else {
@@ -38728,6 +38816,245 @@ ${effect.notification.body || ""}`.trim();
38728
38816
  ...debugReadChat ? { debugReadChat } : {}
38729
38817
  };
38730
38818
  }
38819
+ var DEFAULT_DEBUG_SANITIZE_OPTIONS = {
38820
+ maxDepth: 8,
38821
+ maxArrayLength: 80,
38822
+ maxObjectKeys: 120,
38823
+ maxStringLength: 16e3
38824
+ };
38825
+ var SECRET_KEY_PATTERN = /(?:token|secret|password|passwd|authorization|cookie|api[_-]?key|access[_-]?key|refresh[_-]?token|client[_-]?secret|private[_-]?key)/i;
38826
+ function truncateDebugString(value, maxLength) {
38827
+ if (value.length <= maxLength) return value;
38828
+ return `${value.slice(0, maxLength)}\u2026[truncated ${value.length - maxLength} chars]`;
38829
+ }
38830
+ function redactDebugSecrets(value) {
38831
+ 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]");
38832
+ }
38833
+ function sanitizeDebugBundleValue(value, options = {}, depth = 0, keyHint = "") {
38834
+ const normalizedOptions = { ...DEFAULT_DEBUG_SANITIZE_OPTIONS, ...options };
38835
+ if (value === null || value === void 0) return value;
38836
+ if (typeof value === "number" || typeof value === "boolean") return value;
38837
+ if (typeof value === "bigint") return String(value);
38838
+ if (typeof value === "string") {
38839
+ if (SECRET_KEY_PATTERN.test(keyHint) && value.trim()) return "[REDACTED:secret-field]";
38840
+ return truncateDebugString(redactDebugSecrets(value), normalizedOptions.maxStringLength);
38841
+ }
38842
+ if (typeof value === "function") return `[Function ${value.name || "anonymous"}]`;
38843
+ if (typeof value !== "object") return String(value);
38844
+ if (depth >= normalizedOptions.maxDepth) return "[MaxDepth]";
38845
+ if (Array.isArray(value)) {
38846
+ const items = value.slice(0, normalizedOptions.maxArrayLength).map((item) => sanitizeDebugBundleValue(item, normalizedOptions, depth + 1, keyHint));
38847
+ if (value.length > normalizedOptions.maxArrayLength) {
38848
+ items.push(`[truncated ${value.length - normalizedOptions.maxArrayLength} items]`);
38849
+ }
38850
+ return items;
38851
+ }
38852
+ const record2 = value;
38853
+ const result = {};
38854
+ const entries = Object.entries(record2).slice(0, normalizedOptions.maxObjectKeys);
38855
+ for (const [key, item] of entries) {
38856
+ result[key] = sanitizeDebugBundleValue(item, normalizedOptions, depth + 1, key);
38857
+ }
38858
+ const remaining = Object.keys(record2).length - entries.length;
38859
+ if (remaining > 0) result.__truncatedKeys = remaining;
38860
+ return result;
38861
+ }
38862
+ function summarizeProviderForDebug(provider) {
38863
+ if (!provider) return null;
38864
+ const scripts = provider.scripts && typeof provider.scripts === "object" ? Object.keys(provider.scripts) : [];
38865
+ const controls = Array.isArray(provider.controls) ? provider.controls.map((control) => ({
38866
+ id: control?.id,
38867
+ label: control?.label,
38868
+ type: control?.type,
38869
+ settingKey: control?.settingKey,
38870
+ invokeScript: control?.invokeScript,
38871
+ listScript: control?.listScript,
38872
+ location: control?.location
38873
+ })) : [];
38874
+ return {
38875
+ type: provider.type,
38876
+ name: provider.name,
38877
+ category: provider.category,
38878
+ version: provider.version,
38879
+ canonicalHistory: provider.canonicalHistory,
38880
+ historyBehavior: provider.historyBehavior,
38881
+ webviewMatchText: provider.webviewMatchText,
38882
+ scriptNames: scripts,
38883
+ controls,
38884
+ resume: provider.resume
38885
+ };
38886
+ }
38887
+ function summarizeSessionForDebug(session) {
38888
+ if (!session || typeof session !== "object") return null;
38889
+ return {
38890
+ sessionId: session.sessionId,
38891
+ instanceKey: session.instanceKey,
38892
+ adapterKey: session.adapterKey,
38893
+ providerType: session.providerType,
38894
+ providerName: session.providerName,
38895
+ transport: session.transport,
38896
+ kind: session.kind,
38897
+ cdpManagerKey: session.cdpManagerKey,
38898
+ parentSessionId: session.parentSessionId,
38899
+ providerSessionId: session.providerSessionId,
38900
+ workspace: session.workspace,
38901
+ title: session.title,
38902
+ status: session.status,
38903
+ mode: session.mode,
38904
+ capabilities: session.capabilities
38905
+ };
38906
+ }
38907
+ function summarizeStateForDebug(state) {
38908
+ if (!state || typeof state !== "object") return null;
38909
+ const activeChat = state.activeChat && typeof state.activeChat === "object" ? state.activeChat : null;
38910
+ return {
38911
+ type: state.type,
38912
+ name: state.name,
38913
+ category: state.category,
38914
+ status: state.status,
38915
+ instanceId: state.instanceId,
38916
+ providerSessionId: state.providerSessionId,
38917
+ title: state.title,
38918
+ transport: state.transport,
38919
+ mode: state.mode,
38920
+ workspace: state.workspace,
38921
+ runtime: state.runtime,
38922
+ errorMessage: state.errorMessage,
38923
+ errorReason: state.errorReason,
38924
+ activeChat: activeChat ? {
38925
+ status: activeChat.status,
38926
+ title: activeChat.title,
38927
+ messageCount: Array.isArray(activeChat.messages) ? activeChat.messages.length : void 0,
38928
+ activeModal: activeChat.activeModal,
38929
+ messagesTail: Array.isArray(activeChat.messages) ? activeChat.messages.slice(-10) : void 0
38930
+ } : null,
38931
+ controlValues: state.controlValues,
38932
+ summaryMetadata: state.summaryMetadata
38933
+ };
38934
+ }
38935
+ function buildDebugBundleText(bundle) {
38936
+ return [
38937
+ "# ADHDev Chat Debug Bundle",
38938
+ "",
38939
+ "```json",
38940
+ JSON.stringify(bundle, null, 2),
38941
+ "```"
38942
+ ].join("\n");
38943
+ }
38944
+ async function handleGetChatDebugBundle(h, args) {
38945
+ const provider = h.getProvider(args?.agentType);
38946
+ const transport = getTargetTransport(h, provider);
38947
+ const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
38948
+ const providerType = provider?.type || getCurrentProviderType(h, args?.agentType || "");
38949
+ const adapter = isCliLikeTransport(transport) ? getTargetedCliAdapter(h, args, provider?.type) : null;
38950
+ const targetInstance = getTargetInstance(h, args);
38951
+ let adapterStatus = null;
38952
+ let parsedStatus = null;
38953
+ let adapterDebugSnapshot = null;
38954
+ let partialResponse = "";
38955
+ if (adapter) {
38956
+ try {
38957
+ adapterStatus = adapter.getStatus?.();
38958
+ } catch (error48) {
38959
+ adapterStatus = { error: error48?.message || String(error48) };
38960
+ }
38961
+ try {
38962
+ parsedStatus = typeof adapter.getScriptParsedStatus === "function" ? parseMaybeJson(adapter.getScriptParsedStatus()) : null;
38963
+ } catch (error48) {
38964
+ parsedStatus = { error: error48?.message || String(error48) };
38965
+ }
38966
+ try {
38967
+ adapterDebugSnapshot = typeof adapter.getDebugSnapshot === "function" ? adapter.getDebugSnapshot() : null;
38968
+ } catch (error48) {
38969
+ adapterDebugSnapshot = { error: error48?.message || String(error48) };
38970
+ }
38971
+ try {
38972
+ partialResponse = adapter.getPartialResponse?.() || "";
38973
+ } catch {
38974
+ partialResponse = "";
38975
+ }
38976
+ }
38977
+ let instanceState = null;
38978
+ if (targetInstance?.getState) {
38979
+ try {
38980
+ instanceState = summarizeStateForDebug(targetInstance.getState());
38981
+ } catch (error48) {
38982
+ instanceState = { error: error48?.message || String(error48) };
38983
+ }
38984
+ }
38985
+ let readChat = null;
38986
+ try {
38987
+ const readResult = await handleReadChat(h, { ...args, tailLimit: Math.max(1, Math.min(40, Number(args?.tailLimit || 40))) });
38988
+ readChat = readResult.success ? {
38989
+ success: true,
38990
+ status: readResult.status,
38991
+ title: readResult.title,
38992
+ totalMessages: readResult.totalMessages,
38993
+ returnedMessages: Array.isArray(readResult.messages) ? readResult.messages.length : void 0,
38994
+ syncMode: readResult.syncMode,
38995
+ replaceFrom: readResult.replaceFrom,
38996
+ lastMessageSignature: readResult.lastMessageSignature,
38997
+ providerSessionId: readResult.providerSessionId,
38998
+ transcriptAuthority: readResult.transcriptAuthority,
38999
+ coverage: readResult.coverage,
39000
+ activeModal: readResult.activeModal,
39001
+ messagesTail: Array.isArray(readResult.messages) ? readResult.messages.slice(-20) : [],
39002
+ debugReadChat: readResult.debugReadChat
39003
+ } : { success: false, error: readResult.error };
39004
+ } catch (error48) {
39005
+ readChat = { success: false, error: error48?.message || String(error48) };
39006
+ }
39007
+ const cdp = h.getCdp();
39008
+ const rawBundle = {
39009
+ version: 1,
39010
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
39011
+ target: {
39012
+ targetSessionId,
39013
+ providerType,
39014
+ transport,
39015
+ routeManagerKey: h.currentManagerKey,
39016
+ currentIdeType: h.currentIdeType
39017
+ },
39018
+ session: summarizeSessionForDebug(h.currentSession),
39019
+ provider: summarizeProviderForDebug(provider),
39020
+ daemon: {
39021
+ pid: process.pid,
39022
+ platform: process.platform,
39023
+ nodeVersion: process.version,
39024
+ cwd: process.cwd()
39025
+ },
39026
+ cdp: {
39027
+ requested: !!cdp,
39028
+ connected: !!cdp?.isConnected,
39029
+ managerKey: getCurrentManagerKey(h)
39030
+ },
39031
+ instanceState,
39032
+ cli: adapter ? {
39033
+ cliType: adapter.cliType,
39034
+ cliName: adapter.cliName,
39035
+ workingDir: adapter.workingDir,
39036
+ status: adapterStatus?.status,
39037
+ activeModal: adapterStatus?.activeModal,
39038
+ messageCount: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.length : void 0,
39039
+ messagesTail: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.slice(-20) : void 0,
39040
+ parsedStatus,
39041
+ partialResponse,
39042
+ ready: typeof adapter.isReady === "function" ? adapter.isReady() : void 0,
39043
+ processing: typeof adapter.isProcessing === "function" ? adapter.isProcessing() : void 0,
39044
+ debugSnapshot: adapterDebugSnapshot
39045
+ } : null,
39046
+ readChat,
39047
+ frontend: args?.frontendSnapshot && typeof args.frontendSnapshot === "object" ? args.frontendSnapshot : null,
39048
+ recentLogs: getRecentLogs(80, "debug"),
39049
+ recentDebugTrace: getRecentDebugTrace({ limit: 120 })
39050
+ };
39051
+ const bundle = sanitizeDebugBundleValue(rawBundle);
39052
+ return {
39053
+ success: true,
39054
+ bundle,
39055
+ text: buildDebugBundleText(bundle)
39056
+ };
39057
+ }
38731
39058
  function didProviderConfirmSend(result) {
38732
39059
  const parsed = parseMaybeJson(result);
38733
39060
  if (parsed === true) return true;
@@ -40111,7 +40438,8 @@ ${effect.notification.body || ""}`.trim();
40111
40438
  if (command.type !== "send_message" && command.type !== "pty_write") return null;
40112
40439
  const text = typeof command.text === "string" ? command.text.trim() : typeof command.message === "string" ? command.message.trim() : "";
40113
40440
  if (!text) return null;
40114
- return { type: command.type, text };
40441
+ const enterCount = Number.isInteger(command.enterCount) && command.enterCount > 0 && command.enterCount <= 5 ? command.enterCount : void 0;
40442
+ return { type: command.type, text, ...enterCount ? { enterCount } : {} };
40115
40443
  }
40116
40444
  init_logger();
40117
40445
  function normalizeOpenPanelCommandResult(result) {
@@ -40367,7 +40695,12 @@ ${effect.notification.body || ""}`.trim();
40367
40695
  if (cliCommand?.type === "send_message" && cliCommand.text) {
40368
40696
  await adapter.sendMessage(cliCommand.text);
40369
40697
  } else if (cliCommand?.type === "pty_write" && cliCommand.text && adapter.writeRaw) {
40698
+ const enterCount = cliCommand.enterCount || 1;
40370
40699
  await adapter.writeRaw(cliCommand.text + "\r");
40700
+ for (let i = 1; i < enterCount; i += 1) {
40701
+ await new Promise((resolve12) => setTimeout(resolve12, 50));
40702
+ await adapter.writeRaw("\r");
40703
+ }
40371
40704
  }
40372
40705
  applyProviderPatch(h, args, parsed.payload);
40373
40706
  return {
@@ -40904,6 +41237,8 @@ ${effect.notification.body || ""}`.trim();
40904
41237
  // ─── Chat commands (chat-commands.ts) ───────────────
40905
41238
  case "read_chat":
40906
41239
  return handleReadChat(this, args);
41240
+ case "get_chat_debug_bundle":
41241
+ return handleGetChatDebugBundle(this, args);
40907
41242
  case "chat_history":
40908
41243
  return handleChatHistory(this, args);
40909
41244
  case "send_chat":
@@ -41562,7 +41897,12 @@ ${effect.notification.body || ""}`.trim();
41562
41897
  if (cliCommand?.type === "send_message" && cliCommand.text) {
41563
41898
  await this.adapter.sendMessage(cliCommand.text);
41564
41899
  } else if (cliCommand?.type === "pty_write" && cliCommand.text) {
41900
+ const enterCount = cliCommand.enterCount || 1;
41565
41901
  await this.adapter.writeRaw(cliCommand.text + "\r");
41902
+ for (let i = 1; i < enterCount; i += 1) {
41903
+ await new Promise((resolve12) => setTimeout(resolve12, 50));
41904
+ await this.adapter.writeRaw("\r");
41905
+ }
41566
41906
  }
41567
41907
  this.applyProviderResponse(parsed.payload, { phase: "immediate" });
41568
41908
  }
@@ -42569,7 +42909,8 @@ ${effect.notification.body || ""}`.trim();
42569
42909
  cwd: this.workingDir,
42570
42910
  env,
42571
42911
  stdio: ["pipe", "pipe", "pipe"],
42572
- shell: spawnConfig.shell || false
42912
+ shell: spawnConfig.shell || false,
42913
+ ...process.platform === "win32" ? { windowsHide: true } : {}
42573
42914
  });
42574
42915
  const AUTH_ERROR_PATTERNS = [
42575
42916
  /unauthorized|unauthenticated/i,
@@ -43259,7 +43600,10 @@ ${rawInput}` : rawInput;
43259
43600
  return (0, import_fs5.existsSync)(expandExecutable(trimmed));
43260
43601
  }
43261
43602
  try {
43262
- (0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], { stdio: "ignore" });
43603
+ (0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
43604
+ stdio: "ignore",
43605
+ ...process.platform === "win32" ? { windowsHide: true } : {}
43606
+ });
43263
43607
  return true;
43264
43608
  } catch {
43265
43609
  return false;
@@ -46180,7 +46524,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46180
46524
  const canUseAppLauncher = !!appName;
46181
46525
  const useAppLauncher = preferredMethod === "app" ? canUseAppLauncher : preferredMethod === "cli" ? false : !canUseCli && canUseAppLauncher;
46182
46526
  if (!useAppLauncher && ide.cliCommand) {
46183
- (0, import_child_process7.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore" }).unref();
46527
+ (0, import_child_process7.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
46184
46528
  } else if (appName) {
46185
46529
  const openArgs = ["-a", appName, "--args", ...args];
46186
46530
  (0, import_child_process7.spawn)("open", openArgs, { detached: true, stdio: "ignore" }).unref();
@@ -46209,7 +46553,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46209
46553
  const args = ["--remote-debugging-port=" + port];
46210
46554
  if (newWindow) args.push("--new-window");
46211
46555
  if (workspace) args.push(workspace);
46212
- (0, import_child_process7.spawn)(cli, args, { detached: true, stdio: "ignore" }).unref();
46556
+ (0, import_child_process7.spawn)(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
46213
46557
  }
46214
46558
  function getAvailableIdeIds() {
46215
46559
  return getProviderLoader().getAvailableIdeTypes();
@@ -46683,16 +47027,28 @@ Run 'adhdev doctor' for detailed diagnostics.`
46683
47027
  } catch {
46684
47028
  }
46685
47029
  }
46686
- function resolveSiblingNpmExecutable(nodeExecutable) {
47030
+ function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
46687
47031
  const binDir = path16.dirname(nodeExecutable);
46688
- const candidates = process.platform === "win32" ? ["npm.cmd", "npm.exe", "npm"] : ["npm"];
46689
- for (const candidate of candidates) {
47032
+ if (platform10 === "win32") {
47033
+ const npmCliPath = path16.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
47034
+ if (fs8.existsSync(npmCliPath)) {
47035
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
47036
+ }
47037
+ for (const candidate of ["npm.exe", "npm"]) {
47038
+ const candidatePath = path16.join(binDir, candidate);
47039
+ if (fs8.existsSync(candidatePath)) {
47040
+ return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
47041
+ }
47042
+ }
47043
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
47044
+ }
47045
+ for (const candidate of ["npm"]) {
46690
47046
  const candidatePath = path16.join(binDir, candidate);
46691
47047
  if (fs8.existsSync(candidatePath)) {
46692
- return candidatePath;
47048
+ return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
46693
47049
  }
46694
47050
  }
46695
- return "npm";
47051
+ return { executable: "npm", argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
46696
47052
  }
46697
47053
  function findCurrentPackageRoot(currentCliPath, packageName) {
46698
47054
  if (!currentCliPath) return null;
@@ -46741,31 +47097,50 @@ Run 'adhdev doctor' for detailed diagnostics.`
46741
47097
  }
46742
47098
  function resolveCurrentGlobalInstallSurface(options) {
46743
47099
  const packageRoot = findCurrentPackageRoot(options.currentCliPath || process.argv[1], options.packageName);
47100
+ const npmInvocation = resolveSiblingNpmInvocation(options.nodeExecutable || process.execPath, options.platform);
46744
47101
  return {
46745
- npmExecutable: resolveSiblingNpmExecutable(options.nodeExecutable || process.execPath),
47102
+ npmExecutable: npmInvocation.executable,
47103
+ npmArgsPrefix: npmInvocation.argsPrefix,
46746
47104
  packageRoot,
46747
- installPrefix: packageRoot ? resolveInstallPrefixFromPackageRoot(packageRoot, options.packageName) : null
47105
+ installPrefix: packageRoot ? resolveInstallPrefixFromPackageRoot(packageRoot, options.packageName) : null,
47106
+ execOptions: npmInvocation.execOptions
46748
47107
  };
46749
47108
  }
46750
47109
  function buildPinnedGlobalInstallCommand(options) {
46751
47110
  const surface = resolveCurrentGlobalInstallSurface(options);
46752
- const args = ["install", "-g", `${options.packageName}@${options.targetVersion || "latest"}`, "--force"];
47111
+ const args = [...surface.npmArgsPrefix || [], "install", "-g", `${options.packageName}@${options.targetVersion || "latest"}`, "--force"];
46753
47112
  if (surface.installPrefix) {
46754
47113
  args.push("--prefix", surface.installPrefix);
46755
47114
  }
46756
47115
  return {
46757
47116
  command: surface.npmExecutable,
46758
47117
  args,
46759
- surface
47118
+ surface,
47119
+ execOptions: surface.execOptions || getNpmExecOptions(options.platform)
46760
47120
  };
46761
47121
  }
46762
- function getNpmExecOptions() {
46763
- return { shell: process.platform === "win32" };
47122
+ function getNpmExecOptions(platform10 = process.platform) {
47123
+ if (platform10 === "win32") {
47124
+ return { shell: false, windowsHide: true };
47125
+ }
47126
+ return { shell: false };
47127
+ }
47128
+ function execNpmCommandSync(args, options = {}, surface) {
47129
+ const execOptions = surface?.execOptions || getNpmExecOptions();
47130
+ return (0, import_child_process8.execFileSync)(
47131
+ surface?.npmExecutable || "npm",
47132
+ [...surface?.npmArgsPrefix || [], ...args],
47133
+ {
47134
+ ...options,
47135
+ ...execOptions,
47136
+ ...process.platform === "win32" ? { windowsHide: true } : {}
47137
+ }
47138
+ );
46764
47139
  }
46765
47140
  function killPid2(pid) {
46766
47141
  try {
46767
47142
  if (process.platform === "win32") {
46768
- (0, import_child_process8.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
47143
+ (0, import_child_process8.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
46769
47144
  } else {
46770
47145
  process.kill(pid, "SIGTERM");
46771
47146
  }
@@ -46784,7 +47159,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46784
47159
  "Bypass",
46785
47160
  "-Command",
46786
47161
  `(Get-CimInstance Win32_Process -Filter "${pidFilter}").CommandLine`
46787
- ], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
47162
+ ], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
46788
47163
  if (psOut) return psOut;
46789
47164
  } catch {
46790
47165
  }
@@ -46795,7 +47170,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46795
47170
  pidFilter,
46796
47171
  "get",
46797
47172
  "CommandLine"
46798
- ], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
47173
+ ], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
46799
47174
  if (wmicOut) return wmicOut;
46800
47175
  } catch {
46801
47176
  }
@@ -46855,11 +47230,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
46855
47230
  }
46856
47231
  }
46857
47232
  function cleanupStaleGlobalInstallDirs(pkgName, surface) {
46858
- const npmExecOpts = getNpmExecOptions();
46859
47233
  const prefixArgs = surface.installPrefix ? ["--prefix", surface.installPrefix] : [];
46860
- const npmRoot = (0, import_child_process8.execFileSync)(surface.npmExecutable, ["root", "-g", ...prefixArgs], { encoding: "utf8", ...npmExecOpts }).trim();
47234
+ const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
46861
47235
  if (!npmRoot) return;
46862
- const npmPrefix = surface.installPrefix || (0, import_child_process8.execFileSync)(surface.npmExecutable, ["prefix", "-g", ...prefixArgs], { encoding: "utf8", ...npmExecOpts }).trim();
47236
+ const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
46863
47237
  const binDir = process.platform === "win32" ? npmPrefix : path16.join(npmPrefix, "bin");
46864
47238
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
46865
47239
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
@@ -46929,7 +47303,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46929
47303
  encoding: "utf8",
46930
47304
  stdio: "pipe",
46931
47305
  maxBuffer: 20 * 1024 * 1024,
46932
- ...getNpmExecOptions()
47306
+ ...installCommand.execOptions
46933
47307
  }
46934
47308
  );
46935
47309
  if (installOutput.trim()) {
@@ -47642,18 +48016,18 @@ Run 'adhdev doctor' for detailed diagnostics.`
47642
48016
  case "daemon_upgrade": {
47643
48017
  LOG2.info("Upgrade", "Remote upgrade requested from dashboard");
47644
48018
  try {
47645
- const { execSync: execSync7 } = await import("child_process");
47646
48019
  const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
47647
48020
  const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
47648
- const latest = execSync7(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
48021
+ const npmSurface = resolveCurrentGlobalInstallSurface({ packageName: pkgName });
48022
+ const latest = String(execNpmCommandSync(["view", pkgName, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
47649
48023
  LOG2.info("Upgrade", `Latest ${pkgName}: v${latest}`);
47650
48024
  let currentInstalled = null;
47651
48025
  try {
47652
- const currentJson = execSync7(`npm ls -g ${pkgName} --depth=0 --json`, {
48026
+ const currentJson = String(execNpmCommandSync(["ls", "-g", pkgName, "--depth=0", "--json"], {
47653
48027
  encoding: "utf-8",
47654
48028
  timeout: 1e4,
47655
48029
  stdio: ["pipe", "pipe", "pipe"]
47656
- }).trim();
48030
+ }, npmSurface)).trim();
47657
48031
  const parsed = JSON.parse(currentJson);
47658
48032
  currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
47659
48033
  } catch {