adhdev 0.9.48 → 0.9.50

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,241 @@ 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 targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
7713
+ if (!targetSessionId && !h.currentSession) {
7714
+ return { success: false, error: "No targetSessionId specified \u2014 cannot route command" };
7715
+ }
7716
+ const provider = h.getProvider(args?.agentType);
7717
+ const transport = getTargetTransport(h, provider);
7718
+ const providerType = provider?.type || getCurrentProviderType(h, args?.agentType || "");
7719
+ const adapter = isCliLikeTransport(transport) ? getTargetedCliAdapter(h, args, provider?.type) : null;
7720
+ const targetInstance = getTargetInstance(h, args);
7721
+ let adapterStatus = null;
7722
+ let parsedStatus = null;
7723
+ let adapterDebugSnapshot = null;
7724
+ let partialResponse = "";
7725
+ if (adapter) {
7726
+ try {
7727
+ adapterStatus = adapter.getStatus?.();
7728
+ } catch (error48) {
7729
+ adapterStatus = { error: error48?.message || String(error48) };
7730
+ }
7731
+ try {
7732
+ parsedStatus = typeof adapter.getScriptParsedStatus === "function" ? parseMaybeJson(adapter.getScriptParsedStatus()) : null;
7733
+ } catch (error48) {
7734
+ parsedStatus = { error: error48?.message || String(error48) };
7735
+ }
7736
+ try {
7737
+ adapterDebugSnapshot = typeof adapter.getDebugSnapshot === "function" ? adapter.getDebugSnapshot() : null;
7738
+ } catch (error48) {
7739
+ adapterDebugSnapshot = { error: error48?.message || String(error48) };
7740
+ }
7741
+ try {
7742
+ partialResponse = adapter.getPartialResponse?.() || "";
7743
+ } catch {
7744
+ partialResponse = "";
7745
+ }
7746
+ }
7747
+ let instanceState = null;
7748
+ if (targetInstance?.getState) {
7749
+ try {
7750
+ instanceState = summarizeStateForDebug(targetInstance.getState());
7751
+ } catch (error48) {
7752
+ instanceState = { error: error48?.message || String(error48) };
7753
+ }
7754
+ }
7755
+ let readChat = null;
7756
+ try {
7757
+ const readResult = await handleReadChat(h, { ...args, tailLimit: Math.max(1, Math.min(40, Number(args?.tailLimit || 40))) });
7758
+ readChat = readResult.success ? {
7759
+ success: true,
7760
+ status: readResult.status,
7761
+ title: readResult.title,
7762
+ totalMessages: readResult.totalMessages,
7763
+ returnedMessages: Array.isArray(readResult.messages) ? readResult.messages.length : void 0,
7764
+ syncMode: readResult.syncMode,
7765
+ replaceFrom: readResult.replaceFrom,
7766
+ lastMessageSignature: readResult.lastMessageSignature,
7767
+ providerSessionId: readResult.providerSessionId,
7768
+ transcriptAuthority: readResult.transcriptAuthority,
7769
+ coverage: readResult.coverage,
7770
+ activeModal: readResult.activeModal,
7771
+ messagesTail: Array.isArray(readResult.messages) ? readResult.messages.slice(-20) : [],
7772
+ debugReadChat: readResult.debugReadChat
7773
+ } : { success: false, error: readResult.error };
7774
+ } catch (error48) {
7775
+ readChat = { success: false, error: error48?.message || String(error48) };
7776
+ }
7777
+ const cdp = h.getCdp();
7778
+ const rawBundle = {
7779
+ version: 1,
7780
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
7781
+ target: {
7782
+ targetSessionId,
7783
+ providerType,
7784
+ transport,
7785
+ routeManagerKey: h.currentManagerKey,
7786
+ currentIdeType: h.currentIdeType
7787
+ },
7788
+ session: summarizeSessionForDebug(h.currentSession),
7789
+ provider: summarizeProviderForDebug(provider),
7790
+ daemon: {
7791
+ pid: process.pid,
7792
+ platform: process.platform,
7793
+ nodeVersion: process.version,
7794
+ cwd: process.cwd()
7795
+ },
7796
+ cdp: {
7797
+ requested: !!cdp,
7798
+ connected: !!cdp?.isConnected,
7799
+ managerKey: getCurrentManagerKey(h)
7800
+ },
7801
+ instanceState,
7802
+ cli: adapter ? {
7803
+ cliType: adapter.cliType,
7804
+ cliName: adapter.cliName,
7805
+ workingDir: adapter.workingDir,
7806
+ status: adapterStatus?.status,
7807
+ activeModal: adapterStatus?.activeModal,
7808
+ messageCount: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.length : void 0,
7809
+ messagesTail: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.slice(-20) : void 0,
7810
+ parsedStatus,
7811
+ partialResponse,
7812
+ ready: typeof adapter.isReady === "function" ? adapter.isReady() : void 0,
7813
+ processing: typeof adapter.isProcessing === "function" ? adapter.isProcessing() : void 0,
7814
+ debugSnapshot: adapterDebugSnapshot
7815
+ } : null,
7816
+ readChat,
7817
+ frontend: args?.frontendSnapshot && typeof args.frontendSnapshot === "object" ? args.frontendSnapshot : null,
7818
+ recentLogs: getRecentLogs(80, "debug"),
7819
+ recentDebugTrace: getRecentDebugTrace({ limit: 120 })
7820
+ };
7821
+ const bundle = sanitizeDebugBundleValue(rawBundle);
7822
+ return {
7823
+ success: true,
7824
+ bundle,
7825
+ text: buildDebugBundleText(bundle)
7826
+ };
7827
+ }
7589
7828
  function didProviderConfirmSend(result) {
7590
7829
  const parsed = parseMaybeJson(result);
7591
7830
  if (parsed === true) return true;
@@ -8559,7 +8798,7 @@ async function handleResolveAction(h, args) {
8559
8798
  }
8560
8799
  return { success: false, error: "resolveAction script not available for this provider" };
8561
8800
  }
