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/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,241 @@ 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 targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
8233
+ if (!targetSessionId && !h.currentSession) {
8234
+ return { success: false, error: "No targetSessionId specified \u2014 cannot route command" };
8235
+ }
8236
+ const provider = h.getProvider(args?.agentType);
8237
+ const transport = getTargetTransport(h, provider);
8238
+ const providerType = provider?.type || getCurrentProviderType(h, args?.agentType || "");
8239
+ const adapter = isCliLikeTransport(transport) ? getTargetedCliAdapter(h, args, provider?.type) : null;
8240
+ const targetInstance = getTargetInstance(h, args);
8241
+ let adapterStatus = null;
8242
+ let parsedStatus = null;
8243
+ let adapterDebugSnapshot = null;
8244
+ let partialResponse = "";
8245
+ if (adapter) {
8246
+ try {
8247
+ adapterStatus = adapter.getStatus?.();
8248
+ } catch (error48) {
8249
+ adapterStatus = { error: error48?.message || String(error48) };
8250
+ }
8251
+ try {
8252
+ parsedStatus = typeof adapter.getScriptParsedStatus === "function" ? parseMaybeJson(adapter.getScriptParsedStatus()) : null;
8253
+ } catch (error48) {
8254
+ parsedStatus = { error: error48?.message || String(error48) };
8255
+ }
8256
+ try {
8257
+ adapterDebugSnapshot = typeof adapter.getDebugSnapshot === "function" ? adapter.getDebugSnapshot() : null;
8258
+ } catch (error48) {
8259
+ adapterDebugSnapshot = { error: error48?.message || String(error48) };
8260
+ }
8261
+ try {
8262
+ partialResponse = adapter.getPartialResponse?.() || "";
8263
+ } catch {
8264
+ partialResponse = "";
8265
+ }
8266
+ }
8267
+ let instanceState = null;
8268
+ if (targetInstance?.getState) {
8269
+ try {
8270
+ instanceState = summarizeStateForDebug(targetInstance.getState());
8271
+ } catch (error48) {
8272
+ instanceState = { error: error48?.message || String(error48) };
8273
+ }
8274
+ }
8275
+ let readChat = null;
8276
+ try {
8277
+ const readResult = await handleReadChat(h, { ...args, tailLimit: Math.max(1, Math.min(40, Number(args?.tailLimit || 40))) });
8278
+ readChat = readResult.success ? {
8279
+ success: true,
8280
+ status: readResult.status,
8281
+ title: readResult.title,
8282
+ totalMessages: readResult.totalMessages,
8283
+ returnedMessages: Array.isArray(readResult.messages) ? readResult.messages.length : void 0,
8284
+ syncMode: readResult.syncMode,
8285
+ replaceFrom: readResult.replaceFrom,
8286
+ lastMessageSignature: readResult.lastMessageSignature,
8287
+ providerSessionId: readResult.providerSessionId,
8288
+ transcriptAuthority: readResult.transcriptAuthority,
8289
+ coverage: readResult.coverage,
8290
+ activeModal: readResult.activeModal,
8291
+ messagesTail: Array.isArray(readResult.messages) ? readResult.messages.slice(-20) : [],
8292
+ debugReadChat: readResult.debugReadChat
8293
+ } : { success: false, error: readResult.error };
8294
+ } catch (error48) {
8295
+ readChat = { success: false, error: error48?.message || String(error48) };
8296
+ }
8297
+ const cdp = h.getCdp();
8298
+ const rawBundle = {
8299
+ version: 1,
8300
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
8301
+ target: {
8302
+ targetSessionId,
8303
+ providerType,
8304
+ transport,
8305
+ routeManagerKey: h.currentManagerKey,
8306
+ currentIdeType: h.currentIdeType
8307
+ },
8308
+ session: summarizeSessionForDebug(h.currentSession),
8309
+ provider: summarizeProviderForDebug(provider),
8310
+ daemon: {
8311
+ pid: process.pid,
8312
+ platform: process.platform,
8313
+ nodeVersion: process.version,
8314
+ cwd: process.cwd()
8315
+ },
8316
+ cdp: {
8317
+ requested: !!cdp,
8318
+ connected: !!cdp?.isConnected,
8319
+ managerKey: getCurrentManagerKey(h)
8320
+ },
8321
+ instanceState,
8322
+ cli: adapter ? {
8323
+ cliType: adapter.cliType,
8324
+ cliName: adapter.cliName,
8325
+ workingDir: adapter.workingDir,
8326
+ status: adapterStatus?.status,
8327
+ activeModal: adapterStatus?.activeModal,
8328
+ messageCount: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.length : void 0,
8329
+ messagesTail: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.slice(-20) : void 0,
8330
+ parsedStatus,
8331
+ partialResponse,
8332
+ ready: typeof adapter.isReady === "function" ? adapter.isReady() : void 0,
8333
+ processing: typeof adapter.isProcessing === "function" ? adapter.isProcessing() : void 0,
8334
+ debugSnapshot: adapterDebugSnapshot
8335
+ } : null,
8336
+ readChat,
8337
+ frontend: args?.frontendSnapshot && typeof args.frontendSnapshot === "object" ? args.frontendSnapshot : null,
8338
+ recentLogs: getRecentLogs(80, "debug"),
8339
+ recentDebugTrace: getRecentDebugTrace({ limit: 120 })
8340
+ };
8341
+ const bundle = sanitizeDebugBundleValue(rawBundle);
8342
+ return {
8343
+ success: true,
8344
+ bundle,
8345
+ text: buildDebugBundleText(bundle)
8346
+ };
8347
+ }
8109
8348
  function didProviderConfirmSend(result) {
8110
8349
  const parsed = parseMaybeJson(result);
8111
8350
  if (parsed === true) return true;
@@ -9079,7 +9318,7 @@ async function handleResolveAction(h, args) {
9079
9318
  }
9080
9319
  return { success: false, error: "resolveAction script not available for this provider" };
9081
9320
  }