8562
- var RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget;
8801
+ var RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN;
8563
8802
  var init_chat_commands = __esm({
8564
8803
  "../../oss/packages/daemon-core/src/commands/chat-commands.ts"() {
8565
8804
  "use strict";
@@ -8574,6 +8813,13 @@ var init_chat_commands = __esm({
8574
8813
  RECENT_SEND_WINDOW_MS = 1200;
8575
8814
  READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
8576
8815
  recentSendByTarget = /* @__PURE__ */ new Map();
8816
+ DEFAULT_DEBUG_SANITIZE_OPTIONS = {
8817
+ maxDepth: 8,
8818
+ maxArrayLength: 80,
8819
+ maxObjectKeys: 120,
8820
+ maxStringLength: 16e3
8821
+ };
8822
+ SECRET_KEY_PATTERN = /(?:token|secret|password|passwd|authorization|cookie|api[_-]?key|access[_-]?key|refresh[_-]?token|client[_-]?secret|private[_-]?key)/i;
8577
8823
  }
8578
8824
  });
8579
8825
 
@@ -9794,6 +10040,7 @@ var init_handler = __esm({
9794
10040
  this.logCommandStart(cmd, args);
9795
10041
  const sessionScopedCommands = /* @__PURE__ */ new Set([
9796
10042
  "read_chat",
10043
+ "get_chat_debug_bundle",
9797
10044
  "send_chat",
9798
10045
  "list_chats",
9799
10046
  "new_chat",
@@ -9841,6 +10088,8 @@ var init_handler = __esm({
9841
10088
  // ─── Chat commands (chat-commands.ts) ───────────────
9842
10089
  case "read_chat":
9843
10090
  return handleReadChat(this, args);
10091
+ case "get_chat_debug_bundle":
10092
+ return handleGetChatDebugBundle(this, args);
9844
10093
  case "chat_history":
9845
10094
  return handleChatHistory(this, args);
9846
10095
  case "send_chat":
@@ -11193,7 +11442,12 @@ function findBinary(name) {
11193
11442
  const isWin = os10.platform() === "win32";
11194
11443
  try {
11195
11444
  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();
11445
+ return (0, import_child_process4.execSync)(cmd, {
11446
+ encoding: "utf-8",
11447
+ timeout: 5e3,
11448
+ stdio: ["pipe", "pipe", "pipe"],
11449
+ ...isWin ? { windowsHide: true } : {}
11450
+ }).trim().split("\n")[0].trim();
11197
11451
  } catch {
11198
11452
  return isWin ? `${trimmed}.cmd` : trimmed;
11199
11453
  }
@@ -13878,6 +14132,83 @@ var init_provider_cli_adapter = __esm({
13878
14132
  if (!this.isWaitingForResponse) return "";
13879
14133
  return this.responseBuffer;
13880
14134
  }
14135
+ getDebugSnapshot() {
14136
+ const screenText = this.readTerminalScreenText();
14137
+ const parsedResult = this.parsedStatusCache?.result && typeof this.parsedStatusCache.result === "object" ? this.parsedStatusCache.result : null;
14138
+ return {
14139
+ cliType: this.cliType,
14140
+ cliName: this.cliName,
14141
+ workingDir: this.workingDir,
14142
+ currentStatus: this.currentStatus,
14143
+ ready: this.ready,
14144
+ isWaitingForResponse: this.isWaitingForResponse,
14145
+ activeModal: this.activeModal,
14146
+ parseErrorMessage: this.parseErrorMessage,
14147
+ messageCounts: {
14148
+ committed: this.committedMessages.length,
14149
+ structured: this.structuredMessages.length,
14150
+ visible: this.messages.length,
14151
+ parsedCache: Array.isArray(parsedResult?.messages) ? parsedResult.messages.length : void 0
14152
+ },
14153
+ buffers: {
14154
+ accumulatedLength: this.accumulatedBuffer.length,
14155
+ accumulatedRawLength: this.accumulatedRawBuffer.length,
14156
+ recentOutputLength: this.recentOutputBuffer.length,
14157
+ responseLength: this.responseBuffer.length,
14158
+ startupLength: this.startupBuffer.length,
14159
+ accumulatedTail: this.accumulatedBuffer.slice(-24e3),
14160
+ accumulatedRawTail: this.accumulatedRawBuffer.slice(-24e3),
14161
+ recentOutputTail: this.recentOutputBuffer.slice(-12e3),
14162
+ responseTail: this.responseBuffer.slice(-12e3)
14163
+ },
14164
+ terminal: {
14165
+ screenText,
14166
+ lastScreenSnapshot: this.lastScreenSnapshot,
14167
+ lastScreenText: this.lastScreenText,
14168
+ lastOutputAt: this.lastOutputAt,
14169
+ lastNonEmptyOutputAt: this.lastNonEmptyOutputAt,
14170
+ lastScreenChangeAt: this.lastScreenChangeAt,
14171
+ lastScreenSnapshotReadAt: this.lastScreenSnapshotReadAt
14172
+ },
14173
+ parser: {
14174
+ scriptNames: listCliScriptNames(this.cliScripts),
14175
+ traceSessionId: this.traceSessionId,
14176
+ traceSeq: this.traceSeq,
14177
+ currentTurnScope: this.currentTurnScope,
14178
+ parsedStatusCache: parsedResult ? {
14179
+ id: parsedResult.id,
14180
+ status: parsedResult.status,
14181
+ title: parsedResult.title,
14182
+ providerSessionId: parsedResult.providerSessionId,
14183
+ transcriptAuthority: parsedResult.transcriptAuthority,
14184
+ coverage: parsedResult.coverage,
14185
+ messageCount: Array.isArray(parsedResult.messages) ? parsedResult.messages.length : void 0,
14186
+ activeModal: parsedResult.activeModal
14187
+ } : null,
14188
+ pendingScriptStatus: this.pendingScriptStatus,
14189
+ pendingScriptStatusSince: this.pendingScriptStatusSince
14190
+ },
14191
+ runtimeMetadata: this.getRuntimeMetadata(),
14192
+ statusHistory: this.statusHistory.slice(-80),
14193
+ traceEntries: this.traceEntries.slice(-120),
14194
+ timing: {
14195
+ spawnAt: this.spawnAt,
14196
+ startupFirstOutputAt: this.startupFirstOutputAt,
14197
+ submitPendingUntil: this.submitPendingUntil,
14198
+ responseSettleIgnoreUntil: this.responseSettleIgnoreUntil,
14199
+ responseEpoch: this.responseEpoch,
14200
+ resizeSuppressUntil: this.resizeSuppressUntil,
14201
+ lastApprovalResolvedAt: this.lastApprovalResolvedAt,
14202
+ committedMessagesChangedAt: this.committedMessagesChangedAt
14203
+ },
14204
+ finish: {
14205
+ idleFinishCandidate: this.idleFinishCandidate,
14206
+ finishRetryCount: this.finishRetryCount,
14207
+ submitRetryUsed: this.submitRetryUsed,
14208
+ submitRetryPromptSnippet: this.submitRetryPromptSnippet
14209
+ }
14210
+ };
14211
+ }
13881
14212
  getRuntimeMetadata() {
13882
14213
  if (!this.ptyProcess || typeof this.ptyProcess.getMetadata !== "function") return null;
13883
14214
  return this.ptyProcess.getMetadata();
@@ -31954,7 +32285,8 @@ var init_acp_provider_instance = __esm({
31954
32285
  cwd: this.workingDir,
31955
32286
  env: env3,
31956
32287
  stdio: ["pipe", "pipe", "pipe"],
31957
- shell: spawnConfig.shell || false
32288
+ shell: spawnConfig.shell || false,
32289
+ ...process.platform === "win32" ? { windowsHide: true } : {}
31958
32290
  });
31959
32291
  const AUTH_ERROR_PATTERNS = [
31960
32292
  /unauthorized|unauthenticated/i,
@@ -32653,7 +32985,10 @@ function commandExists(command) {
32653
32985
  return (0, import_fs5.existsSync)(expandExecutable(trimmed));
32654
32986
  }
32655
32987
  try {
32656
- (0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], { stdio: "ignore" });
32988
+ (0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
32989
+ stdio: "ignore",
32990
+ ...process.platform === "win32" ? { windowsHide: true } : {}
32991
+ });
32657
32992
  return true;
32658
32993
  } catch {
32659
32994
  return false;
@@ -37372,7 +37707,7 @@ async function launchMacOS(ide, port, workspace, newWindow) {
37372
37707
  const canUseAppLauncher = !!appName;
37373
37708
  const useAppLauncher = preferredMethod === "app" ? canUseAppLauncher : preferredMethod === "cli" ? false : !canUseCli && canUseAppLauncher;
37374
37709
  if (!useAppLauncher && ide.cliCommand) {
37375
- (0, import_child_process7.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore" }).unref();
37710
+ (0, import_child_process7.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
37376
37711
  } else if (appName) {
37377
37712
  const openArgs = ["-a", appName, "--args", ...args];
37378
37713
  (0, import_child_process7.spawn)("open", openArgs, { detached: true, stdio: "ignore" }).unref();
@@ -37401,7 +37736,7 @@ async function launchLinux(ide, port, workspace, newWindow) {
37401
37736
  const args = ["--remote-debugging-port=" + port];
37402
37737
  if (newWindow) args.push("--new-window");
37403
37738
  if (workspace) args.push(workspace);
37404
- (0, import_child_process7.spawn)(cli, args, { detached: true, stdio: "ignore" }).unref();
37739
+ (0, import_child_process7.spawn)(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
37405
37740
  }
37406
37741
  function getAvailableIdeIds() {
37407
37742
  return getProviderLoader().getAvailableIdeTypes();
@@ -37910,23 +38245,23 @@ function resolveSiblingNpmInvocation(nodeExecutable, platform12 = process.platfo
37910
38245
  if (platform12 === "win32") {
37911
38246
  const npmCliPath = path16.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
37912
38247
  if (fs8.existsSync(npmCliPath)) {
37913
- return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: { shell: false } };
38248
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
37914
38249
  }
37915
38250
  for (const candidate of ["npm.exe", "npm"]) {
37916
38251
  const candidatePath = path16.join(binDir, candidate);
37917
38252
  if (fs8.existsSync(candidatePath)) {
37918
- return { executable: candidatePath, argsPrefix: [], execOptions: { shell: false } };
38253
+ return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
37919
38254
  }
37920
38255
  }
37921
- return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: { shell: false } };
38256
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
37922
38257
  }
37923
38258
  for (const candidate of ["npm"]) {
37924
38259
  const candidatePath = path16.join(binDir, candidate);
37925
38260
  if (fs8.existsSync(candidatePath)) {
37926
- return { executable: candidatePath, argsPrefix: [], execOptions: { shell: false } };
38261
+ return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
37927
38262
  }
37928
38263
  }
37929
- return { executable: "npm", argsPrefix: [], execOptions: { shell: false } };
38264
+ return { executable: "npm", argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
37930
38265
  }
37931
38266
  function findCurrentPackageRoot(currentCliPath, packageName) {
37932
38267
  if (!currentCliPath) return null;
@@ -37997,13 +38332,28 @@ function buildPinnedGlobalInstallCommand(options) {
37997
38332
  execOptions: surface.execOptions || getNpmExecOptions(options.platform)
37998
38333
  };
37999
38334
  }
38000
- function getNpmExecOptions(_platform = process.platform) {
38335
+ function getNpmExecOptions(platform12 = process.platform) {
38336
+ if (platform12 === "win32") {
38337
+ return { shell: false, windowsHide: true };
38338
+ }
38001
38339
  return { shell: false };
38002
38340
  }
38341
+ function execNpmCommandSync(args, options = {}, surface) {
38342
+ const execOptions = surface?.execOptions || getNpmExecOptions();
38343
+ return (0, import_child_process8.execFileSync)(
38344
+ surface?.npmExecutable || "npm",
38345
+ [...surface?.npmArgsPrefix || [], ...args],
38346
+ {
38347
+ ...options,
38348
+ ...execOptions,
38349
+ ...process.platform === "win32" ? { windowsHide: true } : {}
38350
+ }
38351
+ );
38352
+ }
38003
38353
  function killPid(pid) {
38004
38354
  try {
38005
38355
  if (process.platform === "win32") {
38006
- (0, import_child_process8.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
38356
+ (0, import_child_process8.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
38007
38357
  } else {
38008
38358
  process.kill(pid, "SIGTERM");
38009
38359
  }
@@ -38022,7 +38372,7 @@ function getWindowsProcessCommandLine(pid) {
38022
38372
  "Bypass",
38023
38373
  "-Command",
38024
38374
  `(Get-CimInstance Win32_Process -Filter "${pidFilter}").CommandLine`
38025
- ], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
38375
+ ], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
38026
38376
  if (psOut) return psOut;
38027
38377
  } catch {
38028
38378
  }
@@ -38033,7 +38383,7 @@ function getWindowsProcessCommandLine(pid) {
38033
38383
  pidFilter,
38034
38384
  "get",
38035
38385
  "CommandLine"
38036
- ], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
38386
+ ], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
38037
38387
  if (wmicOut) return wmicOut;
38038
38388
  } catch {
38039
38389
  }
@@ -38094,9 +38444,9 @@ function removeDaemonPidFile() {
38094
38444
  }
38095
38445
  function cleanupStaleGlobalInstallDirs(pkgName, surface) {
38096
38446
  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();
38447
+ const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
38098
38448
  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();
38449
+ const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
38100
38450
  const binDir = process.platform === "win32" ? npmPrefix : path16.join(npmPrefix, "bin");
38101
38451
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
38102
38452
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
@@ -38624,6 +38974,8 @@ var init_router = __esm({
38624
38974
  const wantsAll = args?.all === true;
38625
38975
  const offset = wantsAll ? 0 : Math.max(0, Number(args?.offset) || 0);
38626
38976
  const limit = wantsAll ? Number.MAX_SAFE_INTEGER : Math.max(1, Math.min(100, Number(args?.limit) || 30));
38977
+ const requestedWorkspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
38978
+ const requestedProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : typeof args?.activeProviderSessionId === "string" ? args.activeProviderSessionId.trim() : "";
38627
38979
  const providerMeta = this.deps.providerLoader.resolve?.(providerType) || this.deps.providerLoader.getMeta(providerType);
38628
38980
  const { sessions: historySessions, hasMore, source } = listProviderHistorySessions(providerType, {
38629
38981
  canonicalHistory: providerMeta?.canonicalHistory,
@@ -38643,6 +38995,7 @@ var init_router = __esm({
38643
38995
  sessions: historySessions.map((session) => {
38644
38996
  const saved = savedSessionById.get(session.historySessionId);
38645
38997
  const recent = recentSessionById.get(session.historySessionId);
38998
+ const workspace = saved?.workspace || recent?.workspace || session.workspace || (requestedWorkspace && requestedProviderSessionId === session.historySessionId ? requestedWorkspace : void 0);
38646
38999
  return {
38647
39000
  id: session.historySessionId,
38648
39001
  providerSessionId: session.historySessionId,
@@ -38650,13 +39003,13 @@ var init_router = __esm({
38650
39003
  providerName: saved?.providerName || recent?.providerName || providerType,
38651
39004
  kind: saved?.kind || recent?.kind || kind,
38652
39005
  title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
38653
- workspace: saved?.workspace || recent?.workspace || session.workspace,
39006
+ workspace,
38654
39007
  summaryMetadata: saved?.summaryMetadata || recent?.summaryMetadata,
38655
39008
  preview: session.preview,
38656
39009
  messageCount: session.messageCount,
38657
39010
  firstMessageAt: session.firstMessageAt,
38658
39011
  lastMessageAt: session.lastMessageAt,
38659
- canResume: !!(saved?.workspace || recent?.workspace || session.workspace) && canResumeById,
39012
+ canResume: !!workspace && canResumeById,
38660
39013
  historySource: session.source,
38661
39014
  sourcePath: session.sourcePath,
38662
39015
  sourceMtimeMs: session.sourceMtimeMs
@@ -38918,18 +39271,18 @@ var init_router = __esm({
38918
39271
  case "daemon_upgrade": {
38919
39272
  LOG.info("Upgrade", "Remote upgrade requested from dashboard");
38920
39273
  try {
38921
- const { execSync: execSync7 } = await import("child_process");
38922
39274
  const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
38923
39275
  const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
38924
- const latest = execSync7(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
39276
+ const npmSurface = resolveCurrentGlobalInstallSurface({ packageName: pkgName });
39277
+ const latest = String(execNpmCommandSync(["view", pkgName, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
38925
39278
  LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
38926
39279
  let currentInstalled = null;
38927
39280
  try {
38928
- const currentJson = execSync7(`npm ls -g ${pkgName} --depth=0 --json`, {
39281
+ const currentJson = String(execNpmCommandSync(["ls", "-g", pkgName, "--depth=0", "--json"], {
38929
39282
  encoding: "utf-8",
38930
39283
  timeout: 1e4,
38931
39284
  stdio: ["pipe", "pipe", "pipe"]
38932
- }).trim();
39285
+ }, npmSurface)).trim();
38933
39286
  const parsed = JSON.parse(currentJson);
38934
39287
  currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
38935
39288
  } catch {
@@ -47178,6 +47531,7 @@ __export(src_exports, {
47178
47531
  detectCLIs: () => detectCLIs,
47179
47532
  detectIDEs: () => detectIDEs,
47180
47533
  ensureSessionHostReady: () => ensureSessionHostReady,
47534
+ execNpmCommandSync: () => execNpmCommandSync,
47181
47535
  findCdpManager: () => findCdpManager,
47182
47536
  flattenMessageParts: () => flattenMessageParts,
47183
47537
  forwardAgentStreamsToIdeInstance: () => forwardAgentStreamsToIdeInstance,
@@ -47188,6 +47542,7 @@ __export(src_exports, {
47188
47542
  getDebugRuntimeConfig: () => getDebugRuntimeConfig,
47189
47543
  getHostMemorySnapshot: () => getHostMemorySnapshot,
47190
47544
  getLogLevel: () => getLogLevel,
47545
+ getNpmExecOptions: () => getNpmExecOptions,
47191
47546
  getRecentActivity: () => getRecentActivity,
47192
47547
  getRecentCommands: () => getRecentCommands,
47193
47548
  getRecentDebugTrace: () => getRecentDebugTrace,
@@ -56943,7 +57298,7 @@ var init_adhdev_daemon = __esm({
56943
57298
  init_version();
56944
57299
  init_src();
56945
57300
  init_runtime_defaults();
56946
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.48" });
57301
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.50" });
56947
57302
  AdhdevDaemon = class _AdhdevDaemon {
56948
57303
  localHttpServer = null;
56949
57304
  localWss = null;