9082
- var RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget;
9321
+ var RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN;
9083
9322
  var init_chat_commands = __esm({
9084
9323
  "../../oss/packages/daemon-core/src/commands/chat-commands.ts"() {
9085
9324
  "use strict";
@@ -9094,6 +9333,13 @@ var init_chat_commands = __esm({
9094
9333
  RECENT_SEND_WINDOW_MS = 1200;
9095
9334
  READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
9096
9335
  recentSendByTarget = /* @__PURE__ */ new Map();
9336
+ DEFAULT_DEBUG_SANITIZE_OPTIONS = {
9337
+ maxDepth: 8,
9338
+ maxArrayLength: 80,
9339
+ maxObjectKeys: 120,
9340
+ maxStringLength: 16e3
9341
+ };
9342
+ SECRET_KEY_PATTERN = /(?:token|secret|password|passwd|authorization|cookie|api[_-]?key|access[_-]?key|refresh[_-]?token|client[_-]?secret|private[_-]?key)/i;
9097
9343
  }
9098
9344
  });
9099
9345
 
@@ -10314,6 +10560,7 @@ var init_handler = __esm({
10314
10560
  this.logCommandStart(cmd, args);
10315
10561
  const sessionScopedCommands = /* @__PURE__ */ new Set([
10316
10562
  "read_chat",
10563
+ "get_chat_debug_bundle",
10317
10564
  "send_chat",
10318
10565
  "list_chats",
10319
10566
  "new_chat",
@@ -10361,6 +10608,8 @@ var init_handler = __esm({
10361
10608
  // ─── Chat commands (chat-commands.ts) ───────────────
10362
10609
  case "read_chat":
10363
10610
  return handleReadChat(this, args);
10611
+ case "get_chat_debug_bundle":
10612
+ return handleGetChatDebugBundle(this, args);
10364
10613
  case "chat_history":
10365
10614
  return handleChatHistory(this, args);
10366
10615
  case "send_chat":
@@ -12150,7 +12399,12 @@ function findBinary(name) {
12150
12399
  const isWin = os11.platform() === "win32";
12151
12400
  try {
12152
12401
  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();
12402
+ return (0, import_child_process4.execSync)(cmd, {
12403
+ encoding: "utf-8",
12404
+ timeout: 5e3,
12405
+ stdio: ["pipe", "pipe", "pipe"],
12406
+ ...isWin ? { windowsHide: true } : {}
12407
+ }).trim().split("\n")[0].trim();
12154
12408
  } catch {
12155
12409
  return isWin ? `${trimmed}.cmd` : trimmed;
12156
12410
  }
@@ -14835,6 +15089,83 @@ var init_provider_cli_adapter = __esm({
14835
15089
  if (!this.isWaitingForResponse) return "";
14836
15090
  return this.responseBuffer;
14837
15091
  }
15092
+ getDebugSnapshot() {
15093
+ const screenText = this.readTerminalScreenText();
15094
+ const parsedResult = this.parsedStatusCache?.result && typeof this.parsedStatusCache.result === "object" ? this.parsedStatusCache.result : null;
15095
+ return {
15096
+ cliType: this.cliType,
15097
+ cliName: this.cliName,
15098
+ workingDir: this.workingDir,
15099
+ currentStatus: this.currentStatus,
15100
+ ready: this.ready,
15101
+ isWaitingForResponse: this.isWaitingForResponse,
15102
+ activeModal: this.activeModal,
15103
+ parseErrorMessage: this.parseErrorMessage,
15104
+ messageCounts: {
15105
+ committed: this.committedMessages.length,
15106
+ structured: this.structuredMessages.length,
15107
+ visible: this.messages.length,
15108
+ parsedCache: Array.isArray(parsedResult?.messages) ? parsedResult.messages.length : void 0
15109
+ },
15110
+ buffers: {
15111
+ accumulatedLength: this.accumulatedBuffer.length,
15112
+ accumulatedRawLength: this.accumulatedRawBuffer.length,
15113
+ recentOutputLength: this.recentOutputBuffer.length,
15114
+ responseLength: this.responseBuffer.length,
15115
+ startupLength: this.startupBuffer.length,
15116
+ accumulatedTail: this.accumulatedBuffer.slice(-24e3),
15117
+ accumulatedRawTail: this.accumulatedRawBuffer.slice(-24e3),
15118
+ recentOutputTail: this.recentOutputBuffer.slice(-12e3),
15119
+ responseTail: this.responseBuffer.slice(-12e3)
15120
+ },
15121
+ terminal: {
15122
+ screenText,
15123
+ lastScreenSnapshot: this.lastScreenSnapshot,
15124
+ lastScreenText: this.lastScreenText,
15125
+ lastOutputAt: this.lastOutputAt,
15126
+ lastNonEmptyOutputAt: this.lastNonEmptyOutputAt,
15127
+ lastScreenChangeAt: this.lastScreenChangeAt,
15128
+ lastScreenSnapshotReadAt: this.lastScreenSnapshotReadAt
15129
+ },
15130
+ parser: {
15131
+ scriptNames: listCliScriptNames(this.cliScripts),
15132
+ traceSessionId: this.traceSessionId,
15133
+ traceSeq: this.traceSeq,
15134
+ currentTurnScope: this.currentTurnScope,
15135
+ parsedStatusCache: parsedResult ? {
15136
+ id: parsedResult.id,
15137
+ status: parsedResult.status,
15138
+ title: parsedResult.title,
15139
+ providerSessionId: parsedResult.providerSessionId,
15140
+ transcriptAuthority: parsedResult.transcriptAuthority,
15141
+ coverage: parsedResult.coverage,
15142
+ messageCount: Array.isArray(parsedResult.messages) ? parsedResult.messages.length : void 0,
15143
+ activeModal: parsedResult.activeModal
15144
+ } : null,
15145
+ pendingScriptStatus: this.pendingScriptStatus,
15146
+ pendingScriptStatusSince: this.pendingScriptStatusSince
15147
+ },
15148
+ runtimeMetadata: this.getRuntimeMetadata(),
15149
+ statusHistory: this.statusHistory.slice(-80),
15150
+ traceEntries: this.traceEntries.slice(-120),
15151
+ timing: {
15152
+ spawnAt: this.spawnAt,
15153
+ startupFirstOutputAt: this.startupFirstOutputAt,
15154
+ submitPendingUntil: this.submitPendingUntil,
15155
+ responseSettleIgnoreUntil: this.responseSettleIgnoreUntil,
15156
+ responseEpoch: this.responseEpoch,
15157
+ resizeSuppressUntil: this.resizeSuppressUntil,
15158
+ lastApprovalResolvedAt: this.lastApprovalResolvedAt,
15159
+ committedMessagesChangedAt: this.committedMessagesChangedAt
15160
+ },
15161
+ finish: {
15162
+ idleFinishCandidate: this.idleFinishCandidate,
15163
+ finishRetryCount: this.finishRetryCount,
15164
+ submitRetryUsed: this.submitRetryUsed,
15165
+ submitRetryPromptSnippet: this.submitRetryPromptSnippet
15166
+ }
15167
+ };
15168
+ }
14838
15169
  getRuntimeMetadata() {
14839
15170
  if (!this.ptyProcess || typeof this.ptyProcess.getMetadata !== "function") return null;
14840
15171
  return this.ptyProcess.getMetadata();
@@ -32911,7 +33242,8 @@ var init_acp_provider_instance = __esm({
32911
33242
  cwd: this.workingDir,
32912
33243
  env: env3,
32913
33244
  stdio: ["pipe", "pipe", "pipe"],
32914
- shell: spawnConfig.shell || false
33245
+ shell: spawnConfig.shell || false,
33246
+ ...process.platform === "win32" ? { windowsHide: true } : {}
32915
33247
  });
32916
33248
  const AUTH_ERROR_PATTERNS = [
32917
33249
  /unauthorized|unauthenticated/i,
@@ -33610,7 +33942,10 @@ function commandExists(command) {
33610
33942
  return (0, import_fs5.existsSync)(expandExecutable(trimmed));
33611
33943
  }
33612
33944
  try {
33613
- (0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], { stdio: "ignore" });
33945
+ (0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
33946
+ stdio: "ignore",
33947
+ ...process.platform === "win32" ? { windowsHide: true } : {}
33948
+ });
33614
33949
  return true;
33615
33950
  } catch {
33616
33951
  return false;
@@ -38329,7 +38664,7 @@ async function launchMacOS(ide, port, workspace, newWindow) {
38329
38664
  const canUseAppLauncher = !!appName;
38330
38665
  const useAppLauncher = preferredMethod === "app" ? canUseAppLauncher : preferredMethod === "cli" ? false : !canUseCli && canUseAppLauncher;
38331
38666
  if (!useAppLauncher && ide.cliCommand) {
38332
- (0, import_child_process7.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore" }).unref();
38667
+ (0, import_child_process7.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
38333
38668
  } else if (appName) {
38334
38669
  const openArgs = ["-a", appName, "--args", ...args];
38335
38670
  (0, import_child_process7.spawn)("open", openArgs, { detached: true, stdio: "ignore" }).unref();
@@ -38358,7 +38693,7 @@ async function launchLinux(ide, port, workspace, newWindow) {
38358
38693
  const args = ["--remote-debugging-port=" + port];
38359
38694
  if (newWindow) args.push("--new-window");
38360
38695
  if (workspace) args.push(workspace);
38361
- (0, import_child_process7.spawn)(cli, args, { detached: true, stdio: "ignore" }).unref();
38696
+ (0, import_child_process7.spawn)(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
38362
38697
  }
38363
38698
  function getAvailableIdeIds() {
38364
38699
  return getProviderLoader().getAvailableIdeTypes();
@@ -38867,23 +39202,23 @@ function resolveSiblingNpmInvocation(nodeExecutable, platform12 = process.platfo
38867
39202
  if (platform12 === "win32") {
38868
39203
  const npmCliPath = path17.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
38869
39204
  if (fs8.existsSync(npmCliPath)) {
38870
- return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: { shell: false } };
39205
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
38871
39206
  }
38872
39207
  for (const candidate of ["npm.exe", "npm"]) {
38873
39208
  const candidatePath = path17.join(binDir, candidate);
38874
39209
  if (fs8.existsSync(candidatePath)) {
38875
- return { executable: candidatePath, argsPrefix: [], execOptions: { shell: false } };
39210
+ return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
38876
39211
  }
38877
39212
  }
38878
- return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: { shell: false } };
39213
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
38879
39214
  }
38880
39215
  for (const candidate of ["npm"]) {
38881
39216
  const candidatePath = path17.join(binDir, candidate);
38882
39217
  if (fs8.existsSync(candidatePath)) {
38883
- return { executable: candidatePath, argsPrefix: [], execOptions: { shell: false } };
39218
+ return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
38884
39219
  }
38885
39220
  }
38886
- return { executable: "npm", argsPrefix: [], execOptions: { shell: false } };
39221
+ return { executable: "npm", argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
38887
39222
  }
38888
39223
  function findCurrentPackageRoot(currentCliPath, packageName) {
38889
39224
  if (!currentCliPath) return null;
@@ -38954,13 +39289,28 @@ function buildPinnedGlobalInstallCommand(options) {
38954
39289
  execOptions: surface.execOptions || getNpmExecOptions(options.platform)
38955
39290
  };
38956
39291
  }
38957
- function getNpmExecOptions(_platform = process.platform) {
39292
+ function getNpmExecOptions(platform12 = process.platform) {
39293
+ if (platform12 === "win32") {
39294
+ return { shell: false, windowsHide: true };
39295
+ }
38958
39296
  return { shell: false };
38959
39297
  }
39298
+ function execNpmCommandSync(args, options = {}, surface) {
39299
+ const execOptions = surface?.execOptions || getNpmExecOptions();
39300
+ return (0, import_child_process8.execFileSync)(
39301
+ surface?.npmExecutable || "npm",
39302
+ [...surface?.npmArgsPrefix || [], ...args],
39303
+ {
39304
+ ...options,
39305
+ ...execOptions,
39306
+ ...process.platform === "win32" ? { windowsHide: true } : {}
39307
+ }
39308
+ );
39309
+ }
38960
39310
  function killPid(pid) {
38961
39311
  try {
38962
39312
  if (process.platform === "win32") {
38963
- (0, import_child_process8.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
39313
+ (0, import_child_process8.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
38964
39314
  } else {
38965
39315
  process.kill(pid, "SIGTERM");
38966
39316
  }
@@ -38979,7 +39329,7 @@ function getWindowsProcessCommandLine(pid) {
38979
39329
  "Bypass",
38980
39330
  "-Command",
38981
39331
  `(Get-CimInstance Win32_Process -Filter "${pidFilter}").CommandLine`
38982
- ], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
39332
+ ], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
38983
39333
  if (psOut) return psOut;
38984
39334
  } catch {
38985
39335
  }
@@ -38990,7 +39340,7 @@ function getWindowsProcessCommandLine(pid) {
38990
39340
  pidFilter,
38991
39341
  "get",
38992
39342
  "CommandLine"
38993
- ], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
39343
+ ], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
38994
39344
  if (wmicOut) return wmicOut;
38995
39345
  } catch {
38996
39346
  }
@@ -39051,9 +39401,9 @@ function removeDaemonPidFile() {
39051
39401
  }
39052
39402
  function cleanupStaleGlobalInstallDirs(pkgName, surface) {
39053
39403
  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();
39404
+ const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
39055
39405
  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();
39406
+ const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
39057
39407
  const binDir = process.platform === "win32" ? npmPrefix : path17.join(npmPrefix, "bin");
39058
39408
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
39059
39409
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
@@ -39581,6 +39931,8 @@ var init_router = __esm({
39581
39931
  const wantsAll = args?.all === true;
39582
39932
  const offset = wantsAll ? 0 : Math.max(0, Number(args?.offset) || 0);
39583
39933
  const limit = wantsAll ? Number.MAX_SAFE_INTEGER : Math.max(1, Math.min(100, Number(args?.limit) || 30));
39934
+ const requestedWorkspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
39935
+ const requestedProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : typeof args?.activeProviderSessionId === "string" ? args.activeProviderSessionId.trim() : "";
39584
39936
  const providerMeta = this.deps.providerLoader.resolve?.(providerType) || this.deps.providerLoader.getMeta(providerType);
39585
39937
  const { sessions: historySessions, hasMore, source } = listProviderHistorySessions(providerType, {
39586
39938
  canonicalHistory: providerMeta?.canonicalHistory,
@@ -39600,6 +39952,7 @@ var init_router = __esm({
39600
39952
  sessions: historySessions.map((session) => {
39601
39953
  const saved = savedSessionById.get(session.historySessionId);
39602
39954
  const recent = recentSessionById.get(session.historySessionId);
39955
+ const workspace = saved?.workspace || recent?.workspace || session.workspace || (requestedWorkspace && requestedProviderSessionId === session.historySessionId ? requestedWorkspace : void 0);
39603
39956
  return {
39604
39957
  id: session.historySessionId,
39605
39958
  providerSessionId: session.historySessionId,
@@ -39607,13 +39960,13 @@ var init_router = __esm({
39607
39960
  providerName: saved?.providerName || recent?.providerName || providerType,
39608
39961
  kind: saved?.kind || recent?.kind || kind,
39609
39962
  title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
39610
- workspace: saved?.workspace || recent?.workspace || session.workspace,
39963
+ workspace,
39611
39964
  summaryMetadata: saved?.summaryMetadata || recent?.summaryMetadata,
39612
39965
  preview: session.preview,
39613
39966
  messageCount: session.messageCount,
39614
39967
  firstMessageAt: session.firstMessageAt,
39615
39968
  lastMessageAt: session.lastMessageAt,
39616
- canResume: !!(saved?.workspace || recent?.workspace || session.workspace) && canResumeById,
39969
+ canResume: !!workspace && canResumeById,
39617
39970
  historySource: session.source,
39618
39971
  sourcePath: session.sourcePath,
39619
39972
  sourceMtimeMs: session.sourceMtimeMs
@@ -39875,18 +40228,18 @@ var init_router = __esm({
39875
40228
  case "daemon_upgrade": {
39876
40229
  LOG.info("Upgrade", "Remote upgrade requested from dashboard");
39877
40230
  try {
39878
- const { execSync: execSync8 } = await import("child_process");
39879
40231
  const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
39880
40232
  const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
39881
- const latest = execSync8(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
40233
+ const npmSurface = resolveCurrentGlobalInstallSurface({ packageName: pkgName });
40234
+ const latest = String(execNpmCommandSync(["view", pkgName, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
39882
40235
  LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
39883
40236
  let currentInstalled = null;
39884
40237
  try {
39885
- const currentJson = execSync8(`npm ls -g ${pkgName} --depth=0 --json`, {
40238
+ const currentJson = String(execNpmCommandSync(["ls", "-g", pkgName, "--depth=0", "--json"], {
39886
40239
  encoding: "utf-8",
39887
40240
  timeout: 1e4,
39888
40241
  stdio: ["pipe", "pipe", "pipe"]
39889
- }).trim();
40242
+ }, npmSurface)).trim();
39890
40243
  const parsed = JSON.parse(currentJson);
39891
40244
  currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
39892
40245
  } catch {
@@ -48135,6 +48488,7 @@ __export(src_exports, {
48135
48488
  detectCLIs: () => detectCLIs,
48136
48489
  detectIDEs: () => detectIDEs,
48137
48490
  ensureSessionHostReady: () => ensureSessionHostReady,
48491
+ execNpmCommandSync: () => execNpmCommandSync,
48138
48492
  findCdpManager: () => findCdpManager,
48139
48493
  flattenMessageParts: () => flattenMessageParts,
48140
48494
  forwardAgentStreamsToIdeInstance: () => forwardAgentStreamsToIdeInstance,
@@ -48145,6 +48499,7 @@ __export(src_exports, {
48145
48499
  getDebugRuntimeConfig: () => getDebugRuntimeConfig,
48146
48500
  getHostMemorySnapshot: () => getHostMemorySnapshot,
48147
48501
  getLogLevel: () => getLogLevel,
48502
+ getNpmExecOptions: () => getNpmExecOptions,
48148
48503
  getRecentActivity: () => getRecentActivity,
48149
48504
  getRecentCommands: () => getRecentCommands,
48150
48505
  getRecentDebugTrace: () => getRecentDebugTrace,
@@ -88085,7 +88440,7 @@ var init_adhdev_daemon = __esm({
88085
88440
  init_version();
88086
88441
  init_src();
88087
88442
  init_runtime_defaults();
88088
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.48" });
88443
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.50" });
88089
88444
  AdhdevDaemon = class _AdhdevDaemon {
88090
88445
  localHttpServer = null;
88091
88446
  localWss = null;
@@ -91965,7 +92320,9 @@ async function runDaemonUpgrade(options, pkgVersion3) {
91965
92320
  console.log(source_default.cyan("\n Checking for updates..."));
91966
92321
  let latest;
91967
92322
  try {
91968
- latest = execSync8("npm view adhdev version", { encoding: "utf-8" }).trim();
92323
+ const { execNpmCommandSync: execNpmCommandSync2, resolveCurrentGlobalInstallSurface: resolveCurrentGlobalInstallSurface2 } = await Promise.resolve().then(() => (init_src(), src_exports));
92324
+ const npmSurface = resolveCurrentGlobalInstallSurface2({ packageName: "adhdev" });
92325
+ latest = String(execNpmCommandSync2(["view", "adhdev", "version"], { encoding: "utf-8" }, npmSurface)).trim();
91969
92326
  } catch (e) {
91970
92327
  console.log(source_default.red(`
91971
92328
  \u2717 Failed to check latest version: ${e?.message}