adhdev 0.9.44 → 0.9.45

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
@@ -500,18 +500,18 @@ var init_source = __esm({
500
500
  }
501
501
  }
502
502
  });
503
- createStyler = (open3, close, parent) => {
503
+ createStyler = (open2, close, parent) => {
504
504
  let openAll;
505
505
  let closeAll;
506
506
  if (parent === void 0) {
507
- openAll = open3;
507
+ openAll = open2;
508
508
  closeAll = close;
509
509
  } else {
510
- openAll = parent.openAll + open3;
510
+ openAll = parent.openAll + open2;
511
511
  closeAll = close + parent.closeAll;
512
512
  }
513
513
  return {
514
- open: open3,
514
+ open: open2,
515
515
  close,
516
516
  openAll,
517
517
  closeAll,
@@ -1410,17 +1410,17 @@ function checkPathExists(paths) {
1410
1410
  return null;
1411
1411
  }
1412
1412
  async function detectIDEs(providerLoader) {
1413
- const os31 = (0, import_os2.platform)();
1413
+ const os30 = (0, import_os2.platform)();
1414
1414
  const results = [];
1415
1415
  for (const def of getMergedDefinitions()) {
1416
1416
  const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
1417
- const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os31] || []) || []);
1417
+ const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os30] || []) || []);
1418
1418
  let resolvedCli = cliPath;
1419
- if (!resolvedCli && appPath && os31 === "darwin") {
1419
+ if (!resolvedCli && appPath && os30 === "darwin") {
1420
1420
  const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
1421
1421
  if ((0, import_fs3.existsSync)(bundledCli)) resolvedCli = bundledCli;
1422
1422
  }
1423
- if (!resolvedCli && appPath && os31 === "win32") {
1423
+ if (!resolvedCli && appPath && os30 === "win32") {
1424
1424
  const { dirname: dirname11 } = await import("path");
1425
1425
  const appDir = dirname11(appPath);
1426
1426
  const candidates = [
@@ -1437,7 +1437,7 @@ async function detectIDEs(providerLoader) {
1437
1437
  }
1438
1438
  }
1439
1439
  }
1440
- const installed = os31 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
1440
+ const installed = os30 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
1441
1441
  const version2 = resolvedCli ? getIdeVersion(resolvedCli) : null;
1442
1442
  results.push({
1443
1443
  id: def.id,
@@ -1506,8 +1506,8 @@ function execAsync(cmd, timeoutMs = 5e3) {
1506
1506
  });
1507
1507
  }
1508
1508
  async function detectCLIs(providerLoader, options) {
1509
- const platform13 = os3.platform();
1510
- const whichCmd = platform13 === "win32" ? "where" : "which";
1509
+ const platform12 = os3.platform();
1510
+ const whichCmd = platform12 === "win32" ? "where" : "which";
1511
1511
  const includeVersion = options?.includeVersion !== false;
1512
1512
  const cliList = providerLoader ? providerLoader.getCliDetectionList() : [];
1513
1513
  const results = await Promise.all(
@@ -1550,8 +1550,8 @@ async function detectCLI(cliId, providerLoader, options) {
1550
1550
  const cliList = providerLoader.getCliDetectionList();
1551
1551
  const target = cliList.find((c) => c.id === resolvedId);
1552
1552
  if (target) {
1553
- const platform13 = os3.platform();
1554
- const whichCmd = platform13 === "win32" ? "where" : "which";
1553
+ const platform12 = os3.platform();
1554
+ const whichCmd = platform12 === "win32" ? "where" : "which";
1555
1555
  try {
1556
1556
  const explicitPath = resolveCommandPath(target.command);
1557
1557
  const pathResult = explicitPath || await execAsync(`${whichCmd} ${shellQuote(target.command)}`);
@@ -4552,6 +4552,27 @@ function computeSavedHistorySessionSummaries(agentType, dir, files, fileSignatur
4552
4552
  persistedEntries: nextPersistedEntries
4553
4553
  };
4554
4554
  }
4555
+ function pageHistoryRecords(agentType, records, offset = 0, limit = 30, excludeRecentCount = 0, historyBehavior) {
4556
+ const allMessages = records.map((message) => sanitizeHistoryMessage(agentType, message)).filter(Boolean);
4557
+ allMessages.sort((a, b) => a.receivedAt - b.receivedAt);
4558
+ const chronological = [];
4559
+ let lastTurn = null;
4560
+ for (const message of allMessages) {
4561
+ const previous = chronological[chronological.length - 1];
4562
+ if (isAdjacentHistoryDuplicate(agentType, previous, message)) continue;
4563
+ if (message.role !== "system" && isAdjacentHistoryDuplicate(agentType, lastTurn, message)) continue;
4564
+ chronological.push(message);
4565
+ if (message.role !== "system") lastTurn = message;
4566
+ }
4567
+ const collapsed = collapseReplayAssistantTurns(chronological, historyBehavior);
4568
+ const boundedLimit = Math.max(1, limit);
4569
+ const boundedOffset = Math.max(0, offset);
4570
+ const boundedExclude = Math.max(0, Math.min(excludeRecentCount, collapsed.length));
4571
+ const endExclusive = Math.max(0, collapsed.length - boundedExclude - boundedOffset);
4572
+ const startInclusive = Math.max(0, endExclusive - boundedLimit);
4573
+ const sliced = collapsed.slice(startInclusive, endExclusive);
4574
+ return { messages: sliced, hasMore: startInclusive > 0 };
4575
+ }
4555
4576
  function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, excludeRecentCount = 0, historyBehavior) {
4556
4577
  try {
4557
4578
  const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
@@ -4577,25 +4598,7 @@ function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, ex
4577
4598
  }
4578
4599
  }
4579
4600
  }
4580
- allMessages.sort((a, b) => a.receivedAt - b.receivedAt);
4581
- const chronological = [];
4582
- let lastTurn = null;
4583
- for (const message of allMessages) {
4584
- const previous = chronological[chronological.length - 1];
4585
- if (isAdjacentHistoryDuplicate(agentType, previous, message)) continue;
4586
- if (message.role !== "system" && isAdjacentHistoryDuplicate(agentType, lastTurn, message)) continue;
4587
- chronological.push(message);
4588
- if (message.role !== "system") lastTurn = message;
4589
- }
4590
- const collapsed = collapseReplayAssistantTurns(chronological, historyBehavior);
4591
- const boundedLimit = Math.max(1, limit);
4592
- const boundedOffset = Math.max(0, offset);
4593
- const boundedExclude = Math.max(0, Math.min(excludeRecentCount, collapsed.length));
4594
- const endExclusive = Math.max(0, collapsed.length - boundedExclude - boundedOffset);
4595
- const startInclusive = Math.max(0, endExclusive - boundedLimit);
4596
- const sliced = collapsed.slice(startInclusive, endExclusive);
4597
- const hasMore = startInclusive > 0;
4598
- return { messages: sliced, hasMore };
4601
+ return pageHistoryRecords(agentType, allMessages, offset, limit, excludeRecentCount, historyBehavior);
4599
4602
  } catch {
4600
4603
  return { messages: [], hasMore: false };
4601
4604
  }
@@ -4730,6 +4733,52 @@ function rewriteCanonicalSavedHistory(agentType, historySessionId, records) {
4730
4733
  return false;
4731
4734
  }
4732
4735
  }
4736
+ function buildHermesNativeHistoryRecords(historySessionId) {
4737
+ const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId);
4738
+ if (!normalizedSessionId) return null;
4739
+ try {
4740
+ const sessionFilePath = path7.join(os6.homedir(), ".hermes", "sessions", `session_${normalizedSessionId}.json`);
4741
+ if (!fs3.existsSync(sessionFilePath)) return null;
4742
+ const raw = JSON.parse(fs3.readFileSync(sessionFilePath, "utf-8"));
4743
+ const canonicalMessages = Array.isArray(raw.messages) ? raw.messages : [];
4744
+ const records = [];
4745
+ let fallbackTs = Date.parse(raw.session_start || raw.last_updated || "") || Date.now();
4746
+ for (const message of canonicalMessages) {
4747
+ const role = String(message.role || "").trim();
4748
+ const content = normalizeCanonicalHermesMessageContent(message.content);
4749
+ if (!content) continue;
4750
+ const receivedAt = extractCanonicalHermesMessageTimestamp(message, fallbackTs);
4751
+ fallbackTs = receivedAt + 1;
4752
+ if (role === "user" || role === "assistant") {
4753
+ records.push({
4754
+ ts: new Date(receivedAt).toISOString(),
4755
+ receivedAt,
4756
+ role,
4757
+ content,
4758
+ kind: "standard",
4759
+ agent: "hermes-cli",
4760
+ historySessionId: normalizedSessionId
4761
+ });
4762
+ continue;
4763
+ }
4764
+ if (role === "tool") {
4765
+ records.push({
4766
+ ts: new Date(receivedAt).toISOString(),
4767
+ receivedAt,
4768
+ role: "assistant",
4769
+ content,
4770
+ kind: "tool",
4771
+ senderName: "Tool",
4772
+ agent: "hermes-cli",
4773
+ historySessionId: normalizedSessionId
4774
+ });
4775
+ }
4776
+ }
4777
+ return records;
4778
+ } catch {
4779
+ return null;
4780
+ }
4781
+ }
4733
4782
  function rebuildHermesSavedHistoryFromCanonicalSession(historySessionId) {
4734
4783
  const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId);
4735
4784
  if (!normalizedSessionId) return false;
@@ -4879,6 +4928,77 @@ function extractClaudeUserContentParts(content) {
4879
4928
  }
4880
4929
  return parts;
4881
4930
  }
4931
+ function buildClaudeNativeHistoryRecords(historySessionId, workspace) {
4932
+ const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId);
4933
+ if (!normalizedSessionId) return null;
4934
+ try {
4935
+ const transcriptPath = resolveClaudeProjectTranscriptPath(normalizedSessionId, workspace);
4936
+ if (!transcriptPath) return null;
4937
+ const lines = fs3.readFileSync(transcriptPath, "utf-8").split("\n").filter(Boolean);
4938
+ const records = [];
4939
+ let fallbackTs = Date.now();
4940
+ for (const line of lines) {
4941
+ let parsed = null;
4942
+ try {
4943
+ parsed = JSON.parse(line);
4944
+ } catch {
4945
+ parsed = null;
4946
+ }
4947
+ if (!parsed) continue;
4948
+ const parsedSessionId = String(parsed.sessionId || "").trim();
4949
+ if (parsedSessionId && parsedSessionId !== normalizedSessionId) continue;
4950
+ const receivedAt = extractTimestampValue(parsed.timestamp) || fallbackTs;
4951
+ fallbackTs = receivedAt + 1;
4952
+ const parsedWorkspace = String(parsed.cwd || workspace || "").trim();
4953
+ if (records.length === 0 && parsedWorkspace) {
4954
+ records.push({
4955
+ ts: new Date(receivedAt).toISOString(),
4956
+ receivedAt,
4957
+ role: "system",
4958
+ kind: "session_start",
4959
+ content: parsedWorkspace,
4960
+ agent: "claude-cli",
4961
+ historySessionId: normalizedSessionId,
4962
+ workspace: parsedWorkspace
4963
+ });
4964
+ }
4965
+ const type = String(parsed.type || "").trim();
4966
+ const message = parsed.message && typeof parsed.message === "object" ? parsed.message : null;
4967
+ if (type === "user" && message) {
4968
+ for (const part of extractClaudeUserContentParts(message.content)) {
4969
+ records.push({
4970
+ ts: new Date(receivedAt).toISOString(),
4971
+ receivedAt,
4972
+ role: part.role,
4973
+ content: part.content,
4974
+ kind: part.kind,
4975
+ senderName: part.senderName,
4976
+ agent: "claude-cli",
4977
+ historySessionId: normalizedSessionId
4978
+ });
4979
+ }
4980
+ continue;
4981
+ }
4982
+ if (type === "assistant" && message) {
4983
+ for (const part of extractClaudeAssistantContentParts(message.content)) {
4984
+ records.push({
4985
+ ts: new Date(receivedAt).toISOString(),
4986
+ receivedAt,
4987
+ role: "assistant",
4988
+ content: part.content,
4989
+ kind: part.kind,
4990
+ senderName: part.senderName,
4991
+ agent: "claude-cli",
4992
+ historySessionId: normalizedSessionId
4993
+ });
4994
+ }
4995
+ }
4996
+ }
4997
+ return records;
4998
+ } catch {
4999
+ return null;
5000
+ }
5001
+ }
4882
5002
  function rebuildClaudeSavedHistoryFromNativeProject(historySessionId, workspace) {
4883
5003
  const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId);
4884
5004
  if (!normalizedSessionId) return false;
@@ -4957,6 +5077,352 @@ function rebuildClaudeSavedHistoryFromNativeProject(historySessionId, workspace)
4957
5077
  return false;
4958
5078
  }
4959
5079
  }
5080
+ function isUuidLikeSessionId(sessionId) {
5081
+ return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(sessionId);
5082
+ }
5083
+ function readCodexSessionMeta(filePath) {
5084
+ try {
5085
+ const firstLine = fs3.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
5086
+ if (!firstLine) return null;
5087
+ const parsed = JSON.parse(firstLine);
5088
+ if (String(parsed.type || "") !== "session_meta") return null;
5089
+ const payload = parsed.payload && typeof parsed.payload === "object" ? parsed.payload : null;
5090
+ return payload;
5091
+ } catch {
5092
+ return null;
5093
+ }
5094
+ }
5095
+ function resolveCodexSessionTranscriptPath(historySessionId, workspace) {
5096
+ const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId);
5097
+ if (!normalizedSessionId || !isUuidLikeSessionId(normalizedSessionId)) return null;
5098
+ const sessionsDir = path7.join(os6.homedir(), ".codex", "sessions");
5099
+ if (!fs3.existsSync(sessionsDir)) return null;
5100
+ const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
5101
+ const candidates = [];
5102
+ const stack = [sessionsDir];
5103
+ while (stack.length > 0) {
5104
+ const current = stack.pop();
5105
+ if (!current) continue;
5106
+ let entries = [];
5107
+ try {
5108
+ entries = fs3.readdirSync(current, { withFileTypes: true });
5109
+ } catch {
5110
+ continue;
5111
+ }
5112
+ for (const entry of entries) {
5113
+ const entryPath = path7.join(current, entry.name);
5114
+ if (entry.isDirectory()) {
5115
+ stack.push(entryPath);
5116
+ continue;
5117
+ }
5118
+ if (!entry.isFile() || !entry.name.endsWith(".jsonl") || !entry.name.includes(normalizedSessionId)) continue;
5119
+ const meta3 = readCodexSessionMeta(entryPath);
5120
+ const metaSessionId = String(meta3?.id || "").trim();
5121
+ if (metaSessionId && metaSessionId !== normalizedSessionId) continue;
5122
+ const metaWorkspace = String(meta3?.cwd || "").trim();
5123
+ let mtimeMs = 0;
5124
+ try {
5125
+ mtimeMs = fs3.statSync(entryPath).mtimeMs;
5126
+ } catch {
5127
+ }
5128
+ candidates.push({
5129
+ path: entryPath,
5130
+ mtimeMs,
5131
+ workspaceMatches: !!normalizedWorkspace && metaWorkspace === normalizedWorkspace,
5132
+ metaMatches: metaSessionId === normalizedSessionId
5133
+ });
5134
+ }
5135
+ }
5136
+ candidates.sort((a, b) => Number(b.workspaceMatches) - Number(a.workspaceMatches) || Number(b.metaMatches) - Number(a.metaMatches) || b.mtimeMs - a.mtimeMs);
5137
+ return candidates[0]?.path || null;
5138
+ }
5139
+ function flattenCodexContent(content) {
5140
+ if (typeof content === "string") return content.trim();
5141
+ if (content == null) return "";
5142
+ if (Array.isArray(content)) {
5143
+ return content.map((entry) => flattenCodexContent(entry)).filter(Boolean).join("\n").trim();
5144
+ }
5145
+ if (typeof content === "object") {
5146
+ const record2 = content;
5147
+ if (typeof record2.text === "string") return record2.text.trim();
5148
+ if (typeof record2.content === "string" || Array.isArray(record2.content)) return flattenCodexContent(record2.content);
5149
+ if (typeof record2.output === "string") return record2.output.trim();
5150
+ if (typeof record2.message === "string") return record2.message.trim();
5151
+ }
5152
+ return "";
5153
+ }
5154
+ function summarizeCodexToolCall(payload) {
5155
+ const name = String(payload.name || payload.type || "tool").trim() || "tool";
5156
+ const rawArguments = payload.arguments ?? payload.input;
5157
+ let argumentValue = "";
5158
+ if (typeof rawArguments === "string") {
5159
+ const trimmed = rawArguments.trim();
5160
+ try {
5161
+ const parsed = JSON.parse(trimmed);
5162
+ argumentValue = summarizeCodexToolArguments(parsed);
5163
+ } catch {
5164
+ argumentValue = trimmed;
5165
+ }
5166
+ } else {
5167
+ argumentValue = summarizeCodexToolArguments(rawArguments);
5168
+ }
5169
+ return argumentValue ? `${name}: ${argumentValue}` : name;
5170
+ }
5171
+ function summarizeCodexToolArguments(value) {
5172
+ if (typeof value === "string") return value.trim();
5173
+ if (Array.isArray(value)) return value.map((entry) => String(entry)).join(" ").trim();
5174
+ if (!value || typeof value !== "object") return "";
5175
+ const record2 = value;
5176
+ const direct = record2.command || record2.cmd || record2.query || record2.path || record2.prompt;
5177
+ if (typeof direct === "string") return direct.trim();
5178
+ if (Array.isArray(direct)) return direct.map((entry) => String(entry)).join(" ").trim();
5179
+ try {
5180
+ return JSON.stringify(record2).trim();
5181
+ } catch {
5182
+ return "";
5183
+ }
5184
+ }
5185
+ function codexToolOutputContent(payload) {
5186
+ const output = payload.output ?? payload.result ?? payload.content;
5187
+ const text = flattenCodexContent(output);
5188
+ if (text) return text;
5189
+ if (output && typeof output === "object") {
5190
+ try {
5191
+ return JSON.stringify(output).trim();
5192
+ } catch {
5193
+ return "";
5194
+ }
5195
+ }
5196
+ return "";
5197
+ }
5198
+ function buildCodexNativeHistoryRecords(historySessionId, workspace) {
5199
+ const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId);
5200
+ if (!normalizedSessionId || !isUuidLikeSessionId(normalizedSessionId)) return null;
5201
+ try {
5202
+ const transcriptPath = resolveCodexSessionTranscriptPath(normalizedSessionId, workspace);
5203
+ if (!transcriptPath) return null;
5204
+ const lines = fs3.readFileSync(transcriptPath, "utf-8").split("\n").filter(Boolean);
5205
+ const records = [];
5206
+ let fallbackTs = Date.now();
5207
+ for (const line of lines) {
5208
+ let parsed = null;
5209
+ try {
5210
+ parsed = JSON.parse(line);
5211
+ } catch {
5212
+ parsed = null;
5213
+ }
5214
+ if (!parsed) continue;
5215
+ const receivedAt = extractTimestampValue(parsed.timestamp) || fallbackTs;
5216
+ fallbackTs = receivedAt + 1;
5217
+ const type = String(parsed.type || "").trim();
5218
+ const payload = parsed.payload && typeof parsed.payload === "object" ? parsed.payload : null;
5219
+ if (!payload) continue;
5220
+ if (type === "session_meta") {
5221
+ const parsedSessionId = String(payload.id || "").trim();
5222
+ if (parsedSessionId && parsedSessionId !== normalizedSessionId) return null;
5223
+ const parsedWorkspace = String(payload.cwd || workspace || "").trim();
5224
+ if (records.length === 0 && parsedWorkspace) {
5225
+ records.push({
5226
+ ts: new Date(receivedAt).toISOString(),
5227
+ receivedAt,
5228
+ role: "system",
5229
+ kind: "session_start",
5230
+ content: parsedWorkspace,
5231
+ agent: "codex-cli",
5232
+ historySessionId: normalizedSessionId,
5233
+ workspace: parsedWorkspace
5234
+ });
5235
+ }
5236
+ continue;
5237
+ }
5238
+ if (type !== "response_item") continue;
5239
+ const payloadType = String(payload.type || "").trim();
5240
+ if (payloadType === "message") {
5241
+ const role = String(payload.role || "").trim();
5242
+ if (role !== "user" && role !== "assistant") continue;
5243
+ const content = flattenCodexContent(payload.content);
5244
+ if (!content) continue;
5245
+ records.push({
5246
+ ts: new Date(receivedAt).toISOString(),
5247
+ receivedAt,
5248
+ role,
5249
+ content,
5250
+ kind: "standard",
5251
+ agent: "codex-cli",
5252
+ historySessionId: normalizedSessionId
5253
+ });
5254
+ continue;
5255
+ }
5256
+ if (payloadType === "function_call" || payloadType === "custom_tool_call") {
5257
+ const content = summarizeCodexToolCall(payload);
5258
+ if (!content) continue;
5259
+ records.push({
5260
+ ts: new Date(receivedAt).toISOString(),
5261
+ receivedAt,
5262
+ role: "assistant",
5263
+ content,
5264
+ kind: "tool",
5265
+ senderName: "Tool",
5266
+ agent: "codex-cli",
5267
+ historySessionId: normalizedSessionId
5268
+ });
5269
+ continue;
5270
+ }
5271
+ if (payloadType === "function_call_output" || payloadType === "custom_tool_call_output") {
5272
+ const content = codexToolOutputContent(payload);
5273
+ if (!content) continue;
5274
+ records.push({
5275
+ ts: new Date(receivedAt).toISOString(),
5276
+ receivedAt,
5277
+ role: "assistant",
5278
+ content,
5279
+ kind: "tool",
5280
+ senderName: "Tool",
5281
+ agent: "codex-cli",
5282
+ historySessionId: normalizedSessionId
5283
+ });
5284
+ }
5285
+ }
5286
+ return records;
5287
+ } catch {
5288
+ return null;
5289
+ }
5290
+ }
5291
+ function rebuildCodexSavedHistoryFromNativeSession(historySessionId, workspace) {
5292
+ const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId);
5293
+ if (!normalizedSessionId || !isUuidLikeSessionId(normalizedSessionId)) return false;
5294
+ const records = buildCodexNativeHistoryRecords(normalizedSessionId, workspace);
5295
+ if (!records || records.length === 0) return false;
5296
+ const existingSessionStart = readExistingSessionStartRecord("codex-cli", normalizedSessionId);
5297
+ const recordsToWrite = existingSessionStart && records[0]?.kind !== "session_start" ? [{ ...existingSessionStart, historySessionId: normalizedSessionId }, ...records] : records;
5298
+ return rewriteCanonicalSavedHistory("codex-cli", normalizedSessionId, recordsToWrite);
5299
+ }
5300
+ function isNativeSourceCanonicalHistory(canonicalHistory) {
5301
+ if (!canonicalHistory) return false;
5302
+ if (canonicalHistory.mode === "disabled") return false;
5303
+ if (canonicalHistory.mode === "materialized-mirror") return false;
5304
+ return true;
5305
+ }
5306
+ function buildNativeHistoryRecords(canonicalHistory, historySessionId, workspace) {
5307
+ const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId || "");
5308
+ if (!canonicalHistory || !normalizedSessionId || !isNativeSourceCanonicalHistory(canonicalHistory)) return null;
5309
+ if (canonicalHistory.format === "hermes-json") return buildHermesNativeHistoryRecords(normalizedSessionId);
5310
+ if (canonicalHistory.format === "claude-jsonl") return buildClaudeNativeHistoryRecords(normalizedSessionId, workspace);
5311
+ if (canonicalHistory.format === "codex-jsonl") return buildCodexNativeHistoryRecords(normalizedSessionId, workspace);
5312
+ return null;
5313
+ }
5314
+ function readProviderChatHistory(agentType, options = {}) {
5315
+ if (isNativeSourceCanonicalHistory(options.canonicalHistory) && options.historySessionId) {
5316
+ const records = buildNativeHistoryRecords(options.canonicalHistory, options.historySessionId, options.workspace);
5317
+ if (!records) return { messages: [], hasMore: false, source: "native-unavailable" };
5318
+ return {
5319
+ ...pageHistoryRecords(agentType, records, options.offset || 0, options.limit || 30, options.excludeRecentCount || 0, options.historyBehavior),
5320
+ source: "provider-native"
5321
+ };
5322
+ }
5323
+ return {
5324
+ ...readChatHistory(agentType, options.offset || 0, options.limit || 30, options.historySessionId, options.excludeRecentCount || 0, options.historyBehavior),
5325
+ source: "adhdev-mirror"
5326
+ };
5327
+ }
5328
+ function buildNativeSessionSummary(agentType, historySessionId, records, sourcePath) {
5329
+ const visible = pageHistoryRecords(agentType, records, 0, Number.MAX_SAFE_INTEGER).messages;
5330
+ if (visible.length === 0) return null;
5331
+ let sourceMtimeMs = 0;
5332
+ try {
5333
+ sourceMtimeMs = fs3.statSync(sourcePath).mtimeMs;
5334
+ } catch {
5335
+ }
5336
+ const firstMessageAt = visible[0]?.receivedAt || sourceMtimeMs || Date.now();
5337
+ const lastMessageAt = visible[visible.length - 1]?.receivedAt || firstMessageAt;
5338
+ const lastNonSystem = [...visible].reverse().find((message) => message.role !== "system") || visible[visible.length - 1];
5339
+ const firstSystem = visible.find((message) => message.kind === "session_start");
5340
+ return {
5341
+ historySessionId,
5342
+ sessionTitle: lastNonSystem?.content,
5343
+ messageCount: visible.length,
5344
+ firstMessageAt,
5345
+ lastMessageAt,
5346
+ preview: lastNonSystem?.content,
5347
+ workspace: firstSystem?.workspace || (firstSystem?.kind === "session_start" ? firstSystem.content : void 0),
5348
+ source: "provider-native",
5349
+ sourcePath,
5350
+ sourceMtimeMs
5351
+ };
5352
+ }
5353
+ function listFilesRecursive(root, predicate) {
5354
+ if (!fs3.existsSync(root)) return [];
5355
+ const results = [];
5356
+ const stack = [root];
5357
+ while (stack.length > 0) {
5358
+ const current = stack.pop();
5359
+ if (!current) continue;
5360
+ let entries = [];
5361
+ try {
5362
+ entries = fs3.readdirSync(current, { withFileTypes: true });
5363
+ } catch {
5364
+ continue;
5365
+ }
5366
+ for (const entry of entries) {
5367
+ const entryPath = path7.join(current, entry.name);
5368
+ if (entry.isDirectory()) {
5369
+ stack.push(entryPath);
5370
+ continue;
5371
+ }
5372
+ if (predicate(entryPath, entry)) results.push(entryPath);
5373
+ }
5374
+ }
5375
+ return results;
5376
+ }
5377
+ function collectNativeHistorySessionSummaries(agentType, canonicalHistory) {
5378
+ const summaries = [];
5379
+ if (canonicalHistory.format === "hermes-json") {
5380
+ const root = path7.join(os6.homedir(), ".hermes", "sessions");
5381
+ for (const filePath of listFilesRecursive(root, (_entryPath, entry) => entry.isFile() && /^session_.+\.json$/.test(entry.name))) {
5382
+ const fileName = path7.basename(filePath);
5383
+ const historySessionId = fileName.replace(/^session_/, "").replace(/\.json$/, "");
5384
+ const records = buildHermesNativeHistoryRecords(historySessionId);
5385
+ const summary = records ? buildNativeSessionSummary(agentType, historySessionId, records, filePath) : null;
5386
+ if (summary) summaries.push(summary);
5387
+ }
5388
+ } else if (canonicalHistory.format === "claude-jsonl") {
5389
+ const root = path7.join(os6.homedir(), ".claude", "projects");
5390
+ for (const filePath of listFilesRecursive(root, (_entryPath, entry) => entry.isFile() && entry.name.endsWith(".jsonl"))) {
5391
+ const historySessionId = path7.basename(filePath, ".jsonl");
5392
+ const records = buildClaudeNativeHistoryRecords(historySessionId);
5393
+ const summary = records ? buildNativeSessionSummary(agentType, historySessionId, records, filePath) : null;
5394
+ if (summary) summaries.push(summary);
5395
+ }
5396
+ } else if (canonicalHistory.format === "codex-jsonl") {
5397
+ const root = path7.join(os6.homedir(), ".codex", "sessions");
5398
+ const uuidPattern = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
5399
+ for (const filePath of listFilesRecursive(root, (_entryPath, entry) => entry.isFile() && entry.name.endsWith(".jsonl"))) {
5400
+ const meta3 = readCodexSessionMeta(filePath);
5401
+ const historySessionId = String(meta3?.id || path7.basename(filePath).match(uuidPattern)?.[1] || "").trim();
5402
+ if (!historySessionId) continue;
5403
+ const records = buildCodexNativeHistoryRecords(historySessionId, String(meta3?.cwd || "").trim() || void 0);
5404
+ const summary = records ? buildNativeSessionSummary(agentType, historySessionId, records, filePath) : null;
5405
+ if (summary) summaries.push(summary);
5406
+ }
5407
+ }
5408
+ return sortSavedHistorySessionSummaries(summaries);
5409
+ }
5410
+ function listProviderHistorySessions(agentType, options = {}) {
5411
+ if (isNativeSourceCanonicalHistory(options.canonicalHistory)) {
5412
+ const offset = Math.max(0, options.offset || 0);
5413
+ const limit = Math.max(1, options.limit || 30);
5414
+ const summaries = collectNativeHistorySessionSummaries(agentType, options.canonicalHistory);
5415
+ return {
5416
+ sessions: summaries.slice(offset, offset + limit),
5417
+ hasMore: offset + limit < summaries.length,
5418
+ source: "provider-native"
5419
+ };
5420
+ }
5421
+ return {
5422
+ ...listSavedHistorySessions(agentType, { offset: options.offset, limit: options.limit }, options.historyBehavior),
5423
+ source: "adhdev-mirror"
5424
+ };
5425
+ }
4960
5426
  var fs3, path7, os6, HISTORY_DIR, RETAIN_DAYS, SAVED_HISTORY_INDEX_VERSION, SAVED_HISTORY_INDEX_FILE, SAVED_HISTORY_INDEX_LOCK_SUFFIX, SAVED_HISTORY_INDEX_LOCK_WAIT_MS, SAVED_HISTORY_INDEX_LOCK_STALE_MS, SAVED_HISTORY_INDEX_LOCK_POLL_MS, SAVED_HISTORY_ROLLUP_THRESHOLD_BYTES, savedHistorySessionCache, savedHistoryFileSummaryCache, savedHistoryBackgroundRefresh, savedHistoryRollupInFlight, ChatHistoryWriter;
4961
5427
  var init_chat_history = __esm({
4962
5428
  "../../oss/packages/daemon-core/src/config/chat-history.ts"() {
@@ -5960,6 +6426,8 @@ function validateReadChatResultPayload(raw, source = "read_chat") {
5960
6426
  if (raw.summaryMetadata !== void 0) normalized.summaryMetadata = raw.summaryMetadata;
5961
6427
  if (Array.isArray(raw.effects)) normalized.effects = raw.effects;
5962
6428
  if (typeof raw.providerSessionId === "string") normalized.providerSessionId = raw.providerSessionId;
6429
+ if (raw.transcriptAuthority === "provider" || raw.transcriptAuthority === "daemon") normalized.transcriptAuthority = raw.transcriptAuthority;
6430
+ if (raw.coverage === "full" || raw.coverage === "tail" || raw.coverage === "current-turn") normalized.coverage = raw.coverage;
5963
6431
  return normalized;
5964
6432
  }
5965
6433
  var VALID_STATUSES, VALID_ROLES, VALID_BUBBLE_STATES, VALID_TURN_STATUSES;
@@ -8227,7 +8695,16 @@ async function handleChatHistory(h, args) {
8227
8695
  const visibleCount = Array.isArray(status?.messages) ? status.messages.length : 0;
8228
8696
  if (visibleCount > excludeRecentCount) excludeRecentCount = visibleCount;
8229
8697
  }
8230
- const result = readChatHistory(agentStr, offset || 0, limit || 30, historySessionId, excludeRecentCount);
8698
+ const workspace = typeof args?.workspace === "string" ? args.workspace : typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
8699
+ const result = readProviderChatHistory(agentStr, {
8700
+ canonicalHistory: provider?.canonicalHistory,
8701
+ historySessionId,
8702
+ workspace,
8703
+ offset: offset || 0,
8704
+ limit: limit || 30,
8705
+ excludeRecentCount,
8706
+ historyBehavior: provider?.historyBehavior
8707
+ });
8231
8708
  return { success: true, ...result, agent: agentStr };
8232
8709
  } catch (e) {
8233
8710
  return { success: false, error: e.message };
@@ -8252,7 +8729,8 @@ async function handleReadChat(h, args) {
8252
8729
  }
8253
8730
  const parsedRecord = parsedStatus && typeof parsedStatus === "object" ? parsedStatus : null;
8254
8731
  const adapterStatus = adapter.getStatus();
8255
- const shouldPreferAdapterMessages = Array.isArray(adapterStatus.messages) && adapterStatus.messages.length > 0 && Array.isArray(parsedRecord?.messages) && adapterStatus.messages.length > parsedRecord.messages.length;
8732
+ const parsedIsProviderAuthoritative = parsedRecord?.transcriptAuthority === "provider" || parsedRecord?.coverage === "full";
8733
+ const shouldPreferAdapterMessages = !parsedIsProviderAuthoritative && Array.isArray(adapterStatus.messages) && adapterStatus.messages.length > 0 && Array.isArray(parsedRecord?.messages) && adapterStatus.messages.length > parsedRecord.messages.length;
8256
8734
  const parsedShowsApproval = hasNonEmptyModalButtons(parsedRecord?.activeModal) && parsedRecord?.status === "waiting_approval";
8257
8735
  const status = parsedRecord ? {
8258
8736
  ...parsedRecord,
@@ -8262,6 +8740,8 @@ async function handleReadChat(h, args) {
8262
8740
  } : adapterStatus;
8263
8741
  const title = typeof parsedRecord?.title === "string" ? parsedRecord.title : void 0;
8264
8742
  const providerSessionId = typeof parsedRecord?.providerSessionId === "string" ? parsedRecord.providerSessionId : void 0;
8743
+ const transcriptAuthority = parsedRecord?.transcriptAuthority === "provider" || parsedRecord?.transcriptAuthority === "daemon" ? parsedRecord.transcriptAuthority : void 0;
8744
+ const coverage = parsedRecord?.coverage === "full" || parsedRecord?.coverage === "tail" || parsedRecord?.coverage === "current-turn" ? parsedRecord.coverage : void 0;
8265
8745
  if (status) {
8266
8746
  LOG.debug("Command", `[read_chat] cli-like resolved provider=${adapter.cliType} target=${String(args?.targetSessionId || "")} adapterStatus=${String(adapterStatus.status || "")} parsedStatus=${String(parsedRecord?.status || "")} shouldPreferAdapterMessages=${String(shouldPreferAdapterMessages)} adapterMsgCount=${Array.isArray(adapterStatus.messages) ? adapterStatus.messages.length : 0} parsedMsgCount=${Array.isArray(parsedRecord?.messages) ? parsedRecord.messages.length : 0} returnedMsgCount=${Array.isArray(status.messages) ? status.messages.length : 0}`);
8267
8747
  return buildReadChatCommandResult({
@@ -8280,7 +8760,9 @@ async function handleReadChat(h, args) {
8280
8760
  returnedMsgCount: Array.isArray(status.messages) ? status.messages.length : 0
8281
8761
  },
8282
8762
  ...title ? { title } : {},
8283
- ...providerSessionId ? { providerSessionId } : {}
8763
+ ...providerSessionId ? { providerSessionId } : {},
8764
+ ...transcriptAuthority ? { transcriptAuthority } : {},
8765
+ ...coverage ? { coverage } : {}
8284
8766
  }, args);
8285
8767
  }
8286
8768
  }
@@ -11072,18 +11554,18 @@ var init_source2 = __esm({
11072
11554
  }
11073
11555
  }
11074
11556
  });
11075
- createStyler2 = (open3, close, parent) => {
11557
+ createStyler2 = (open2, close, parent) => {
11076
11558
  let openAll;
11077
11559
  let closeAll;
11078
11560
  if (parent === void 0) {
11079
- openAll = open3;
11561
+ openAll = open2;
11080
11562
  closeAll = close;
11081
11563
  } else {
11082
- openAll = parent.openAll + open3;
11564
+ openAll = parent.openAll + open2;
11083
11565
  closeAll = close + parent.closeAll;
11084
11566
  }
11085
11567
  return {
11086
- open: open3,
11568
+ open: open2,
11087
11569
  close,
11088
11570
  openAll,
11089
11571
  closeAll,
@@ -11615,14 +12097,14 @@ function applyTerminalColorEnv(env3) {
11615
12097
  function ensureNodePtySpawnHelperPermissions(logFn) {
11616
12098
  if (os22.platform() === "win32") return;
11617
12099
  try {
11618
- const fs27 = __require("fs");
12100
+ const fs22 = __require("fs");
11619
12101
  const ptyDir = path32.resolve(path32.dirname(__require.resolve("node-pty")), "..");
11620
12102
  const platformArch = `${os22.platform()}-${os22.arch()}`;
11621
12103
  const helper = path32.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
11622
- if (fs27.existsSync(helper)) {
11623
- const stat4 = fs27.statSync(helper);
12104
+ if (fs22.existsSync(helper)) {
12105
+ const stat4 = fs22.statSync(helper);
11624
12106
  if (!(stat4.mode & 73)) {
11625
- fs27.chmodSync(helper, stat4.mode | 493);
12107
+ fs22.chmodSync(helper, stat4.mode | 493);
11626
12108
  logFn?.(`Fixed spawn-helper permissions: ${helper}`);
11627
12109
  }
11628
12110
  }
@@ -12095,8 +12577,8 @@ var init_pty_transport = __esm({
12095
12577
  let cwd = options.cwd;
12096
12578
  if (cwd) {
12097
12579
  try {
12098
- const fs27 = require("fs");
12099
- const stat4 = fs27.statSync(cwd);
12580
+ const fs22 = require("fs");
12581
+ const stat4 = fs22.statSync(cwd);
12100
12582
  if (!stat4.isDirectory()) cwd = os10.homedir();
12101
12583
  } catch {
12102
12584
  cwd = os10.homedir();
@@ -12194,12 +12676,12 @@ function findBinary(name) {
12194
12676
  function isScriptBinary(binaryPath) {
12195
12677
  if (!path10.isAbsolute(binaryPath)) return false;
12196
12678
  try {
12197
- const fs27 = require("fs");
12198
- const resolved = fs27.realpathSync(binaryPath);
12679
+ const fs22 = require("fs");
12680
+ const resolved = fs22.realpathSync(binaryPath);
12199
12681
  const head = Buffer.alloc(8);
12200
- const fd = fs27.openSync(resolved, "r");
12201
- fs27.readSync(fd, head, 0, 8, 0);
12202
- fs27.closeSync(fd);
12682
+ const fd = fs22.openSync(resolved, "r");
12683
+ fs22.readSync(fd, head, 0, 8, 0);
12684
+ fs22.closeSync(fd);
12203
12685
  let i = 0;
12204
12686
  if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
12205
12687
  return head[i] === 35 && head[i + 1] === 33;
@@ -12210,12 +12692,12 @@ function isScriptBinary(binaryPath) {
12210
12692
  function looksLikeMachOOrElf(filePath) {
12211
12693
  if (!path10.isAbsolute(filePath)) return false;
12212
12694
  try {
12213
- const fs27 = require("fs");
12214
- const resolved = fs27.realpathSync(filePath);
12695
+ const fs22 = require("fs");
12696
+ const resolved = fs22.realpathSync(filePath);
12215
12697
  const buf = Buffer.alloc(8);
12216
- const fd = fs27.openSync(resolved, "r");
12217
- fs27.readSync(fd, buf, 0, 8, 0);
12218
- fs27.closeSync(fd);
12698
+ const fd = fs22.openSync(resolved, "r");
12699
+ fs22.readSync(fd, buf, 0, 8, 0);
12700
+ fs22.closeSync(fd);
12219
12701
  let i = 0;
12220
12702
  if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
12221
12703
  const b = buf.subarray(i);
@@ -12775,7 +13257,8 @@ __export(provider_cli_adapter_exports, {
12775
13257
  ProviderCliAdapter: () => ProviderCliAdapter,
12776
13258
  appendBoundedText: () => appendBoundedText,
12777
13259
  normalizeCliProviderForRuntime: () => normalizeCliProviderForRuntime,
12778
- sanitizeCliStandardMessageContent: () => sanitizeCliStandardMessageContent
13260
+ sanitizeCliStandardMessageContent: () => sanitizeCliStandardMessageContent,
13261
+ trimLastAssistantEchoForCliMessages: () => trimLastAssistantEchoForCliMessages
12779
13262
  });
12780
13263
  function normalizeComparableTranscriptText(value) {
12781
13264
  return sanitizeTerminalText(String(value || "")).replace(/\s+/g, " ").trim();
@@ -12871,6 +13354,19 @@ function sanitizeCommittedMessageForDisplay(message) {
12871
13354
  if (content === message.content) return message;
12872
13355
  return { ...message, content };
12873
13356
  }
13357
+ function trimLastAssistantEchoForCliMessages(messages, prompt2) {
13358
+ if (!prompt2) return;
13359
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
13360
+ const message = messages[index];
13361
+ if (!message || message.role !== "assistant" || typeof message.content !== "string") continue;
13362
+ if ((message.kind || "standard") !== "standard") continue;
13363
+ message.content = trimPromptEchoPrefix(message.content, prompt2);
13364
+ if (!message.content.trim()) {
13365
+ messages.splice(index, 1);
13366
+ }
13367
+ return;
13368
+ }
13369
+ }
12874
13370
  var os13, COMMITTED_ACTIVITY_PREFIX_BLOCK_RE, ProviderCliAdapter;
12875
13371
  var init_provider_cli_adapter = __esm({
12876
13372
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
@@ -13068,7 +13564,14 @@ var init_provider_cli_adapter = __esm({
13068
13564
  }
13069
13565
  return null;
13070
13566
  }
13567
+ providerOwnsTranscript() {
13568
+ return this.provider.transcriptAuthority === "provider";
13569
+ }
13570
+ shouldUseFullProviderTranscriptContext() {
13571
+ return this.providerOwnsTranscript() && this.provider.transcriptContext === "full";
13572
+ }
13071
13573
  selectParseBaseMessages(baseMessages) {
13574
+ if (this.shouldUseFullProviderTranscriptContext()) return baseMessages;
13072
13575
  if (baseMessages.length <= _ProviderCliAdapter.PARSE_MESSAGE_TAIL_LIMIT) return baseMessages;
13073
13576
  return baseMessages.slice(-_ProviderCliAdapter.PARSE_MESSAGE_TAIL_LIMIT);
13074
13577
  }
@@ -13551,9 +14054,7 @@ var init_provider_cli_adapter = __esm({
13551
14054
  );
13552
14055
  }
13553
14056
  trimLastAssistantEcho(messages, prompt2) {
13554
- if (!prompt2) return;
13555
- const last = [...messages].reverse().find((m) => m.role === "assistant" && typeof m.content === "string");
13556
- if (last) last.content = trimPromptEchoPrefix(last.content, prompt2);
14057
+ trimLastAssistantEchoForCliMessages(messages, prompt2);
13557
14058
  }
13558
14059
  clearAllTimers() {
13559
14060
  if (this.responseTimeout) {
@@ -14407,7 +14908,8 @@ var init_provider_cli_adapter = __esm({
14407
14908
  title: parsed.title || this.cliName,
14408
14909
  messages: hydratedMessages,
14409
14910
  activeModal: parsed.activeModal ?? this.activeModal,
14410
- providerSessionId: typeof parsed.providerSessionId === "string" ? parsed.providerSessionId : void 0
14911
+ providerSessionId: typeof parsed.providerSessionId === "string" ? parsed.providerSessionId : void 0,
14912
+ ...this.providerOwnsTranscript() ? { transcriptAuthority: "provider", coverage: this.shouldUseFullProviderTranscriptContext() ? "full" : "tail" } : {}
14411
14913
  };
14412
14914
  } else {
14413
14915
  const messages = [...this.committedMessages];
@@ -15299,6 +15801,8 @@ var init_cli_provider_instance = __esm({
15299
15801
  lastCanonicalHermesWatchPath = void 0;
15300
15802
  lastCanonicalClaudeRebuildMtimeMs = 0;
15301
15803
  lastCanonicalClaudeCheckAt = 0;
15804
+ lastCanonicalCodexRebuildMtimeMs = 0;
15805
+ lastCanonicalCodexCheckAt = 0;
15302
15806
  cachedSqliteDb = null;
15303
15807
  cachedSqliteDbPath = null;
15304
15808
  cachedSqliteDbMissingUntil = 0;
@@ -15998,6 +16502,25 @@ ${effect.notification.body || ""}`.trim();
15998
16502
  if (!this.providerSessionId) return false;
15999
16503
  const canonicalHistory = this.provider.canonicalHistory;
16000
16504
  if (!canonicalHistory) return false;
16505
+ if (isNativeSourceCanonicalHistory(canonicalHistory)) {
16506
+ const restoredHistory = readProviderChatHistory(this.type, {
16507
+ canonicalHistory,
16508
+ historySessionId: this.providerSessionId,
16509
+ workspace: this.workingDir,
16510
+ offset: 0,
16511
+ limit: Number.MAX_SAFE_INTEGER,
16512
+ historyBehavior: this.provider.historyBehavior
16513
+ });
16514
+ if (restoredHistory.source !== "provider-native") return false;
16515
+ this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
16516
+ role: message.role,
16517
+ content: message.content,
16518
+ kind: message.kind,
16519
+ senderName: message.senderName,
16520
+ receivedAt: message.receivedAt
16521
+ }));
16522
+ return true;
16523
+ }
16001
16524
  try {
16002
16525
  let rebuilt = false;
16003
16526
  if (canonicalHistory.format === "hermes-json") {
@@ -16031,6 +16554,23 @@ ${effect.notification.body || ""}`.trim();
16031
16554
  if (transcriptMtime > 0 && transcriptMtime <= this.lastCanonicalClaudeRebuildMtimeMs) return true;
16032
16555
  rebuilt = rebuildClaudeSavedHistoryFromNativeProject(this.providerSessionId, this.workingDir);
16033
16556
  if (rebuilt) this.lastCanonicalClaudeRebuildMtimeMs = transcriptMtime || Date.now();
16557
+ } else if (canonicalHistory.format === "codex-jsonl") {
16558
+ const now = Date.now();
16559
+ if (now - this.lastCanonicalCodexCheckAt < 2e3 && this.lastCanonicalCodexRebuildMtimeMs !== 0) {
16560
+ return true;
16561
+ }
16562
+ this.lastCanonicalCodexCheckAt = now;
16563
+ const transcriptFile = resolveCodexSessionTranscriptPath(this.providerSessionId, this.workingDir);
16564
+ let transcriptMtime = 0;
16565
+ if (transcriptFile) {
16566
+ try {
16567
+ transcriptMtime = fs5.statSync(transcriptFile).mtimeMs;
16568
+ } catch {
16569
+ }
16570
+ }
16571
+ if (transcriptMtime > 0 && transcriptMtime <= this.lastCanonicalCodexRebuildMtimeMs) return true;
16572
+ rebuilt = rebuildCodexSavedHistoryFromNativeSession(this.providerSessionId, this.workingDir);
16573
+ if (rebuilt) this.lastCanonicalCodexRebuildMtimeMs = transcriptMtime || Date.now();
16034
16574
  }
16035
16575
  if (!rebuilt) return false;
16036
16576
  const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId, 0, this.provider.historyBehavior);
@@ -16049,8 +16589,17 @@ ${effect.notification.body || ""}`.trim();
16049
16589
  restorePersistedHistoryFromCurrentSession() {
16050
16590
  if (!this.providerSessionId) return;
16051
16591
  this.syncCanonicalSavedHistoryIfNeeded();
16052
- this.historyWriter.compactHistorySession(this.type, this.providerSessionId, this.provider.historyBehavior);
16053
- const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId, 0, this.provider.historyBehavior);
16592
+ const restoredHistory = isNativeSourceCanonicalHistory(this.provider.canonicalHistory) ? readProviderChatHistory(this.type, {
16593
+ canonicalHistory: this.provider.canonicalHistory,
16594
+ historySessionId: this.providerSessionId,
16595
+ workspace: this.workingDir,
16596
+ offset: 0,
16597
+ limit: Number.MAX_SAFE_INTEGER,
16598
+ historyBehavior: this.provider.historyBehavior
16599
+ }) : (() => {
16600
+ this.historyWriter.compactHistorySession(this.type, this.providerSessionId, this.provider.historyBehavior);
16601
+ return readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId, 0, this.provider.historyBehavior);
16602
+ })();
16054
16603
  this.historyWriter.seedSessionHistory(
16055
16604
  this.type,
16056
16605
  restoredHistory.messages,
@@ -16377,10 +16926,10 @@ function mergeDefs(...defs) {
16377
16926
  function cloneDef(schema) {
16378
16927
  return mergeDefs(schema._zod.def);
16379
16928
  }
16380
- function getElementAtPath(obj, path36) {
16381
- if (!path36)
16929
+ function getElementAtPath(obj, path35) {
16930
+ if (!path35)
16382
16931
  return obj;
16383
- return path36.reduce((acc, key) => acc?.[key], obj);
16932
+ return path35.reduce((acc, key) => acc?.[key], obj);
16384
16933
  }
16385
16934
  function promiseAllObject(promisesObj) {
16386
16935
  const keys = Object.keys(promisesObj);
@@ -16692,11 +17241,11 @@ function aborted(x, startIndex = 0) {
16692
17241
  }
16693
17242
  return false;
16694
17243
  }
16695
- function prefixIssues(path36, issues) {
17244
+ function prefixIssues(path35, issues) {
16696
17245
  return issues.map((iss) => {
16697
17246
  var _a2;
16698
17247
  (_a2 = iss).path ?? (_a2.path = []);
16699
- iss.path.unshift(path36);
17248
+ iss.path.unshift(path35);
16700
17249
  return iss;
16701
17250
  });
16702
17251
  }
@@ -16939,7 +17488,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
16939
17488
  }
16940
17489
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
16941
17490
  const result = { errors: [] };
16942
- const processError = (error49, path36 = []) => {
17491
+ const processError = (error49, path35 = []) => {
16943
17492
  var _a2, _b;
16944
17493
  for (const issue2 of error49.issues) {
16945
17494
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -16949,7 +17498,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
16949
17498
  } else if (issue2.code === "invalid_element") {
16950
17499
  processError({ issues: issue2.issues }, issue2.path);
16951
17500
  } else {
16952
- const fullpath = [...path36, ...issue2.path];
17501
+ const fullpath = [...path35, ...issue2.path];
16953
17502
  if (fullpath.length === 0) {
16954
17503
  result.errors.push(mapper(issue2));
16955
17504
  continue;
@@ -16981,8 +17530,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
16981
17530
  }
16982
17531
  function toDotPath(_path) {
16983
17532
  const segs = [];
16984
- const path36 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
16985
- for (const seg of path36) {
17533
+ const path35 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
17534
+ for (const seg of path35) {
16986
17535
  if (typeof seg === "number")
16987
17536
  segs.push(`[${seg}]`);
16988
17537
  else if (typeof seg === "symbol")
@@ -29746,13 +30295,13 @@ function resolveRef(ref, ctx) {
29746
30295
  if (!ref.startsWith("#")) {
29747
30296
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
29748
30297
  }
29749
- const path36 = ref.slice(1).split("/").filter(Boolean);
29750
- if (path36.length === 0) {
30298
+ const path35 = ref.slice(1).split("/").filter(Boolean);
30299
+ if (path35.length === 0) {
29751
30300
  return ctx.rootSchema;
29752
30301
  }
29753
30302
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
29754
- if (path36[0] === defsKey) {
29755
- const key = path36[1];
30303
+ if (path35[0] === defsKey) {
30304
+ const key = path35[1];
29756
30305
  if (!key || !ctx.defs[key]) {
29757
30306
  throw new Error(`Reference not found: ${ref}`);
29758
30307
  }
@@ -34506,7 +35055,7 @@ var init_readdirp = __esm({
34506
35055
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
34507
35056
  const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
34508
35057
  if (wantBigintFsStats) {
34509
- this._stat = (path36) => statMethod(path36, { bigint: true });
35058
+ this._stat = (path35) => statMethod(path35, { bigint: true });
34510
35059
  } else {
34511
35060
  this._stat = statMethod;
34512
35061
  }
@@ -34531,8 +35080,8 @@ var init_readdirp = __esm({
34531
35080
  const par = this.parent;
34532
35081
  const fil = par && par.files;
34533
35082
  if (fil && fil.length > 0) {
34534
- const { path: path36, depth } = par;
34535
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path36));
35083
+ const { path: path35, depth } = par;
35084
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path35));
34536
35085
  const awaited = await Promise.all(slice);
34537
35086
  for (const entry of awaited) {
34538
35087
  if (!entry)
@@ -34572,21 +35121,21 @@ var init_readdirp = __esm({
34572
35121
  this.reading = false;
34573
35122
  }
34574
35123
  }
34575
- async _exploreDir(path36, depth) {
35124
+ async _exploreDir(path35, depth) {
34576
35125
  let files;
34577
35126
  try {
34578
- files = await (0, import_promises.readdir)(path36, this._rdOptions);
35127
+ files = await (0, import_promises.readdir)(path35, this._rdOptions);
34579
35128
  } catch (error48) {
34580
35129
  this._onError(error48);
34581
35130
  }
34582
- return { files, depth, path: path36 };
35131
+ return { files, depth, path: path35 };
34583
35132
  }
34584
- async _formatEntry(dirent, path36) {
35133
+ async _formatEntry(dirent, path35) {
34585
35134
  let entry;
34586
- const basename10 = this._isDirent ? dirent.name : dirent;
35135
+ const basename11 = this._isDirent ? dirent.name : dirent;
34587
35136
  try {
34588
- const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path36, basename10));
34589
- entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename10 };
35137
+ const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path35, basename11));
35138
+ entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename11 };
34590
35139
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
34591
35140
  } catch (err) {
34592
35141
  this._onError(err);
@@ -34642,16 +35191,16 @@ var init_readdirp = __esm({
34642
35191
  });
34643
35192
 
34644
35193
  // ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
34645
- function createFsWatchInstance(path36, options, listener, errHandler, emitRaw) {
35194
+ function createFsWatchInstance(path35, options, listener, errHandler, emitRaw) {
34646
35195
  const handleEvent = (rawEvent, evPath) => {
34647
- listener(path36);
34648
- emitRaw(rawEvent, evPath, { watchedPath: path36 });
34649
- if (evPath && path36 !== evPath) {
34650
- fsWatchBroadcast(sp.resolve(path36, evPath), KEY_LISTENERS, sp.join(path36, evPath));
35196
+ listener(path35);
35197
+ emitRaw(rawEvent, evPath, { watchedPath: path35 });
35198
+ if (evPath && path35 !== evPath) {
35199
+ fsWatchBroadcast(sp.resolve(path35, evPath), KEY_LISTENERS, sp.join(path35, evPath));
34651
35200
  }
34652
35201
  };
34653
35202
  try {
34654
- return (0, import_node_fs.watch)(path36, {
35203
+ return (0, import_node_fs.watch)(path35, {
34655
35204
  persistent: options.persistent
34656
35205
  }, handleEvent);
34657
35206
  } catch (error48) {
@@ -35000,12 +35549,12 @@ var init_handler2 = __esm({
35000
35549
  listener(val1, val2, val3);
35001
35550
  });
35002
35551
  };
35003
- setFsWatchListener = (path36, fullPath, options, handlers) => {
35552
+ setFsWatchListener = (path35, fullPath, options, handlers) => {
35004
35553
  const { listener, errHandler, rawEmitter } = handlers;
35005
35554
  let cont = FsWatchInstances.get(fullPath);
35006
35555
  let watcher;
35007
35556
  if (!options.persistent) {
35008
- watcher = createFsWatchInstance(path36, options, listener, errHandler, rawEmitter);
35557
+ watcher = createFsWatchInstance(path35, options, listener, errHandler, rawEmitter);
35009
35558
  if (!watcher)
35010
35559
  return;
35011
35560
  return watcher.close.bind(watcher);
@@ -35016,7 +35565,7 @@ var init_handler2 = __esm({
35016
35565
  addAndConvert(cont, KEY_RAW, rawEmitter);
35017
35566
  } else {
35018
35567
  watcher = createFsWatchInstance(
35019
- path36,
35568
+ path35,
35020
35569
  options,
35021
35570
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
35022
35571
  errHandler,
@@ -35031,7 +35580,7 @@ var init_handler2 = __esm({
35031
35580
  cont.watcherUnusable = true;
35032
35581
  if (isWindows && error48.code === "EPERM") {
35033
35582
  try {
35034
- const fd = await (0, import_promises2.open)(path36, "r");
35583
+ const fd = await (0, import_promises2.open)(path35, "r");
35035
35584
  await fd.close();
35036
35585
  broadcastErr(error48);
35037
35586
  } catch (err) {
@@ -35062,7 +35611,7 @@ var init_handler2 = __esm({
35062
35611
  };
35063
35612
  };
35064
35613
  FsWatchFileInstances = /* @__PURE__ */ new Map();
35065
- setFsWatchFileListener = (path36, fullPath, options, handlers) => {
35614
+ setFsWatchFileListener = (path35, fullPath, options, handlers) => {
35066
35615
  const { listener, rawEmitter } = handlers;
35067
35616
  let cont = FsWatchFileInstances.get(fullPath);
35068
35617
  const copts = cont && cont.options;
@@ -35084,7 +35633,7 @@ var init_handler2 = __esm({
35084
35633
  });
35085
35634
  const currmtime = curr.mtimeMs;
35086
35635
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
35087
- foreach(cont.listeners, (listener2) => listener2(path36, curr));
35636
+ foreach(cont.listeners, (listener2) => listener2(path35, curr));
35088
35637
  }
35089
35638
  })
35090
35639
  };
@@ -35114,13 +35663,13 @@ var init_handler2 = __esm({
35114
35663
  * @param listener on fs change
35115
35664
  * @returns closer for the watcher instance
35116
35665
  */
35117
- _watchWithNodeFs(path36, listener) {
35666
+ _watchWithNodeFs(path35, listener) {
35118
35667
  const opts = this.fsw.options;
35119
- const directory = sp.dirname(path36);
35120
- const basename10 = sp.basename(path36);
35668
+ const directory = sp.dirname(path35);
35669
+ const basename11 = sp.basename(path35);
35121
35670
  const parent = this.fsw._getWatchedDir(directory);
35122
- parent.add(basename10);
35123
- const absolutePath = sp.resolve(path36);
35671
+ parent.add(basename11);
35672
+ const absolutePath = sp.resolve(path35);
35124
35673
  const options = {
35125
35674
  persistent: opts.persistent
35126
35675
  };
@@ -35129,13 +35678,13 @@ var init_handler2 = __esm({
35129
35678
  let closer;
35130
35679
  if (opts.usePolling) {
35131
35680
  const enableBin = opts.interval !== opts.binaryInterval;
35132
- options.interval = enableBin && isBinaryPath(basename10) ? opts.binaryInterval : opts.interval;
35133
- closer = setFsWatchFileListener(path36, absolutePath, options, {
35681
+ options.interval = enableBin && isBinaryPath(basename11) ? opts.binaryInterval : opts.interval;
35682
+ closer = setFsWatchFileListener(path35, absolutePath, options, {
35134
35683
  listener,
35135
35684
  rawEmitter: this.fsw._emitRaw
35136
35685
  });
35137
35686
  } else {
35138
- closer = setFsWatchListener(path36, absolutePath, options, {
35687
+ closer = setFsWatchListener(path35, absolutePath, options, {
35139
35688
  listener,
35140
35689
  errHandler: this._boundHandleError,
35141
35690
  rawEmitter: this.fsw._emitRaw
@@ -35152,12 +35701,12 @@ var init_handler2 = __esm({
35152
35701
  return;
35153
35702
  }
35154
35703
  const dirname11 = sp.dirname(file2);
35155
- const basename10 = sp.basename(file2);
35704
+ const basename11 = sp.basename(file2);
35156
35705
  const parent = this.fsw._getWatchedDir(dirname11);
35157
35706
  let prevStats = stats;
35158
- if (parent.has(basename10))
35707
+ if (parent.has(basename11))
35159
35708
  return;
35160
- const listener = async (path36, newStats) => {
35709
+ const listener = async (path35, newStats) => {
35161
35710
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
35162
35711
  return;
35163
35712
  if (!newStats || newStats.mtimeMs === 0) {
@@ -35171,18 +35720,18 @@ var init_handler2 = __esm({
35171
35720
  this.fsw._emit(EV.CHANGE, file2, newStats2);
35172
35721
  }
35173
35722
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
35174
- this.fsw._closeFile(path36);
35723
+ this.fsw._closeFile(path35);
35175
35724
  prevStats = newStats2;
35176
35725
  const closer2 = this._watchWithNodeFs(file2, listener);
35177
35726
  if (closer2)
35178
- this.fsw._addPathCloser(path36, closer2);
35727
+ this.fsw._addPathCloser(path35, closer2);
35179
35728
  } else {
35180
35729
  prevStats = newStats2;
35181
35730
  }
35182
35731
  } catch (error48) {
35183
- this.fsw._remove(dirname11, basename10);
35732
+ this.fsw._remove(dirname11, basename11);
35184
35733
  }
35185
- } else if (parent.has(basename10)) {
35734
+ } else if (parent.has(basename11)) {
35186
35735
  const at = newStats.atimeMs;
35187
35736
  const mt = newStats.mtimeMs;
35188
35737
  if (!at || at <= mt || mt !== prevStats.mtimeMs) {
@@ -35207,7 +35756,7 @@ var init_handler2 = __esm({
35207
35756
  * @param item basename of this item
35208
35757
  * @returns true if no more processing is needed for this entry.
35209
35758
  */
35210
- async _handleSymlink(entry, directory, path36, item) {
35759
+ async _handleSymlink(entry, directory, path35, item) {
35211
35760
  if (this.fsw.closed) {
35212
35761
  return;
35213
35762
  }
@@ -35217,7 +35766,7 @@ var init_handler2 = __esm({
35217
35766
  this.fsw._incrReadyCount();
35218
35767
  let linkPath;
35219
35768
  try {
35220
- linkPath = await (0, import_promises2.realpath)(path36);
35769
+ linkPath = await (0, import_promises2.realpath)(path35);
35221
35770
  } catch (e) {
35222
35771
  this.fsw._emitReady();
35223
35772
  return true;
@@ -35227,12 +35776,12 @@ var init_handler2 = __esm({
35227
35776
  if (dir.has(item)) {
35228
35777
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
35229
35778
  this.fsw._symlinkPaths.set(full, linkPath);
35230
- this.fsw._emit(EV.CHANGE, path36, entry.stats);
35779
+ this.fsw._emit(EV.CHANGE, path35, entry.stats);
35231
35780
  }
35232
35781
  } else {
35233
35782
  dir.add(item);
35234
35783
  this.fsw._symlinkPaths.set(full, linkPath);
35235
- this.fsw._emit(EV.ADD, path36, entry.stats);
35784
+ this.fsw._emit(EV.ADD, path35, entry.stats);
35236
35785
  }
35237
35786
  this.fsw._emitReady();
35238
35787
  return true;
@@ -35262,9 +35811,9 @@ var init_handler2 = __esm({
35262
35811
  return;
35263
35812
  }
35264
35813
  const item = entry.path;
35265
- let path36 = sp.join(directory, item);
35814
+ let path35 = sp.join(directory, item);
35266
35815
  current.add(item);
35267
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path36, item)) {
35816
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path35, item)) {
35268
35817
  return;
35269
35818
  }
35270
35819
  if (this.fsw.closed) {
@@ -35273,8 +35822,8 @@ var init_handler2 = __esm({
35273
35822
  }
35274
35823
  if (item === target || !target && !previous.has(item)) {
35275
35824
  this.fsw._incrReadyCount();
35276
- path36 = sp.join(dir, sp.relative(dir, path36));
35277
- this._addToNodeFs(path36, initialAdd, wh, depth + 1);
35825
+ path35 = sp.join(dir, sp.relative(dir, path35));
35826
+ this._addToNodeFs(path35, initialAdd, wh, depth + 1);
35278
35827
  }
35279
35828
  }).on(EV.ERROR, this._boundHandleError);
35280
35829
  return new Promise((resolve18, reject) => {
@@ -35343,13 +35892,13 @@ var init_handler2 = __esm({
35343
35892
  * @param depth Child path actually targeted for watch
35344
35893
  * @param target Child path actually targeted for watch
35345
35894
  */
35346
- async _addToNodeFs(path36, initialAdd, priorWh, depth, target) {
35895
+ async _addToNodeFs(path35, initialAdd, priorWh, depth, target) {
35347
35896
  const ready = this.fsw._emitReady;
35348
- if (this.fsw._isIgnored(path36) || this.fsw.closed) {
35897
+ if (this.fsw._isIgnored(path35) || this.fsw.closed) {
35349
35898
  ready();
35350
35899
  return false;
35351
35900
  }
35352
- const wh = this.fsw._getWatchHelpers(path36);
35901
+ const wh = this.fsw._getWatchHelpers(path35);
35353
35902
  if (priorWh) {
35354
35903
  wh.filterPath = (entry) => priorWh.filterPath(entry);
35355
35904
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -35365,8 +35914,8 @@ var init_handler2 = __esm({
35365
35914
  const follow = this.fsw.options.followSymlinks;
35366
35915
  let closer;
35367
35916
  if (stats.isDirectory()) {
35368
- const absPath = sp.resolve(path36);
35369
- const targetPath = follow ? await (0, import_promises2.realpath)(path36) : path36;
35917
+ const absPath = sp.resolve(path35);
35918
+ const targetPath = follow ? await (0, import_promises2.realpath)(path35) : path35;
35370
35919
  if (this.fsw.closed)
35371
35920
  return;
35372
35921
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -35376,29 +35925,29 @@ var init_handler2 = __esm({
35376
35925
  this.fsw._symlinkPaths.set(absPath, targetPath);
35377
35926
  }
35378
35927
  } else if (stats.isSymbolicLink()) {
35379
- const targetPath = follow ? await (0, import_promises2.realpath)(path36) : path36;
35928
+ const targetPath = follow ? await (0, import_promises2.realpath)(path35) : path35;
35380
35929
  if (this.fsw.closed)
35381
35930
  return;
35382
35931
  const parent = sp.dirname(wh.watchPath);
35383
35932
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
35384
35933
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
35385
- closer = await this._handleDir(parent, stats, initialAdd, depth, path36, wh, targetPath);
35934
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path35, wh, targetPath);
35386
35935
  if (this.fsw.closed)
35387
35936
  return;
35388
35937
  if (targetPath !== void 0) {
35389
- this.fsw._symlinkPaths.set(sp.resolve(path36), targetPath);
35938
+ this.fsw._symlinkPaths.set(sp.resolve(path35), targetPath);
35390
35939
  }
35391
35940
  } else {
35392
35941
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
35393
35942
  }
35394
35943
  ready();
35395
35944
  if (closer)
35396
- this.fsw._addPathCloser(path36, closer);
35945
+ this.fsw._addPathCloser(path35, closer);
35397
35946
  return false;
35398
35947
  } catch (error48) {
35399
35948
  if (this.fsw._handleError(error48)) {
35400
35949
  ready();
35401
- return path36;
35950
+ return path35;
35402
35951
  }
35403
35952
  }
35404
35953
  }
@@ -35433,24 +35982,24 @@ function createPattern(matcher) {
35433
35982
  }
35434
35983
  return () => false;
35435
35984
  }
35436
- function normalizePath(path36) {
35437
- if (typeof path36 !== "string")
35985
+ function normalizePath(path35) {
35986
+ if (typeof path35 !== "string")
35438
35987
  throw new Error("string expected");
35439
- path36 = sp2.normalize(path36);
35440
- path36 = path36.replace(/\\/g, "/");
35988
+ path35 = sp2.normalize(path35);
35989
+ path35 = path35.replace(/\\/g, "/");
35441
35990
  let prepend = false;
35442
- if (path36.startsWith("//"))
35991
+ if (path35.startsWith("//"))
35443
35992
  prepend = true;
35444
- path36 = path36.replace(DOUBLE_SLASH_RE, "/");
35993
+ path35 = path35.replace(DOUBLE_SLASH_RE, "/");
35445
35994
  if (prepend)
35446
- path36 = "/" + path36;
35447
- return path36;
35995
+ path35 = "/" + path35;
35996
+ return path35;
35448
35997
  }
35449
35998
  function matchPatterns(patterns, testString, stats) {
35450
- const path36 = normalizePath(testString);
35999
+ const path35 = normalizePath(testString);
35451
36000
  for (let index = 0; index < patterns.length; index++) {
35452
36001
  const pattern = patterns[index];
35453
- if (pattern(path36, stats)) {
36002
+ if (pattern(path35, stats)) {
35454
36003
  return true;
35455
36004
  }
35456
36005
  }
@@ -35513,19 +36062,19 @@ var init_chokidar = __esm({
35513
36062
  }
35514
36063
  return str;
35515
36064
  };
35516
- normalizePathToUnix = (path36) => toUnix(sp2.normalize(toUnix(path36)));
35517
- normalizeIgnored = (cwd = "") => (path36) => {
35518
- if (typeof path36 === "string") {
35519
- return normalizePathToUnix(sp2.isAbsolute(path36) ? path36 : sp2.join(cwd, path36));
36065
+ normalizePathToUnix = (path35) => toUnix(sp2.normalize(toUnix(path35)));
36066
+ normalizeIgnored = (cwd = "") => (path35) => {
36067
+ if (typeof path35 === "string") {
36068
+ return normalizePathToUnix(sp2.isAbsolute(path35) ? path35 : sp2.join(cwd, path35));
35520
36069
  } else {
35521
- return path36;
36070
+ return path35;
35522
36071
  }
35523
36072
  };
35524
- getAbsolutePath = (path36, cwd) => {
35525
- if (sp2.isAbsolute(path36)) {
35526
- return path36;
36073
+ getAbsolutePath = (path35, cwd) => {
36074
+ if (sp2.isAbsolute(path35)) {
36075
+ return path35;
35527
36076
  }
35528
- return sp2.join(cwd, path36);
36077
+ return sp2.join(cwd, path35);
35529
36078
  };
35530
36079
  EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
35531
36080
  DirEntry = class {
@@ -35590,10 +36139,10 @@ var init_chokidar = __esm({
35590
36139
  dirParts;
35591
36140
  followSymlinks;
35592
36141
  statMethod;
35593
- constructor(path36, follow, fsw) {
36142
+ constructor(path35, follow, fsw) {
35594
36143
  this.fsw = fsw;
35595
- const watchPath = path36;
35596
- this.path = path36 = path36.replace(REPLACER_RE, "");
36144
+ const watchPath = path35;
36145
+ this.path = path35 = path35.replace(REPLACER_RE, "");
35597
36146
  this.watchPath = watchPath;
35598
36147
  this.fullWatchPath = sp2.resolve(watchPath);
35599
36148
  this.dirParts = [];
@@ -35733,20 +36282,20 @@ var init_chokidar = __esm({
35733
36282
  this._closePromise = void 0;
35734
36283
  let paths = unifyPaths(paths_);
35735
36284
  if (cwd) {
35736
- paths = paths.map((path36) => {
35737
- const absPath = getAbsolutePath(path36, cwd);
36285
+ paths = paths.map((path35) => {
36286
+ const absPath = getAbsolutePath(path35, cwd);
35738
36287
  return absPath;
35739
36288
  });
35740
36289
  }
35741
- paths.forEach((path36) => {
35742
- this._removeIgnoredPath(path36);
36290
+ paths.forEach((path35) => {
36291
+ this._removeIgnoredPath(path35);
35743
36292
  });
35744
36293
  this._userIgnored = void 0;
35745
36294
  if (!this._readyCount)
35746
36295
  this._readyCount = 0;
35747
36296
  this._readyCount += paths.length;
35748
- Promise.all(paths.map(async (path36) => {
35749
- const res = await this._nodeFsHandler._addToNodeFs(path36, !_internal, void 0, 0, _origAdd);
36297
+ Promise.all(paths.map(async (path35) => {
36298
+ const res = await this._nodeFsHandler._addToNodeFs(path35, !_internal, void 0, 0, _origAdd);
35750
36299
  if (res)
35751
36300
  this._emitReady();
35752
36301
  return res;
@@ -35768,17 +36317,17 @@ var init_chokidar = __esm({
35768
36317
  return this;
35769
36318
  const paths = unifyPaths(paths_);
35770
36319
  const { cwd } = this.options;
35771
- paths.forEach((path36) => {
35772
- if (!sp2.isAbsolute(path36) && !this._closers.has(path36)) {
36320
+ paths.forEach((path35) => {
36321
+ if (!sp2.isAbsolute(path35) && !this._closers.has(path35)) {
35773
36322
  if (cwd)
35774
- path36 = sp2.join(cwd, path36);
35775
- path36 = sp2.resolve(path36);
36323
+ path35 = sp2.join(cwd, path35);
36324
+ path35 = sp2.resolve(path35);
35776
36325
  }
35777
- this._closePath(path36);
35778
- this._addIgnoredPath(path36);
35779
- if (this._watched.has(path36)) {
36326
+ this._closePath(path35);
36327
+ this._addIgnoredPath(path35);
36328
+ if (this._watched.has(path35)) {
35780
36329
  this._addIgnoredPath({
35781
- path: path36,
36330
+ path: path35,
35782
36331
  recursive: true
35783
36332
  });
35784
36333
  }
@@ -35842,38 +36391,38 @@ var init_chokidar = __esm({
35842
36391
  * @param stats arguments to be passed with event
35843
36392
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
35844
36393
  */
35845
- async _emit(event, path36, stats) {
36394
+ async _emit(event, path35, stats) {
35846
36395
  if (this.closed)
35847
36396
  return;
35848
36397
  const opts = this.options;
35849
36398
  if (isWindows)
35850
- path36 = sp2.normalize(path36);
36399
+ path35 = sp2.normalize(path35);
35851
36400
  if (opts.cwd)
35852
- path36 = sp2.relative(opts.cwd, path36);
35853
- const args = [path36];
36401
+ path35 = sp2.relative(opts.cwd, path35);
36402
+ const args = [path35];
35854
36403
  if (stats != null)
35855
36404
  args.push(stats);
35856
36405
  const awf = opts.awaitWriteFinish;
35857
36406
  let pw;
35858
- if (awf && (pw = this._pendingWrites.get(path36))) {
36407
+ if (awf && (pw = this._pendingWrites.get(path35))) {
35859
36408
  pw.lastChange = /* @__PURE__ */ new Date();
35860
36409
  return this;
35861
36410
  }
35862
36411
  if (opts.atomic) {
35863
36412
  if (event === EVENTS.UNLINK) {
35864
- this._pendingUnlinks.set(path36, [event, ...args]);
36413
+ this._pendingUnlinks.set(path35, [event, ...args]);
35865
36414
  setTimeout(() => {
35866
- this._pendingUnlinks.forEach((entry, path37) => {
36415
+ this._pendingUnlinks.forEach((entry, path36) => {
35867
36416
  this.emit(...entry);
35868
36417
  this.emit(EVENTS.ALL, ...entry);
35869
- this._pendingUnlinks.delete(path37);
36418
+ this._pendingUnlinks.delete(path36);
35870
36419
  });
35871
36420
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
35872
36421
  return this;
35873
36422
  }
35874
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path36)) {
36423
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path35)) {
35875
36424
  event = EVENTS.CHANGE;
35876
- this._pendingUnlinks.delete(path36);
36425
+ this._pendingUnlinks.delete(path35);
35877
36426
  }
35878
36427
  }
35879
36428
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -35891,16 +36440,16 @@ var init_chokidar = __esm({
35891
36440
  this.emitWithAll(event, args);
35892
36441
  }
35893
36442
  };
35894
- this._awaitWriteFinish(path36, awf.stabilityThreshold, event, awfEmit);
36443
+ this._awaitWriteFinish(path35, awf.stabilityThreshold, event, awfEmit);
35895
36444
  return this;
35896
36445
  }
35897
36446
  if (event === EVENTS.CHANGE) {
35898
- const isThrottled = !this._throttle(EVENTS.CHANGE, path36, 50);
36447
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path35, 50);
35899
36448
  if (isThrottled)
35900
36449
  return this;
35901
36450
  }
35902
36451
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
35903
- const fullPath = opts.cwd ? sp2.join(opts.cwd, path36) : path36;
36452
+ const fullPath = opts.cwd ? sp2.join(opts.cwd, path35) : path35;
35904
36453
  let stats2;
35905
36454
  try {
35906
36455
  stats2 = await (0, import_promises3.stat)(fullPath);
@@ -35931,23 +36480,23 @@ var init_chokidar = __esm({
35931
36480
  * @param timeout duration of time to suppress duplicate actions
35932
36481
  * @returns tracking object or false if action should be suppressed
35933
36482
  */
35934
- _throttle(actionType, path36, timeout) {
36483
+ _throttle(actionType, path35, timeout) {
35935
36484
  if (!this._throttled.has(actionType)) {
35936
36485
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
35937
36486
  }
35938
36487
  const action = this._throttled.get(actionType);
35939
36488
  if (!action)
35940
36489
  throw new Error("invalid throttle");
35941
- const actionPath = action.get(path36);
36490
+ const actionPath = action.get(path35);
35942
36491
  if (actionPath) {
35943
36492
  actionPath.count++;
35944
36493
  return false;
35945
36494
  }
35946
36495
  let timeoutObject;
35947
36496
  const clear = () => {
35948
- const item = action.get(path36);
36497
+ const item = action.get(path35);
35949
36498
  const count = item ? item.count : 0;
35950
- action.delete(path36);
36499
+ action.delete(path35);
35951
36500
  clearTimeout(timeoutObject);
35952
36501
  if (item)
35953
36502
  clearTimeout(item.timeoutObject);
@@ -35955,7 +36504,7 @@ var init_chokidar = __esm({
35955
36504
  };
35956
36505
  timeoutObject = setTimeout(clear, timeout);
35957
36506
  const thr = { timeoutObject, clear, count: 0 };
35958
- action.set(path36, thr);
36507
+ action.set(path35, thr);
35959
36508
  return thr;
35960
36509
  }
35961
36510
  _incrReadyCount() {
@@ -35969,44 +36518,44 @@ var init_chokidar = __esm({
35969
36518
  * @param event
35970
36519
  * @param awfEmit Callback to be called when ready for event to be emitted.
35971
36520
  */
35972
- _awaitWriteFinish(path36, threshold, event, awfEmit) {
36521
+ _awaitWriteFinish(path35, threshold, event, awfEmit) {
35973
36522
  const awf = this.options.awaitWriteFinish;
35974
36523
  if (typeof awf !== "object")
35975
36524
  return;
35976
36525
  const pollInterval = awf.pollInterval;
35977
36526
  let timeoutHandler;
35978
- let fullPath = path36;
35979
- if (this.options.cwd && !sp2.isAbsolute(path36)) {
35980
- fullPath = sp2.join(this.options.cwd, path36);
36527
+ let fullPath = path35;
36528
+ if (this.options.cwd && !sp2.isAbsolute(path35)) {
36529
+ fullPath = sp2.join(this.options.cwd, path35);
35981
36530
  }
35982
36531
  const now = /* @__PURE__ */ new Date();
35983
36532
  const writes = this._pendingWrites;
35984
36533
  function awaitWriteFinishFn(prevStat) {
35985
36534
  (0, import_node_fs2.stat)(fullPath, (err, curStat) => {
35986
- if (err || !writes.has(path36)) {
36535
+ if (err || !writes.has(path35)) {
35987
36536
  if (err && err.code !== "ENOENT")
35988
36537
  awfEmit(err);
35989
36538
  return;
35990
36539
  }
35991
36540
  const now2 = Number(/* @__PURE__ */ new Date());
35992
36541
  if (prevStat && curStat.size !== prevStat.size) {
35993
- writes.get(path36).lastChange = now2;
36542
+ writes.get(path35).lastChange = now2;
35994
36543
  }
35995
- const pw = writes.get(path36);
36544
+ const pw = writes.get(path35);
35996
36545
  const df = now2 - pw.lastChange;
35997
36546
  if (df >= threshold) {
35998
- writes.delete(path36);
36547
+ writes.delete(path35);
35999
36548
  awfEmit(void 0, curStat);
36000
36549
  } else {
36001
36550
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
36002
36551
  }
36003
36552
  });
36004
36553
  }
36005
- if (!writes.has(path36)) {
36006
- writes.set(path36, {
36554
+ if (!writes.has(path35)) {
36555
+ writes.set(path35, {
36007
36556
  lastChange: now,
36008
36557
  cancelWait: () => {
36009
- writes.delete(path36);
36558
+ writes.delete(path35);
36010
36559
  clearTimeout(timeoutHandler);
36011
36560
  return event;
36012
36561
  }
@@ -36017,8 +36566,8 @@ var init_chokidar = __esm({
36017
36566
  /**
36018
36567
  * Determines whether user has asked to ignore this path.
36019
36568
  */
36020
- _isIgnored(path36, stats) {
36021
- if (this.options.atomic && DOT_RE.test(path36))
36569
+ _isIgnored(path35, stats) {
36570
+ if (this.options.atomic && DOT_RE.test(path35))
36022
36571
  return true;
36023
36572
  if (!this._userIgnored) {
36024
36573
  const { cwd } = this.options;
@@ -36028,17 +36577,17 @@ var init_chokidar = __esm({
36028
36577
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
36029
36578
  this._userIgnored = anymatch(list, void 0);
36030
36579
  }
36031
- return this._userIgnored(path36, stats);
36580
+ return this._userIgnored(path35, stats);
36032
36581
  }
36033
- _isntIgnored(path36, stat4) {
36034
- return !this._isIgnored(path36, stat4);
36582
+ _isntIgnored(path35, stat4) {
36583
+ return !this._isIgnored(path35, stat4);
36035
36584
  }
36036
36585
  /**
36037
36586
  * Provides a set of common helpers and properties relating to symlink handling.
36038
36587
  * @param path file or directory pattern being watched
36039
36588
  */
36040
- _getWatchHelpers(path36) {
36041
- return new WatchHelper(path36, this.options.followSymlinks, this);
36589
+ _getWatchHelpers(path35) {
36590
+ return new WatchHelper(path35, this.options.followSymlinks, this);
36042
36591
  }
36043
36592
  // Directory helpers
36044
36593
  // -----------------
@@ -36070,63 +36619,63 @@ var init_chokidar = __esm({
36070
36619
  * @param item base path of item/directory
36071
36620
  */
36072
36621
  _remove(directory, item, isDirectory) {
36073
- const path36 = sp2.join(directory, item);
36074
- const fullPath = sp2.resolve(path36);
36075
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path36) || this._watched.has(fullPath);
36076
- if (!this._throttle("remove", path36, 100))
36622
+ const path35 = sp2.join(directory, item);
36623
+ const fullPath = sp2.resolve(path35);
36624
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path35) || this._watched.has(fullPath);
36625
+ if (!this._throttle("remove", path35, 100))
36077
36626
  return;
36078
36627
  if (!isDirectory && this._watched.size === 1) {
36079
36628
  this.add(directory, item, true);
36080
36629
  }
36081
- const wp = this._getWatchedDir(path36);
36630
+ const wp = this._getWatchedDir(path35);
36082
36631
  const nestedDirectoryChildren = wp.getChildren();
36083
- nestedDirectoryChildren.forEach((nested) => this._remove(path36, nested));
36632
+ nestedDirectoryChildren.forEach((nested) => this._remove(path35, nested));
36084
36633
  const parent = this._getWatchedDir(directory);
36085
36634
  const wasTracked = parent.has(item);
36086
36635
  parent.remove(item);
36087
36636
  if (this._symlinkPaths.has(fullPath)) {
36088
36637
  this._symlinkPaths.delete(fullPath);
36089
36638
  }
36090
- let relPath = path36;
36639
+ let relPath = path35;
36091
36640
  if (this.options.cwd)
36092
- relPath = sp2.relative(this.options.cwd, path36);
36641
+ relPath = sp2.relative(this.options.cwd, path35);
36093
36642
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
36094
36643
  const event = this._pendingWrites.get(relPath).cancelWait();
36095
36644
  if (event === EVENTS.ADD)
36096
36645
  return;
36097
36646
  }
36098
- this._watched.delete(path36);
36647
+ this._watched.delete(path35);
36099
36648
  this._watched.delete(fullPath);
36100
36649
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
36101
- if (wasTracked && !this._isIgnored(path36))
36102
- this._emit(eventName, path36);
36103
- this._closePath(path36);
36650
+ if (wasTracked && !this._isIgnored(path35))
36651
+ this._emit(eventName, path35);
36652
+ this._closePath(path35);
36104
36653
  }
36105
36654
  /**
36106
36655
  * Closes all watchers for a path
36107
36656
  */
36108
- _closePath(path36) {
36109
- this._closeFile(path36);
36110
- const dir = sp2.dirname(path36);
36111
- this._getWatchedDir(dir).remove(sp2.basename(path36));
36657
+ _closePath(path35) {
36658
+ this._closeFile(path35);
36659
+ const dir = sp2.dirname(path35);
36660
+ this._getWatchedDir(dir).remove(sp2.basename(path35));
36112
36661
  }
36113
36662
  /**
36114
36663
  * Closes only file-specific watchers
36115
36664
  */
36116
- _closeFile(path36) {
36117
- const closers = this._closers.get(path36);
36665
+ _closeFile(path35) {
36666
+ const closers = this._closers.get(path35);
36118
36667
  if (!closers)
36119
36668
  return;
36120
36669
  closers.forEach((closer) => closer());
36121
- this._closers.delete(path36);
36670
+ this._closers.delete(path35);
36122
36671
  }
36123
- _addPathCloser(path36, closer) {
36672
+ _addPathCloser(path35, closer) {
36124
36673
  if (!closer)
36125
36674
  return;
36126
- let list = this._closers.get(path36);
36675
+ let list = this._closers.get(path35);
36127
36676
  if (!list) {
36128
36677
  list = [];
36129
- this._closers.set(path36, list);
36678
+ this._closers.set(path35, list);
36130
36679
  }
36131
36680
  list.push(closer);
36132
36681
  }
@@ -37875,6 +38424,43 @@ var init_provider_loader = __esm({
37875
38424
  }
37876
38425
  });
37877
38426
 
38427
+ // ../../oss/packages/daemon-core/src/launch/macos-app-process.ts
38428
+ function normalizeMacAppPath(appPath) {
38429
+ const trimmed = String(appPath || "").trim();
38430
+ if (!trimmed) return null;
38431
+ return trimmed.replace(/\/+$/, "");
38432
+ }
38433
+ function parsePsLine(line) {
38434
+ const match = line.match(/^\s*(\d+)\s+(.+)$/);
38435
+ if (!match) return null;
38436
+ const pid = Number.parseInt(match[1], 10);
38437
+ if (!Number.isFinite(pid)) return null;
38438
+ return { pid, args: match[2] };
38439
+ }
38440
+ function isMacAppProcessArgs(args, appPath) {
38441
+ const normalized = normalizeMacAppPath(appPath);
38442
+ if (!normalized) return false;
38443
+ return String(args || "").startsWith(`${normalized}/`);
38444
+ }
38445
+ function findMacAppProcessPids(psOutput, appPaths) {
38446
+ const normalizedPaths = appPaths.map(normalizeMacAppPath).filter((value) => !!value);
38447
+ if (normalizedPaths.length === 0) return [];
38448
+ const pids = [];
38449
+ for (const line of String(psOutput || "").split(/\r?\n/)) {
38450
+ const parsed = parsePsLine(line);
38451
+ if (!parsed) continue;
38452
+ if (normalizedPaths.some((appPath) => isMacAppProcessArgs(parsed.args, appPath))) {
38453
+ pids.push(parsed.pid);
38454
+ }
38455
+ }
38456
+ return pids;
38457
+ }
38458
+ var init_macos_app_process = __esm({
38459
+ "../../oss/packages/daemon-core/src/launch/macos-app-process.ts"() {
38460
+ "use strict";
38461
+ }
38462
+ });
38463
+
37878
38464
  // ../../oss/packages/daemon-core/src/launch.ts
37879
38465
  function getProviderLoader() {
37880
38466
  if (!_providerLoader) {
@@ -37897,9 +38483,9 @@ function getWinProcessNames() {
37897
38483
  function getProviderMeta(ideId) {
37898
38484
  return getProviderLoader().getMeta(ideId);
37899
38485
  }
37900
- function getPreferredLaunchMethod(ideId, platform13) {
38486
+ function getPreferredLaunchMethod(ideId, platform12) {
37901
38487
  const prefer = getProviderMeta(ideId)?.launch?.prefer;
37902
- const value = prefer?.[platform13];
38488
+ const value = prefer?.[platform12];
37903
38489
  return value === "cli" || value === "app" || value === "auto" ? value : "auto";
37904
38490
  }
37905
38491
  function getCdpStartupTimeoutMs(ideId) {
@@ -37910,6 +38496,35 @@ function getCdpStartupTimeoutMs(ideId) {
37910
38496
  function escapeForAppleScript(value) {
37911
38497
  return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
37912
38498
  }
38499
+ function getIdePathCandidates(ideId) {
38500
+ return getProviderLoader().getIdePathCandidates(ideId);
38501
+ }
38502
+ function getMacAppProcessPids(ideId) {
38503
+ const appPaths = getIdePathCandidates(ideId);
38504
+ if (appPaths.length === 0) return [];
38505
+ try {
38506
+ const output = (0, import_child_process7.execSync)("ps axww -o pid=,args=", {
38507
+ encoding: "utf-8",
38508
+ timeout: 3e3,
38509
+ stdio: ["pipe", "pipe", "pipe"]
38510
+ });
38511
+ return findMacAppProcessPids(output, appPaths);
38512
+ } catch {
38513
+ return [];
38514
+ }
38515
+ }
38516
+ function killMacAppPathProcesses(ideId, signal) {
38517
+ const pids = getMacAppProcessPids(ideId);
38518
+ let signalled = false;
38519
+ for (const pid of pids) {
38520
+ try {
38521
+ process.kill(pid, signal);
38522
+ signalled = true;
38523
+ } catch {
38524
+ }
38525
+ }
38526
+ return signalled;
38527
+ }
37913
38528
  async function findFreePort(ports) {
37914
38529
  for (const port2 of ports) {
37915
38530
  const free = await checkPortFree(port2);
@@ -37971,6 +38586,7 @@ async function killIdeProcess(ideId) {
37971
38586
  } catch {
37972
38587
  }
37973
38588
  }
38589
+ killMacAppPathProcesses(ideId, "SIGTERM");
37974
38590
  } else if (plat === "win32" && winProcesses) {
37975
38591
  for (const proc of winProcesses) {
37976
38592
  try {
@@ -38000,6 +38616,7 @@ async function killIdeProcess(ideId) {
38000
38616
  (0, import_child_process7.execSync)(`pkill -9 -x "${appName}" 2>/dev/null`, { timeout: 5e3 });
38001
38617
  } catch {
38002
38618
  }
38619
+ killMacAppPathProcesses(ideId, "SIGKILL");
38003
38620
  } else if (plat === "win32" && winProcesses) {
38004
38621
  for (const proc of winProcesses) {
38005
38622
  try {
@@ -38019,14 +38636,16 @@ function isIdeRunning(ideId) {
38019
38636
  try {
38020
38637
  if (plat === "darwin") {
38021
38638
  const appName = getMacAppIdentifiers()[ideId];
38022
- if (!appName) return false;
38639
+ if (!appName) return getMacAppProcessPids(ideId).length > 0;
38023
38640
  try {
38024
38641
  const result = (0, import_child_process7.execSync)(`pgrep -x "${appName}" 2>/dev/null`, {
38025
38642
  encoding: "utf-8",
38026
38643
  timeout: 3e3
38027
38644
  });
38028
- return result.trim().length > 0;
38645
+ if (result.trim().length > 0) return true;
38029
38646
  } catch {
38647
+ }
38648
+ try {
38030
38649
  const result = (0, import_child_process7.execSync)(
38031
38650
  `osascript -e 'tell application "System Events" to count (every process whose name is "${escapeForAppleScript(appName)}")'`,
38032
38651
  {
@@ -38035,8 +38654,10 @@ function isIdeRunning(ideId) {
38035
38654
  stdio: ["pipe", "pipe", "pipe"]
38036
38655
  }
38037
38656
  );
38038
- return Number.parseInt(result.trim() || "0", 10) > 0;
38657
+ if (Number.parseInt(result.trim() || "0", 10) > 0) return true;
38658
+ } catch {
38039
38659
  }
38660
+ return getMacAppProcessPids(ideId).length > 0;
38040
38661
  } else if (plat === "win32") {
38041
38662
  const winProcesses = getWinProcessNames()[ideId];
38042
38663
  if (!winProcesses) return false;
@@ -38081,7 +38702,7 @@ function detectCurrentWorkspace(ideId) {
38081
38702
  }
38082
38703
  } else if (plat === "win32") {
38083
38704
  try {
38084
- const fs27 = require("fs");
38705
+ const fs22 = require("fs");
38085
38706
  const appNameMap = getMacAppIdentifiers();
38086
38707
  const appName = appNameMap[ideId];
38087
38708
  if (appName) {
@@ -38090,8 +38711,8 @@ function detectCurrentWorkspace(ideId) {
38090
38711
  appName,
38091
38712
  "storage.json"
38092
38713
  );
38093
- if (fs27.existsSync(storagePath)) {
38094
- const data = JSON.parse(fs27.readFileSync(storagePath, "utf-8"));
38714
+ if (fs22.existsSync(storagePath)) {
38715
+ const data = JSON.parse(fs22.readFileSync(storagePath, "utf-8"));
38095
38716
  const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
38096
38717
  if (workspaces.length > 0) {
38097
38718
  const recent = workspaces[0];
@@ -38108,7 +38729,7 @@ function detectCurrentWorkspace(ideId) {
38108
38729
  return void 0;
38109
38730
  }
38110
38731
  async function launchWithCdp(options = {}) {
38111
- const platform13 = os17.platform();
38732
+ const platform12 = os17.platform();
38112
38733
  let targetIde;
38113
38734
  const ides = await detectIDEs(getProviderLoader());
38114
38735
  if (options.ideId) {
@@ -38177,9 +38798,9 @@ async function launchWithCdp(options = {}) {
38177
38798
  }
38178
38799
  const port = await findFreePort(portPair);
38179
38800
  try {
38180
- if (platform13 === "darwin") {
38801
+ if (platform12 === "darwin") {
38181
38802
  await launchMacOS(targetIde, port, workspace, options.newWindow);
38182
- } else if (platform13 === "win32") {
38803
+ } else if (platform12 === "win32") {
38183
38804
  await launchWindows(targetIde, port, workspace, options.newWindow);
38184
38805
  } else {
38185
38806
  await launchLinux(targetIde, port, workspace, options.newWindow);
@@ -38267,6 +38888,7 @@ var init_launch = __esm({
38267
38888
  path15 = __toESM(require("path"));
38268
38889
  init_ide_detector();
38269
38890
  init_provider_loader();
38891
+ init_macos_app_process();
38270
38892
  _providerLoader = null;
38271
38893
  }
38272
38894
  });
@@ -39459,13 +40081,18 @@ var init_router = __esm({
39459
40081
  const wantsAll = args?.all === true;
39460
40082
  const offset = wantsAll ? 0 : Math.max(0, Number(args?.offset) || 0);
39461
40083
  const limit = wantsAll ? Number.MAX_SAFE_INTEGER : Math.max(1, Math.min(100, Number(args?.limit) || 30));
39462
- const { sessions: historySessions, hasMore } = listSavedHistorySessions(providerType, { offset, limit });
40084
+ const providerMeta = this.deps.providerLoader.getMeta(providerType);
40085
+ const { sessions: historySessions, hasMore, source } = listProviderHistorySessions(providerType, {
40086
+ canonicalHistory: providerMeta?.canonicalHistory,
40087
+ offset,
40088
+ limit,
40089
+ historyBehavior: providerMeta?.historyBehavior
40090
+ });
39463
40091
  const state = loadState();
39464
40092
  const savedSessions = getSavedProviderSessions(state, { providerType, kind });
39465
40093
  const recentSessions = getRecentActivity(state, 200).filter((entry) => entry.providerType === providerType && entry.kind === kind && entry.providerSessionId);
39466
40094
  const savedSessionById = new Map(savedSessions.map((entry) => [entry.providerSessionId, entry]));
39467
40095
  const recentSessionById = new Map(recentSessions.map((entry) => [entry.providerSessionId, entry]));
39468
- const providerMeta = this.deps.providerLoader.getMeta(providerType);
39469
40096
  const canResumeById = supportsExplicitSessionResume(providerMeta?.resume);
39470
40097
  return {
39471
40098
  success: true,
@@ -39488,7 +40115,8 @@ var init_router = __esm({
39488
40115
  canResume: !!(saved?.workspace || recent?.workspace || session.workspace) && canResumeById
39489
40116
  };
39490
40117
  }),
39491
- hasMore
40118
+ hasMore,
40119
+ source
39492
40120
  };
39493
40121
  }
39494
40122
  // ─── restart_session: IDE / CLI / ACP unified ───
@@ -45524,8 +46152,8 @@ var init_dev_server = __esm({
45524
46152
  }
45525
46153
  getEndpointList() {
45526
46154
  return this.routes.map((r) => {
45527
- const path36 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
45528
- return `${r.method.padEnd(5)} ${path36}`;
46155
+ const path35 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
46156
+ return `${r.method.padEnd(5)} ${path35}`;
45529
46157
  });
45530
46158
  }
45531
46159
  async start(port = DEV_SERVER_PORT) {
@@ -47467,8 +48095,8 @@ async function installExtension(ide, extension) {
47467
48095
  const res = await fetch(extension.vsixUrl);
47468
48096
  if (res.ok) {
47469
48097
  const buffer = Buffer.from(await res.arrayBuffer());
47470
- const fs27 = await import("fs");
47471
- fs27.writeFileSync(vsixPath, buffer);
48098
+ const fs22 = await import("fs");
48099
+ fs22.writeFileSync(vsixPath, buffer);
47472
48100
  return new Promise((resolve18) => {
47473
48101
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
47474
48102
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
@@ -48419,11 +49047,11 @@ var require_yoctocolors_cjs = __commonJS({
48419
49047
  "use strict";
48420
49048
  var tty3 = require("tty");
48421
49049
  var hasColors = tty3?.WriteStream?.prototype?.hasColors?.() ?? false;
48422
- var format = (open3, close) => {
49050
+ var format = (open2, close) => {
48423
49051
  if (!hasColors) {
48424
49052
  return (input) => input;
48425
49053
  }
48426
- const openCode = `\x1B[${open3}m`;
49054
+ const openCode = `\x1B[${open2}m`;
48427
49055
  const closeCode = `\x1B[${close}m`;
48428
49056
  return (input) => {
48429
49057
  const string4 = input + "";
@@ -51961,7 +52589,7 @@ var require_innerFrom = __commonJS({
51961
52589
  exports2.fromIterable = fromIterable;
51962
52590
  function fromAsyncIterable(asyncIterable) {
51963
52591
  return new Observable_1.Observable(function(subscriber) {
51964
- process19(asyncIterable, subscriber).catch(function(err) {
52592
+ process13(asyncIterable, subscriber).catch(function(err) {
51965
52593
  return subscriber.error(err);
51966
52594
  });
51967
52595
  });
@@ -51971,7 +52599,7 @@ var require_innerFrom = __commonJS({
51971
52599
  return fromAsyncIterable(isReadableStreamLike_1.readableStreamLikeToAsyncGenerator(readableStream));
51972
52600
  }
51973
52601
  exports2.fromReadableStreamLike = fromReadableStreamLike;
51974
- function process19(asyncIterable, subscriber) {
52602
+ function process13(asyncIterable, subscriber) {
51975
52603
  var asyncIterable_1, asyncIterable_1_1;
51976
52604
  var e_2, _a2;
51977
52605
  return __awaiter(this, void 0, void 0, function() {
@@ -59630,15 +60258,15 @@ var require_route = __commonJS({
59630
60258
  };
59631
60259
  }
59632
60260
  function wrapConversion(toModel, graph) {
59633
- const path36 = [graph[toModel].parent, toModel];
60261
+ const path35 = [graph[toModel].parent, toModel];
59634
60262
  let fn = conversions[graph[toModel].parent][toModel];
59635
60263
  let cur = graph[toModel].parent;
59636
60264
  while (graph[cur].parent) {
59637
- path36.unshift(graph[cur].parent);
60265
+ path35.unshift(graph[cur].parent);
59638
60266
  fn = link(conversions[graph[cur].parent][cur], fn);
59639
60267
  cur = graph[cur].parent;
59640
60268
  }
59641
- fn.conversion = path36;
60269
+ fn.conversion = path35;
59642
60270
  return fn;
59643
60271
  }
59644
60272
  module2.exports = function(fromModel) {
@@ -60035,7 +60663,7 @@ var require_has_flag = __commonJS({
60035
60663
  var require_supports_color = __commonJS({
60036
60664
  "../../node_modules/supports-color/index.js"(exports2, module2) {
60037
60665
  "use strict";
60038
- var os31 = require("os");
60666
+ var os30 = require("os");
60039
60667
  var tty3 = require("tty");
60040
60668
  var hasFlag3 = require_has_flag();
60041
60669
  var { env: env3 } = process;
@@ -60083,7 +60711,7 @@ var require_supports_color = __commonJS({
60083
60711
  return min;
60084
60712
  }
60085
60713
  if (process.platform === "win32") {
60086
- const osRelease = os31.release().split(".");
60714
+ const osRelease = os30.release().split(".");
60087
60715
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
60088
60716
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
60089
60717
  }
@@ -60384,18 +61012,18 @@ var require_source = __commonJS({
60384
61012
  }
60385
61013
  }
60386
61014
  });
60387
- var createStyler3 = (open3, close, parent) => {
61015
+ var createStyler3 = (open2, close, parent) => {
60388
61016
  let openAll;
60389
61017
  let closeAll;
60390
61018
  if (parent === void 0) {
60391
- openAll = open3;
61019
+ openAll = open2;
60392
61020
  closeAll = close;
60393
61021
  } else {
60394
- openAll = parent.openAll + open3;
61022
+ openAll = parent.openAll + open2;
60395
61023
  closeAll = close + parent.closeAll;
60396
61024
  }
60397
61025
  return {
60398
- open: open3,
61026
+ open: open2,
60399
61027
  close,
60400
61028
  openAll,
60401
61029
  closeAll,
@@ -60559,11 +61187,11 @@ var require_signals = __commonJS({
60559
61187
  var require_signal_exit = __commonJS({
60560
61188
  "../../node_modules/inquirer/node_modules/signal-exit/index.js"(exports2, module2) {
60561
61189
  "use strict";
60562
- var process19 = global.process;
60563
- var processOk2 = function(process20) {
60564
- return process20 && typeof process20 === "object" && typeof process20.removeListener === "function" && typeof process20.emit === "function" && typeof process20.reallyExit === "function" && typeof process20.listeners === "function" && typeof process20.kill === "function" && typeof process20.pid === "number" && typeof process20.on === "function";
61190
+ var process13 = global.process;
61191
+ var processOk2 = function(process14) {
61192
+ return process14 && typeof process14 === "object" && typeof process14.removeListener === "function" && typeof process14.emit === "function" && typeof process14.reallyExit === "function" && typeof process14.listeners === "function" && typeof process14.kill === "function" && typeof process14.pid === "number" && typeof process14.on === "function";
60565
61193
  };
60566
- if (!processOk2(process19)) {
61194
+ if (!processOk2(process13)) {
60567
61195
  module2.exports = function() {
60568
61196
  return function() {
60569
61197
  };
@@ -60571,15 +61199,15 @@ var require_signal_exit = __commonJS({
60571
61199
  } else {
60572
61200
  assert3 = require("assert");
60573
61201
  signals2 = require_signals();
60574
- isWin = /^win/i.test(process19.platform);
61202
+ isWin = /^win/i.test(process13.platform);
60575
61203
  EE = require("events");
60576
61204
  if (typeof EE !== "function") {
60577
61205
  EE = EE.EventEmitter;
60578
61206
  }
60579
- if (process19.__signal_exit_emitter__) {
60580
- emitter = process19.__signal_exit_emitter__;
61207
+ if (process13.__signal_exit_emitter__) {
61208
+ emitter = process13.__signal_exit_emitter__;
60581
61209
  } else {
60582
- emitter = process19.__signal_exit_emitter__ = new EE();
61210
+ emitter = process13.__signal_exit_emitter__ = new EE();
60583
61211
  emitter.count = 0;
60584
61212
  emitter.emitted = {};
60585
61213
  }
@@ -60616,12 +61244,12 @@ var require_signal_exit = __commonJS({
60616
61244
  loaded = false;
60617
61245
  signals2.forEach(function(sig) {
60618
61246
  try {
60619
- process19.removeListener(sig, sigListeners[sig]);
61247
+ process13.removeListener(sig, sigListeners[sig]);
60620
61248
  } catch (er) {
60621
61249
  }
60622
61250
  });
60623
- process19.emit = originalProcessEmit;
60624
- process19.reallyExit = originalProcessReallyExit;
61251
+ process13.emit = originalProcessEmit;
61252
+ process13.reallyExit = originalProcessReallyExit;
60625
61253
  emitter.count -= 1;
60626
61254
  };
60627
61255
  module2.exports.unload = unload2;
@@ -60638,7 +61266,7 @@ var require_signal_exit = __commonJS({
60638
61266
  if (!processOk2(global.process)) {
60639
61267
  return;
60640
61268
  }
60641
- var listeners = process19.listeners(sig);
61269
+ var listeners = process13.listeners(sig);
60642
61270
  if (listeners.length === emitter.count) {
60643
61271
  unload2();
60644
61272
  emit("exit", null, sig);
@@ -60646,7 +61274,7 @@ var require_signal_exit = __commonJS({
60646
61274
  if (isWin && sig === "SIGHUP") {
60647
61275
  sig = "SIGINT";
60648
61276
  }
60649
- process19.kill(process19.pid, sig);
61277
+ process13.kill(process13.pid, sig);
60650
61278
  }
60651
61279
  };
60652
61280
  });
@@ -60662,36 +61290,36 @@ var require_signal_exit = __commonJS({
60662
61290
  emitter.count += 1;
60663
61291
  signals2 = signals2.filter(function(sig) {
60664
61292
  try {
60665
- process19.on(sig, sigListeners[sig]);
61293
+ process13.on(sig, sigListeners[sig]);
60666
61294
  return true;
60667
61295
  } catch (er) {
60668
61296
  return false;
60669
61297
  }
60670
61298
  });
60671
- process19.emit = processEmit;
60672
- process19.reallyExit = processReallyExit;
61299
+ process13.emit = processEmit;
61300
+ process13.reallyExit = processReallyExit;
60673
61301
  };
60674
61302
  module2.exports.load = load2;
60675
- originalProcessReallyExit = process19.reallyExit;
61303
+ originalProcessReallyExit = process13.reallyExit;
60676
61304
  processReallyExit = function processReallyExit2(code) {
60677
61305
  if (!processOk2(global.process)) {
60678
61306
  return;
60679
61307
  }
60680
- process19.exitCode = code || /* istanbul ignore next */
61308
+ process13.exitCode = code || /* istanbul ignore next */
60681
61309
  0;
60682
- emit("exit", process19.exitCode, null);
60683
- emit("afterexit", process19.exitCode, null);
60684
- originalProcessReallyExit.call(process19, process19.exitCode);
61310
+ emit("exit", process13.exitCode, null);
61311
+ emit("afterexit", process13.exitCode, null);
61312
+ originalProcessReallyExit.call(process13, process13.exitCode);
60685
61313
  };
60686
- originalProcessEmit = process19.emit;
61314
+ originalProcessEmit = process13.emit;
60687
61315
  processEmit = function processEmit2(ev, arg) {
60688
61316
  if (ev === "exit" && processOk2(global.process)) {
60689
61317
  if (arg !== void 0) {
60690
- process19.exitCode = arg;
61318
+ process13.exitCode = arg;
60691
61319
  }
60692
61320
  var ret = originalProcessEmit.apply(this, arguments);
60693
- emit("exit", process19.exitCode, null);
60694
- emit("afterexit", process19.exitCode, null);
61321
+ emit("exit", process13.exitCode, null);
61322
+ emit("afterexit", process13.exitCode, null);
60695
61323
  return ret;
60696
61324
  } else {
60697
61325
  return originalProcessEmit.apply(this, arguments);
@@ -62881,12 +63509,12 @@ var require_buffer_list = __commonJS({
62881
63509
  return (hint === "string" ? String : Number)(input);
62882
63510
  }
62883
63511
  var _require = require("buffer");
62884
- var Buffer3 = _require.Buffer;
63512
+ var Buffer2 = _require.Buffer;
62885
63513
  var _require2 = require("util");
62886
63514
  var inspect = _require2.inspect;
62887
63515
  var custom2 = inspect && inspect.custom || "inspect";
62888
63516
  function copyBuffer(src, target, offset) {
62889
- Buffer3.prototype.copy.call(src, target, offset);
63517
+ Buffer2.prototype.copy.call(src, target, offset);
62890
63518
  }
62891
63519
  module2.exports = /* @__PURE__ */ (function() {
62892
63520
  function BufferList() {
@@ -62946,8 +63574,8 @@ var require_buffer_list = __commonJS({
62946
63574
  }, {
62947
63575
  key: "concat",
62948
63576
  value: function concat(n) {
62949
- if (this.length === 0) return Buffer3.alloc(0);
62950
- var ret = Buffer3.allocUnsafe(n >>> 0);
63577
+ if (this.length === 0) return Buffer2.alloc(0);
63578
+ var ret = Buffer2.allocUnsafe(n >>> 0);
62951
63579
  var p = this.head;
62952
63580
  var i = 0;
62953
63581
  while (p) {
@@ -63011,7 +63639,7 @@ var require_buffer_list = __commonJS({
63011
63639
  }, {
63012
63640
  key: "_getBuffer",
63013
63641
  value: function _getBuffer(n) {
63014
- var ret = Buffer3.allocUnsafe(n);
63642
+ var ret = Buffer2.allocUnsafe(n);
63015
63643
  var p = this.head;
63016
63644
  var c = 1;
63017
63645
  p.data.copy(ret);
@@ -63343,14 +63971,14 @@ var require_stream_writable = __commonJS({
63343
63971
  deprecate: require_node()
63344
63972
  };
63345
63973
  var Stream = require_stream();
63346
- var Buffer3 = require("buffer").Buffer;
63974
+ var Buffer2 = require("buffer").Buffer;
63347
63975
  var OurUint8Array = (typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {
63348
63976
  };
63349
63977
  function _uint8ArrayToBuffer(chunk) {
63350
- return Buffer3.from(chunk);
63978
+ return Buffer2.from(chunk);
63351
63979
  }
63352
63980
  function _isUint8Array(obj) {
63353
- return Buffer3.isBuffer(obj) || obj instanceof OurUint8Array;
63981
+ return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array;
63354
63982
  }
63355
63983
  var destroyImpl = require_destroy();
63356
63984
  var _require = require_state();
@@ -63478,7 +64106,7 @@ var require_stream_writable = __commonJS({
63478
64106
  var state = this._writableState;
63479
64107
  var ret = false;
63480
64108
  var isBuf = !state.objectMode && _isUint8Array(chunk);
63481
- if (isBuf && !Buffer3.isBuffer(chunk)) {
64109
+ if (isBuf && !Buffer2.isBuffer(chunk)) {
63482
64110
  chunk = _uint8ArrayToBuffer(chunk);
63483
64111
  }
63484
64112
  if (typeof encoding === "function") {
@@ -63522,7 +64150,7 @@ var require_stream_writable = __commonJS({
63522
64150
  });
63523
64151
  function decodeChunk(state, chunk, encoding) {
63524
64152
  if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") {
63525
- chunk = Buffer3.from(chunk, encoding);
64153
+ chunk = Buffer2.from(chunk, encoding);
63526
64154
  }
63527
64155
  return chunk;
63528
64156
  }
@@ -63893,34 +64521,34 @@ var require_safe_buffer = __commonJS({
63893
64521
  "../../node_modules/safe-buffer/index.js"(exports2, module2) {
63894
64522
  "use strict";
63895
64523
  var buffer = require("buffer");
63896
- var Buffer3 = buffer.Buffer;
64524
+ var Buffer2 = buffer.Buffer;
63897
64525
  function copyProps(src, dst) {
63898
64526
  for (var key in src) {
63899
64527
  dst[key] = src[key];
63900
64528
  }
63901
64529
  }
63902
- if (Buffer3.from && Buffer3.alloc && Buffer3.allocUnsafe && Buffer3.allocUnsafeSlow) {
64530
+ if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) {
63903
64531
  module2.exports = buffer;
63904
64532
  } else {
63905
64533
  copyProps(buffer, exports2);
63906
64534
  exports2.Buffer = SafeBuffer;
63907
64535
  }
63908
64536
  function SafeBuffer(arg, encodingOrOffset, length) {
63909
- return Buffer3(arg, encodingOrOffset, length);
64537
+ return Buffer2(arg, encodingOrOffset, length);
63910
64538
  }
63911
- SafeBuffer.prototype = Object.create(Buffer3.prototype);
63912
- copyProps(Buffer3, SafeBuffer);
64539
+ SafeBuffer.prototype = Object.create(Buffer2.prototype);
64540
+ copyProps(Buffer2, SafeBuffer);
63913
64541
  SafeBuffer.from = function(arg, encodingOrOffset, length) {
63914
64542
  if (typeof arg === "number") {
63915
64543
  throw new TypeError("Argument must not be a number");
63916
64544
  }
63917
- return Buffer3(arg, encodingOrOffset, length);
64545
+ return Buffer2(arg, encodingOrOffset, length);
63918
64546
  };
63919
64547
  SafeBuffer.alloc = function(size, fill, encoding) {
63920
64548
  if (typeof size !== "number") {
63921
64549
  throw new TypeError("Argument must be a number");
63922
64550
  }
63923
- var buf = Buffer3(size);
64551
+ var buf = Buffer2(size);
63924
64552
  if (fill !== void 0) {
63925
64553
  if (typeof encoding === "string") {
63926
64554
  buf.fill(fill, encoding);
@@ -63936,7 +64564,7 @@ var require_safe_buffer = __commonJS({
63936
64564
  if (typeof size !== "number") {
63937
64565
  throw new TypeError("Argument must be a number");
63938
64566
  }
63939
- return Buffer3(size);
64567
+ return Buffer2(size);
63940
64568
  };
63941
64569
  SafeBuffer.allocUnsafeSlow = function(size) {
63942
64570
  if (typeof size !== "number") {
@@ -63951,8 +64579,8 @@ var require_safe_buffer = __commonJS({
63951
64579
  var require_string_decoder = __commonJS({
63952
64580
  "../../node_modules/string_decoder/lib/string_decoder.js"(exports2) {
63953
64581
  "use strict";
63954
- var Buffer3 = require_safe_buffer().Buffer;
63955
- var isEncoding = Buffer3.isEncoding || function(encoding) {
64582
+ var Buffer2 = require_safe_buffer().Buffer;
64583
+ var isEncoding = Buffer2.isEncoding || function(encoding) {
63956
64584
  encoding = "" + encoding;
63957
64585
  switch (encoding && encoding.toLowerCase()) {
63958
64586
  case "hex":
@@ -64000,7 +64628,7 @@ var require_string_decoder = __commonJS({
64000
64628
  }
64001
64629
  function normalizeEncoding(enc) {
64002
64630
  var nenc = _normalizeEncoding(enc);
64003
- if (typeof nenc !== "string" && (Buffer3.isEncoding === isEncoding || !isEncoding(enc))) throw new Error("Unknown encoding: " + enc);
64631
+ if (typeof nenc !== "string" && (Buffer2.isEncoding === isEncoding || !isEncoding(enc))) throw new Error("Unknown encoding: " + enc);
64004
64632
  return nenc || enc;
64005
64633
  }
64006
64634
  exports2.StringDecoder = StringDecoder;
@@ -64029,7 +64657,7 @@ var require_string_decoder = __commonJS({
64029
64657
  }
64030
64658
  this.lastNeed = 0;
64031
64659
  this.lastTotal = 0;
64032
- this.lastChar = Buffer3.allocUnsafe(nb);
64660
+ this.lastChar = Buffer2.allocUnsafe(nb);
64033
64661
  }
64034
64662
  StringDecoder.prototype.write = function(buf) {
64035
64663
  if (buf.length === 0) return "";
@@ -64590,14 +65218,14 @@ var require_stream_readable = __commonJS({
64590
65218
  return emitter.listeners(type).length;
64591
65219
  };
64592
65220
  var Stream = require_stream();
64593
- var Buffer3 = require("buffer").Buffer;
65221
+ var Buffer2 = require("buffer").Buffer;
64594
65222
  var OurUint8Array = (typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {
64595
65223
  };
64596
65224
  function _uint8ArrayToBuffer(chunk) {
64597
- return Buffer3.from(chunk);
65225
+ return Buffer2.from(chunk);
64598
65226
  }
64599
65227
  function _isUint8Array(obj) {
64600
- return Buffer3.isBuffer(obj) || obj instanceof OurUint8Array;
65228
+ return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array;
64601
65229
  }
64602
65230
  var debugUtil = require("util");
64603
65231
  var debug;
@@ -64705,7 +65333,7 @@ var require_stream_readable = __commonJS({
64705
65333
  if (typeof chunk === "string") {
64706
65334
  encoding = encoding || state.defaultEncoding;
64707
65335
  if (encoding !== state.encoding) {
64708
- chunk = Buffer3.from(chunk, encoding);
65336
+ chunk = Buffer2.from(chunk, encoding);
64709
65337
  encoding = "";
64710
65338
  }
64711
65339
  skipChunkCheck = true;
@@ -64730,7 +65358,7 @@ var require_stream_readable = __commonJS({
64730
65358
  if (er) {
64731
65359
  errorOrDestroy(stream, er);
64732
65360
  } else if (state.objectMode || chunk && chunk.length > 0) {
64733
- if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer3.prototype) {
65361
+ if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer2.prototype) {
64734
65362
  chunk = _uint8ArrayToBuffer(chunk);
64735
65363
  }
64736
65364
  if (addToFront) {
@@ -65541,7 +66169,7 @@ var require_readable = __commonJS({
65541
66169
  var require_BufferList = __commonJS({
65542
66170
  "../../node_modules/bl/BufferList.js"(exports2, module2) {
65543
66171
  "use strict";
65544
- var { Buffer: Buffer3 } = require("buffer");
66172
+ var { Buffer: Buffer2 } = require("buffer");
65545
66173
  var symbol2 = /* @__PURE__ */ Symbol.for("BufferList");
65546
66174
  function BufferList(buf) {
65547
66175
  if (!(this instanceof BufferList)) {
@@ -65605,10 +66233,10 @@ var require_BufferList = __commonJS({
65605
66233
  srcEnd = this.length;
65606
66234
  }
65607
66235
  if (srcStart >= this.length) {
65608
- return dst || Buffer3.alloc(0);
66236
+ return dst || Buffer2.alloc(0);
65609
66237
  }
65610
66238
  if (srcEnd <= 0) {
65611
- return dst || Buffer3.alloc(0);
66239
+ return dst || Buffer2.alloc(0);
65612
66240
  }
65613
66241
  const copy2 = !!dst;
65614
66242
  const off = this._offset(srcStart);
@@ -65618,7 +66246,7 @@ var require_BufferList = __commonJS({
65618
66246
  let start = off[1];
65619
66247
  if (srcStart === 0 && srcEnd === this.length) {
65620
66248
  if (!copy2) {
65621
- return this._bufs.length === 1 ? this._bufs[0] : Buffer3.concat(this._bufs, this.length);
66249
+ return this._bufs.length === 1 ? this._bufs[0] : Buffer2.concat(this._bufs, this.length);
65622
66250
  }
65623
66251
  for (let i = 0; i < this._bufs.length; i++) {
65624
66252
  this._bufs[i].copy(dst, bufoff);
@@ -65630,7 +66258,7 @@ var require_BufferList = __commonJS({
65630
66258
  return copy2 ? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes) : this._bufs[off[0]].slice(start, start + bytes);
65631
66259
  }
65632
66260
  if (!copy2) {
65633
- dst = Buffer3.allocUnsafe(len);
66261
+ dst = Buffer2.allocUnsafe(len);
65634
66262
  }
65635
66263
  for (let i = off[0]; i < this._bufs.length; i++) {
65636
66264
  const l = this._bufs[i].length - start;
@@ -65706,7 +66334,7 @@ var require_BufferList = __commonJS({
65706
66334
  return this;
65707
66335
  }
65708
66336
  if (buf.buffer) {
65709
- this._appendBuffer(Buffer3.from(buf.buffer, buf.byteOffset, buf.byteLength));
66337
+ this._appendBuffer(Buffer2.from(buf.buffer, buf.byteOffset, buf.byteLength));
65710
66338
  } else if (Array.isArray(buf)) {
65711
66339
  for (let i = 0; i < buf.length; i++) {
65712
66340
  this.append(buf[i]);
@@ -65719,7 +66347,7 @@ var require_BufferList = __commonJS({
65719
66347
  if (typeof buf === "number") {
65720
66348
  buf = buf.toString();
65721
66349
  }
65722
- this._appendBuffer(Buffer3.from(buf));
66350
+ this._appendBuffer(Buffer2.from(buf));
65723
66351
  }
65724
66352
  return this;
65725
66353
  };
@@ -65735,15 +66363,15 @@ var require_BufferList = __commonJS({
65735
66363
  if (typeof search === "function" || Array.isArray(search)) {
65736
66364
  throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');
65737
66365
  } else if (typeof search === "number") {
65738
- search = Buffer3.from([search]);
66366
+ search = Buffer2.from([search]);
65739
66367
  } else if (typeof search === "string") {
65740
- search = Buffer3.from(search, encoding);
66368
+ search = Buffer2.from(search, encoding);
65741
66369
  } else if (this._isBufferList(search)) {
65742
66370
  search = search.slice();
65743
66371
  } else if (Array.isArray(search.buffer)) {
65744
- search = Buffer3.from(search.buffer, search.byteOffset, search.byteLength);
65745
- } else if (!Buffer3.isBuffer(search)) {
65746
- search = Buffer3.from(search);
66372
+ search = Buffer2.from(search.buffer, search.byteOffset, search.byteLength);
66373
+ } else if (!Buffer2.isBuffer(search)) {
66374
+ search = Buffer2.from(search);
65747
66375
  }
65748
66376
  offset = Number(offset || 0);
65749
66377
  if (isNaN(offset)) {
@@ -73059,10 +73687,10 @@ var require_lib = __commonJS({
73059
73687
  exports2.analyse = analyse;
73060
73688
  var detectFile = (filepath, opts = {}) => new Promise((resolve18, reject) => {
73061
73689
  let fd;
73062
- const fs27 = (0, node_1.default)();
73690
+ const fs22 = (0, node_1.default)();
73063
73691
  const handler = (err, buffer) => {
73064
73692
  if (fd) {
73065
- fs27.closeSync(fd);
73693
+ fs22.closeSync(fd);
73066
73694
  }
73067
73695
  if (err) {
73068
73696
  reject(err);
@@ -73074,9 +73702,9 @@ var require_lib = __commonJS({
73074
73702
  };
73075
73703
  const sampleSize = (opts === null || opts === void 0 ? void 0 : opts.sampleSize) || 0;
73076
73704
  if (sampleSize > 0) {
73077
- fd = fs27.openSync(filepath, "r");
73705
+ fd = fs22.openSync(filepath, "r");
73078
73706
  let sample = Buffer.allocUnsafe(sampleSize);
73079
- fs27.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
73707
+ fs22.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
73080
73708
  if (err) {
73081
73709
  handler(err, null);
73082
73710
  } else {
@@ -73088,22 +73716,22 @@ var require_lib = __commonJS({
73088
73716
  });
73089
73717
  return;
73090
73718
  }
73091
- fs27.readFile(filepath, handler);
73719
+ fs22.readFile(filepath, handler);
73092
73720
  });
73093
73721
  exports2.detectFile = detectFile;
73094
73722
  var detectFileSync = (filepath, opts = {}) => {
73095
- const fs27 = (0, node_1.default)();
73723
+ const fs22 = (0, node_1.default)();
73096
73724
  if (opts && opts.sampleSize) {
73097
- const fd = fs27.openSync(filepath, "r");
73725
+ const fd = fs22.openSync(filepath, "r");
73098
73726
  let sample = Buffer.allocUnsafe(opts.sampleSize);
73099
- const bytesRead = fs27.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
73727
+ const bytesRead = fs22.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
73100
73728
  if (bytesRead < opts.sampleSize) {
73101
73729
  sample = sample.subarray(0, bytesRead);
73102
73730
  }
73103
- fs27.closeSync(fd);
73731
+ fs22.closeSync(fd);
73104
73732
  return (0, exports2.detect)(sample);
73105
73733
  }
73106
- return (0, exports2.detect)(fs27.readFileSync(filepath));
73734
+ return (0, exports2.detect)(fs22.readFileSync(filepath));
73107
73735
  };
73108
73736
  exports2.detectFileSync = detectFileSync;
73109
73737
  exports2.default = {
@@ -73120,7 +73748,7 @@ var require_safer = __commonJS({
73120
73748
  "../../node_modules/safer-buffer/safer.js"(exports2, module2) {
73121
73749
  "use strict";
73122
73750
  var buffer = require("buffer");
73123
- var Buffer3 = buffer.Buffer;
73751
+ var Buffer2 = buffer.Buffer;
73124
73752
  var safer = {};
73125
73753
  var key;
73126
73754
  for (key in buffer) {
@@ -73129,12 +73757,12 @@ var require_safer = __commonJS({
73129
73757
  safer[key] = buffer[key];
73130
73758
  }
73131
73759
  var Safer = safer.Buffer = {};
73132
- for (key in Buffer3) {
73133
- if (!Buffer3.hasOwnProperty(key)) continue;
73760
+ for (key in Buffer2) {
73761
+ if (!Buffer2.hasOwnProperty(key)) continue;
73134
73762
  if (key === "allocUnsafe" || key === "allocUnsafeSlow") continue;
73135
- Safer[key] = Buffer3[key];
73763
+ Safer[key] = Buffer2[key];
73136
73764
  }
73137
- safer.Buffer.prototype = Buffer3.prototype;
73765
+ safer.Buffer.prototype = Buffer2.prototype;
73138
73766
  if (!Safer.from || Safer.from === Uint8Array.from) {
73139
73767
  Safer.from = function(value, encodingOrOffset, length) {
73140
73768
  if (typeof value === "number") {
@@ -73143,7 +73771,7 @@ var require_safer = __commonJS({
73143
73771
  if (value && typeof value.length === "undefined") {
73144
73772
  throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
73145
73773
  }
73146
- return Buffer3(value, encodingOrOffset, length);
73774
+ return Buffer2(value, encodingOrOffset, length);
73147
73775
  };
73148
73776
  }
73149
73777
  if (!Safer.alloc) {
@@ -73154,7 +73782,7 @@ var require_safer = __commonJS({
73154
73782
  if (size < 0 || size >= 2 * (1 << 30)) {
73155
73783
  throw new RangeError('The value "' + size + '" is invalid for option "size"');
73156
73784
  }
73157
- var buf = Buffer3(size);
73785
+ var buf = Buffer2(size);
73158
73786
  if (!fill || fill.length === 0) {
73159
73787
  buf.fill(0);
73160
73788
  } else if (typeof encoding === "string") {
@@ -73249,7 +73877,7 @@ var require_merge_exports = __commonJS({
73249
73877
  var require_internal = __commonJS({
73250
73878
  "../../node_modules/@inquirer/external-editor/node_modules/iconv-lite/encodings/internal.js"(exports2, module2) {
73251
73879
  "use strict";
73252
- var Buffer3 = require_safer().Buffer;
73880
+ var Buffer2 = require_safer().Buffer;
73253
73881
  module2.exports = {
73254
73882
  // Encodings
73255
73883
  utf8: { type: "_internal", bomAware: true },
@@ -73273,7 +73901,7 @@ var require_internal = __commonJS({
73273
73901
  } else if (this.enc === "cesu8") {
73274
73902
  this.enc = "utf8";
73275
73903
  this.encoder = InternalEncoderCesu8;
73276
- if (Buffer3.from("eda0bdedb2a9", "hex").toString() !== "\u{1F4A9}") {
73904
+ if (Buffer2.from("eda0bdedb2a9", "hex").toString() !== "\u{1F4A9}") {
73277
73905
  this.decoder = InternalDecoderCesu8;
73278
73906
  this.defaultCharUnicode = iconv2.defaultCharUnicode;
73279
73907
  }
@@ -73286,8 +73914,8 @@ var require_internal = __commonJS({
73286
73914
  this.decoder = new StringDecoder(codec2.enc);
73287
73915
  }
73288
73916
  InternalDecoder.prototype.write = function(buf) {
73289
- if (!Buffer3.isBuffer(buf)) {
73290
- buf = Buffer3.from(buf);
73917
+ if (!Buffer2.isBuffer(buf)) {
73918
+ buf = Buffer2.from(buf);
73291
73919
  }
73292
73920
  return this.decoder.write(buf);
73293
73921
  };
@@ -73298,7 +73926,7 @@ var require_internal = __commonJS({
73298
73926
  this.enc = codec2.enc;
73299
73927
  }
73300
73928
  InternalEncoder.prototype.write = function(str) {
73301
- return Buffer3.from(str, this.enc);
73929
+ return Buffer2.from(str, this.enc);
73302
73930
  };
73303
73931
  InternalEncoder.prototype.end = function() {
73304
73932
  };
@@ -73310,15 +73938,15 @@ var require_internal = __commonJS({
73310
73938
  var completeQuads = str.length - str.length % 4;
73311
73939
  this.prevStr = str.slice(completeQuads);
73312
73940
  str = str.slice(0, completeQuads);
73313
- return Buffer3.from(str, "base64");
73941
+ return Buffer2.from(str, "base64");
73314
73942
  };
73315
73943
  InternalEncoderBase64.prototype.end = function() {
73316
- return Buffer3.from(this.prevStr, "base64");
73944
+ return Buffer2.from(this.prevStr, "base64");
73317
73945
  };
73318
73946
  function InternalEncoderCesu8(options, codec2) {
73319
73947
  }
73320
73948
  InternalEncoderCesu8.prototype.write = function(str) {
73321
- var buf = Buffer3.alloc(str.length * 3);
73949
+ var buf = Buffer2.alloc(str.length * 3);
73322
73950
  var bufIdx = 0;
73323
73951
  for (var i = 0; i < str.length; i++) {
73324
73952
  var charCode = str.charCodeAt(i);
@@ -73414,13 +74042,13 @@ var require_internal = __commonJS({
73414
74042
  str = str.slice(0, str.length - 1);
73415
74043
  }
73416
74044
  }
73417
- return Buffer3.from(str, this.enc);
74045
+ return Buffer2.from(str, this.enc);
73418
74046
  };
73419
74047
  InternalEncoderUtf8.prototype.end = function() {
73420
74048
  if (this.highSurrogate) {
73421
74049
  var str = this.highSurrogate;
73422
74050
  this.highSurrogate = "";
73423
- return Buffer3.from(str, this.enc);
74051
+ return Buffer2.from(str, this.enc);
73424
74052
  }
73425
74053
  };
73426
74054
  }
@@ -73430,7 +74058,7 @@ var require_internal = __commonJS({
73430
74058
  var require_utf32 = __commonJS({
73431
74059
  "../../node_modules/@inquirer/external-editor/node_modules/iconv-lite/encodings/utf32.js"(exports2) {
73432
74060
  "use strict";
73433
- var Buffer3 = require_safer().Buffer;
74061
+ var Buffer2 = require_safer().Buffer;
73434
74062
  exports2._utf32 = Utf32Codec;
73435
74063
  function Utf32Codec(codecOptions, iconv2) {
73436
74064
  this.iconv = iconv2;
@@ -73448,8 +74076,8 @@ var require_utf32 = __commonJS({
73448
74076
  this.highSurrogate = 0;
73449
74077
  }
73450
74078
  Utf32Encoder.prototype.write = function(str) {
73451
- var src = Buffer3.from(str, "ucs2");
73452
- var dst = Buffer3.alloc(src.length * 2);
74079
+ var src = Buffer2.from(str, "ucs2");
74080
+ var dst = Buffer2.alloc(src.length * 2);
73453
74081
  var write32 = this.isLE ? dst.writeUInt32LE : dst.writeUInt32BE;
73454
74082
  var offset = 0;
73455
74083
  for (var i = 0; i < src.length; i += 2) {
@@ -73485,7 +74113,7 @@ var require_utf32 = __commonJS({
73485
74113
  if (!this.highSurrogate) {
73486
74114
  return;
73487
74115
  }
73488
- var buf = Buffer3.alloc(4);
74116
+ var buf = Buffer2.alloc(4);
73489
74117
  if (this.isLE) {
73490
74118
  buf.writeUInt32LE(this.highSurrogate, 0);
73491
74119
  } else {
@@ -73505,7 +74133,7 @@ var require_utf32 = __commonJS({
73505
74133
  }
73506
74134
  var i = 0;
73507
74135
  var codepoint = 0;
73508
- var dst = Buffer3.alloc(src.length + 4);
74136
+ var dst = Buffer2.alloc(src.length + 4);
73509
74137
  var offset = 0;
73510
74138
  var isLE = this.isLE;
73511
74139
  var overflow = this.overflow;
@@ -73661,7 +74289,7 @@ var require_utf32 = __commonJS({
73661
74289
  var require_utf16 = __commonJS({
73662
74290
  "../../node_modules/@inquirer/external-editor/node_modules/iconv-lite/encodings/utf16.js"(exports2) {
73663
74291
  "use strict";
73664
- var Buffer3 = require_safer().Buffer;
74292
+ var Buffer2 = require_safer().Buffer;
73665
74293
  exports2.utf16be = Utf16BECodec;
73666
74294
  function Utf16BECodec() {
73667
74295
  }
@@ -73671,7 +74299,7 @@ var require_utf16 = __commonJS({
73671
74299
  function Utf16BEEncoder() {
73672
74300
  }
73673
74301
  Utf16BEEncoder.prototype.write = function(str) {
73674
- var buf = Buffer3.from(str, "ucs2");
74302
+ var buf = Buffer2.from(str, "ucs2");
73675
74303
  for (var i = 0; i < buf.length; i += 2) {
73676
74304
  var tmp = buf[i];
73677
74305
  buf[i] = buf[i + 1];
@@ -73688,7 +74316,7 @@ var require_utf16 = __commonJS({
73688
74316
  if (buf.length == 0) {
73689
74317
  return "";
73690
74318
  }
73691
- var buf2 = Buffer3.alloc(buf.length + 1);
74319
+ var buf2 = Buffer2.alloc(buf.length + 1);
73692
74320
  var i = 0;
73693
74321
  var j = 0;
73694
74322
  if (this.overflowByte !== -1) {
@@ -73804,7 +74432,7 @@ var require_utf16 = __commonJS({
73804
74432
  var require_utf7 = __commonJS({
73805
74433
  "../../node_modules/@inquirer/external-editor/node_modules/iconv-lite/encodings/utf7.js"(exports2) {
73806
74434
  "use strict";
73807
- var Buffer3 = require_safer().Buffer;
74435
+ var Buffer2 = require_safer().Buffer;
73808
74436
  exports2.utf7 = Utf7Codec;
73809
74437
  exports2.unicode11utf7 = "utf7";
73810
74438
  function Utf7Codec(codecOptions, iconv2) {
@@ -73818,7 +74446,7 @@ var require_utf7 = __commonJS({
73818
74446
  this.iconv = codec2.iconv;
73819
74447
  }
73820
74448
  Utf7Encoder.prototype.write = function(str) {
73821
- return Buffer3.from(str.replace(nonDirectChars, function(chunk) {
74449
+ return Buffer2.from(str.replace(nonDirectChars, function(chunk) {
73822
74450
  return "+" + (chunk === "+" ? "" : this.iconv.encode(chunk, "utf16-be").toString("base64").replace(/=+$/, "")) + "-";
73823
74451
  }.bind(this)));
73824
74452
  };
@@ -73856,7 +74484,7 @@ var require_utf7 = __commonJS({
73856
74484
  res += "+";
73857
74485
  } else {
73858
74486
  var b64str = base64Accum + this.iconv.decode(buf.slice(lastI, i2), "ascii");
73859
- res += this.iconv.decode(Buffer3.from(b64str, "base64"), "utf16-be");
74487
+ res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
73860
74488
  }
73861
74489
  if (buf[i2] != minusChar) {
73862
74490
  i2--;
@@ -73874,7 +74502,7 @@ var require_utf7 = __commonJS({
73874
74502
  var canBeDecoded = b64str.length - b64str.length % 8;
73875
74503
  base64Accum = b64str.slice(canBeDecoded);
73876
74504
  b64str = b64str.slice(0, canBeDecoded);
73877
- res += this.iconv.decode(Buffer3.from(b64str, "base64"), "utf16-be");
74505
+ res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
73878
74506
  }
73879
74507
  this.inBase64 = inBase64;
73880
74508
  this.base64Accum = base64Accum;
@@ -73883,7 +74511,7 @@ var require_utf7 = __commonJS({
73883
74511
  Utf7Decoder.prototype.end = function() {
73884
74512
  var res = "";
73885
74513
  if (this.inBase64 && this.base64Accum.length > 0) {
73886
- res = this.iconv.decode(Buffer3.from(this.base64Accum, "base64"), "utf16-be");
74514
+ res = this.iconv.decode(Buffer2.from(this.base64Accum, "base64"), "utf16-be");
73887
74515
  }
73888
74516
  this.inBase64 = false;
73889
74517
  this.base64Accum = "";
@@ -73899,14 +74527,14 @@ var require_utf7 = __commonJS({
73899
74527
  function Utf7IMAPEncoder(options, codec2) {
73900
74528
  this.iconv = codec2.iconv;
73901
74529
  this.inBase64 = false;
73902
- this.base64Accum = Buffer3.alloc(6);
74530
+ this.base64Accum = Buffer2.alloc(6);
73903
74531
  this.base64AccumIdx = 0;
73904
74532
  }
73905
74533
  Utf7IMAPEncoder.prototype.write = function(str) {
73906
74534
  var inBase64 = this.inBase64;
73907
74535
  var base64Accum = this.base64Accum;
73908
74536
  var base64AccumIdx = this.base64AccumIdx;
73909
- var buf = Buffer3.alloc(str.length * 5 + 10);
74537
+ var buf = Buffer2.alloc(str.length * 5 + 10);
73910
74538
  var bufIdx = 0;
73911
74539
  for (var i2 = 0; i2 < str.length; i2++) {
73912
74540
  var uChar = str.charCodeAt(i2);
@@ -73945,7 +74573,7 @@ var require_utf7 = __commonJS({
73945
74573
  return buf.slice(0, bufIdx);
73946
74574
  };
73947
74575
  Utf7IMAPEncoder.prototype.end = function() {
73948
- var buf = Buffer3.alloc(10);
74576
+ var buf = Buffer2.alloc(10);
73949
74577
  var bufIdx = 0;
73950
74578
  if (this.inBase64) {
73951
74579
  if (this.base64AccumIdx > 0) {
@@ -73982,7 +74610,7 @@ var require_utf7 = __commonJS({
73982
74610
  res += "&";
73983
74611
  } else {
73984
74612
  var b64str = base64Accum + this.iconv.decode(buf.slice(lastI, i2), "ascii").replace(/,/g, "/");
73985
- res += this.iconv.decode(Buffer3.from(b64str, "base64"), "utf16-be");
74613
+ res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
73986
74614
  }
73987
74615
  if (buf[i2] != minusChar) {
73988
74616
  i2--;
@@ -74000,7 +74628,7 @@ var require_utf7 = __commonJS({
74000
74628
  var canBeDecoded = b64str.length - b64str.length % 8;
74001
74629
  base64Accum = b64str.slice(canBeDecoded);
74002
74630
  b64str = b64str.slice(0, canBeDecoded);
74003
- res += this.iconv.decode(Buffer3.from(b64str, "base64"), "utf16-be");
74631
+ res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
74004
74632
  }
74005
74633
  this.inBase64 = inBase64;
74006
74634
  this.base64Accum = base64Accum;
@@ -74009,7 +74637,7 @@ var require_utf7 = __commonJS({
74009
74637
  Utf7IMAPDecoder.prototype.end = function() {
74010
74638
  var res = "";
74011
74639
  if (this.inBase64 && this.base64Accum.length > 0) {
74012
- res = this.iconv.decode(Buffer3.from(this.base64Accum, "base64"), "utf16-be");
74640
+ res = this.iconv.decode(Buffer2.from(this.base64Accum, "base64"), "utf16-be");
74013
74641
  }
74014
74642
  this.inBase64 = false;
74015
74643
  this.base64Accum = "";
@@ -74022,7 +74650,7 @@ var require_utf7 = __commonJS({
74022
74650
  var require_sbcs_codec = __commonJS({
74023
74651
  "../../node_modules/@inquirer/external-editor/node_modules/iconv-lite/encodings/sbcs-codec.js"(exports2) {
74024
74652
  "use strict";
74025
- var Buffer3 = require_safer().Buffer;
74653
+ var Buffer2 = require_safer().Buffer;
74026
74654
  exports2._sbcs = SBCSCodec;
74027
74655
  function SBCSCodec(codecOptions, iconv2) {
74028
74656
  if (!codecOptions) {
@@ -74038,8 +74666,8 @@ var require_sbcs_codec = __commonJS({
74038
74666
  }
74039
74667
  codecOptions.chars = asciiString + codecOptions.chars;
74040
74668
  }
74041
- this.decodeBuf = Buffer3.from(codecOptions.chars, "ucs2");
74042
- var encodeBuf = Buffer3.alloc(65536, iconv2.defaultCharSingleByte.charCodeAt(0));
74669
+ this.decodeBuf = Buffer2.from(codecOptions.chars, "ucs2");
74670
+ var encodeBuf = Buffer2.alloc(65536, iconv2.defaultCharSingleByte.charCodeAt(0));
74043
74671
  for (var i = 0; i < codecOptions.chars.length; i++) {
74044
74672
  encodeBuf[codecOptions.chars.charCodeAt(i)] = i;
74045
74673
  }
@@ -74051,7 +74679,7 @@ var require_sbcs_codec = __commonJS({
74051
74679
  this.encodeBuf = codec2.encodeBuf;
74052
74680
  }
74053
74681
  SBCSEncoder.prototype.write = function(str) {
74054
- var buf = Buffer3.alloc(str.length);
74682
+ var buf = Buffer2.alloc(str.length);
74055
74683
  for (var i = 0; i < str.length; i++) {
74056
74684
  buf[i] = this.encodeBuf[str.charCodeAt(i)];
74057
74685
  }
@@ -74064,7 +74692,7 @@ var require_sbcs_codec = __commonJS({
74064
74692
  }
74065
74693
  SBCSDecoder.prototype.write = function(buf) {
74066
74694
  var decodeBuf = this.decodeBuf;
74067
- var newBuf = Buffer3.alloc(buf.length * 2);
74695
+ var newBuf = Buffer2.alloc(buf.length * 2);
74068
74696
  var idx1 = 0;
74069
74697
  var idx2 = 0;
74070
74698
  for (var i = 0; i < buf.length; i++) {
@@ -74692,7 +75320,7 @@ var require_sbcs_data_generated = __commonJS({
74692
75320
  var require_dbcs_codec = __commonJS({
74693
75321
  "../../node_modules/@inquirer/external-editor/node_modules/iconv-lite/encodings/dbcs-codec.js"(exports2) {
74694
75322
  "use strict";
74695
- var Buffer3 = require_safer().Buffer;
75323
+ var Buffer2 = require_safer().Buffer;
74696
75324
  exports2._dbcs = DBCSCodec;
74697
75325
  var UNASSIGNED = -1;
74698
75326
  var GB18030_CODE = -2;
@@ -74928,7 +75556,7 @@ var require_dbcs_codec = __commonJS({
74928
75556
  this.gb18030 = codec2.gb18030;
74929
75557
  }
74930
75558
  DBCSEncoder.prototype.write = function(str) {
74931
- var newBuf = Buffer3.alloc(str.length * (this.gb18030 ? 4 : 3));
75559
+ var newBuf = Buffer2.alloc(str.length * (this.gb18030 ? 4 : 3));
74932
75560
  var leadSurrogate = this.leadSurrogate;
74933
75561
  var seqObj = this.seqObj;
74934
75562
  var nextChar = -1;
@@ -75032,7 +75660,7 @@ var require_dbcs_codec = __commonJS({
75032
75660
  if (this.leadSurrogate === -1 && this.seqObj === void 0) {
75033
75661
  return;
75034
75662
  }
75035
- var newBuf = Buffer3.alloc(10);
75663
+ var newBuf = Buffer2.alloc(10);
75036
75664
  var j = 0;
75037
75665
  if (this.seqObj) {
75038
75666
  var dbcsCode = this.seqObj[DEF_CHAR];
@@ -75063,7 +75691,7 @@ var require_dbcs_codec = __commonJS({
75063
75691
  this.gb18030 = codec2.gb18030;
75064
75692
  }
75065
75693
  DBCSDecoder.prototype.write = function(buf) {
75066
- var newBuf = Buffer3.alloc(buf.length * 2);
75694
+ var newBuf = Buffer2.alloc(buf.length * 2);
75067
75695
  var nodeIdx = this.nodeIdx;
75068
75696
  var prevBytes = this.prevBytes;
75069
75697
  var prevOffset = this.prevBytes.length;
@@ -76672,7 +77300,7 @@ var require_encodings = __commonJS({
76672
77300
  var require_streams = __commonJS({
76673
77301
  "../../node_modules/@inquirer/external-editor/node_modules/iconv-lite/lib/streams.js"(exports2, module2) {
76674
77302
  "use strict";
76675
- var Buffer3 = require_safer().Buffer;
77303
+ var Buffer2 = require_safer().Buffer;
76676
77304
  module2.exports = function(streamModule) {
76677
77305
  var Transform = streamModule.Transform;
76678
77306
  function IconvLiteEncoderStream(conv, options) {
@@ -76712,7 +77340,7 @@ var require_streams = __commonJS({
76712
77340
  chunks.push(chunk);
76713
77341
  });
76714
77342
  this.on("end", function() {
76715
- cb(null, Buffer3.concat(chunks));
77343
+ cb(null, Buffer2.concat(chunks));
76716
77344
  });
76717
77345
  return this;
76718
77346
  };
@@ -76726,7 +77354,7 @@ var require_streams = __commonJS({
76726
77354
  constructor: { value: IconvLiteDecoderStream }
76727
77355
  });
76728
77356
  IconvLiteDecoderStream.prototype._transform = function(chunk, encoding, done) {
76729
- if (!Buffer3.isBuffer(chunk) && !(chunk instanceof Uint8Array)) {
77357
+ if (!Buffer2.isBuffer(chunk) && !(chunk instanceof Uint8Array)) {
76730
77358
  return done(new Error("Iconv decoding stream needs buffers as its input."));
76731
77359
  }
76732
77360
  try {
@@ -76769,7 +77397,7 @@ var require_streams = __commonJS({
76769
77397
  var require_lib2 = __commonJS({
76770
77398
  "../../node_modules/@inquirer/external-editor/node_modules/iconv-lite/lib/index.js"(exports2, module2) {
76771
77399
  "use strict";
76772
- var Buffer3 = require_safer().Buffer;
77400
+ var Buffer2 = require_safer().Buffer;
76773
77401
  var bomHandling = require_bom_handling();
76774
77402
  var mergeModules = require_merge_exports();
76775
77403
  module2.exports.encodings = null;
@@ -76780,7 +77408,7 @@ var require_lib2 = __commonJS({
76780
77408
  var encoder = module2.exports.getEncoder(encoding, options);
76781
77409
  var res = encoder.write(str);
76782
77410
  var trail = encoder.end();
76783
- return trail && trail.length > 0 ? Buffer3.concat([res, trail]) : res;
77411
+ return trail && trail.length > 0 ? Buffer2.concat([res, trail]) : res;
76784
77412
  };
76785
77413
  module2.exports.decode = function decode3(buf, encoding, options) {
76786
77414
  if (typeof buf === "string") {
@@ -76788,7 +77416,7 @@ var require_lib2 = __commonJS({
76788
77416
  console.error("Iconv-lite warning: decode()-ing strings is deprecated. Refer to https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding");
76789
77417
  module2.exports.skipDecodeWarning = true;
76790
77418
  }
76791
- buf = Buffer3.from("" + (buf || ""), "binary");
77419
+ buf = Buffer2.from("" + (buf || ""), "binary");
76792
77420
  }
76793
77421
  var decoder = module2.exports.getDecoder(encoding, options);
76794
77422
  var res = decoder.write(buf);
@@ -77508,9 +78136,9 @@ var init_prompt = __esm({
77508
78136
  init_utils();
77509
78137
  init_baseUI();
77510
78138
  _ = {
77511
- set: (obj, path36 = "", value) => {
78139
+ set: (obj, path35 = "", value) => {
77512
78140
  let pointer = obj;
77513
- path36.split(".").forEach((key, index, arr) => {
78141
+ path35.split(".").forEach((key, index, arr) => {
77514
78142
  if (key === "__proto__" || key === "constructor") return;
77515
78143
  if (index === arr.length - 1) {
77516
78144
  pointer[key] = value;
@@ -77520,8 +78148,8 @@ var init_prompt = __esm({
77520
78148
  pointer = pointer[key];
77521
78149
  });
77522
78150
  },
77523
- get: (obj, path36 = "", defaultValue) => {
77524
- const travel = (regexp) => String.prototype.split.call(path36, regexp).filter(Boolean).reduce(
78151
+ get: (obj, path35 = "", defaultValue) => {
78152
+ const travel = (regexp) => String.prototype.split.call(path35, regexp).filter(Boolean).reduce(
77525
78153
  // @ts-expect-error implicit any on res[key]
77526
78154
  (res, key) => res !== null && res !== void 0 ? res[key] : res,
77527
78155
  obj
@@ -77837,7 +78465,7 @@ var init_mjs = __esm({
77837
78465
  "../../node_modules/signal-exit/dist/mjs/index.js"() {
77838
78466
  "use strict";
77839
78467
  init_signals();
77840
- processOk = (process19) => !!process19 && typeof process19 === "object" && typeof process19.removeListener === "function" && typeof process19.emit === "function" && typeof process19.reallyExit === "function" && typeof process19.listeners === "function" && typeof process19.kill === "function" && typeof process19.pid === "number" && typeof process19.on === "function";
78468
+ processOk = (process13) => !!process13 && typeof process13 === "object" && typeof process13.removeListener === "function" && typeof process13.emit === "function" && typeof process13.reallyExit === "function" && typeof process13.listeners === "function" && typeof process13.kill === "function" && typeof process13.pid === "number" && typeof process13.on === "function";
77841
78469
  kExitEmitter = /* @__PURE__ */ Symbol.for("signal-exit emitter");
77842
78470
  global2 = globalThis;
77843
78471
  ObjectDefineProperty = Object.defineProperty.bind(Object);
@@ -77930,15 +78558,15 @@ var init_mjs = __esm({
77930
78558
  #originalProcessReallyExit;
77931
78559
  #sigListeners = {};
77932
78560
  #loaded = false;
77933
- constructor(process19) {
78561
+ constructor(process13) {
77934
78562
  super();
77935
- this.#process = process19;
78563
+ this.#process = process13;
77936
78564
  this.#sigListeners = {};
77937
78565
  for (const sig of signals) {
77938
78566
  this.#sigListeners[sig] = () => {
77939
78567
  const listeners = this.#process.listeners(sig);
77940
78568
  let { count } = this.#emitter;
77941
- const p = process19;
78569
+ const p = process13;
77942
78570
  if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
77943
78571
  count += p.__signal_exit_emitter__.count;
77944
78572
  }
@@ -77947,12 +78575,12 @@ var init_mjs = __esm({
77947
78575
  const ret = this.#emitter.emit("exit", null, sig);
77948
78576
  const s = sig === "SIGHUP" ? this.#hupSig : sig;
77949
78577
  if (!ret)
77950
- process19.kill(process19.pid, s);
78578
+ process13.kill(process13.pid, s);
77951
78579
  }
77952
78580
  };
77953
78581
  }
77954
- this.#originalProcessReallyExit = process19.reallyExit;
77955
- this.#originalProcessEmit = process19.emit;
78582
+ this.#originalProcessReallyExit = process13.reallyExit;
78583
+ this.#originalProcessEmit = process13.emit;
77956
78584
  }
77957
78585
  onExit(cb, opts) {
77958
78586
  if (!processOk(this.#process)) {
@@ -78797,585 +79425,6 @@ var init_ora = __esm({
78797
79425
  }
78798
79426
  });
78799
79427
 
78800
- // ../../node_modules/is-docker/index.js
78801
- function hasDockerEnv() {
78802
- try {
78803
- import_node_fs3.default.statSync("/.dockerenv");
78804
- return true;
78805
- } catch {
78806
- return false;
78807
- }
78808
- }
78809
- function hasDockerCGroup() {
78810
- try {
78811
- return import_node_fs3.default.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
78812
- } catch {
78813
- return false;
78814
- }
78815
- }
78816
- function isDocker() {
78817
- if (isDockerCached === void 0) {
78818
- isDockerCached = hasDockerEnv() || hasDockerCGroup();
78819
- }
78820
- return isDockerCached;
78821
- }
78822
- var import_node_fs3, isDockerCached;
78823
- var init_is_docker = __esm({
78824
- "../../node_modules/is-docker/index.js"() {
78825
- "use strict";
78826
- import_node_fs3 = __toESM(require("fs"), 1);
78827
- }
78828
- });
78829
-
78830
- // ../../node_modules/is-inside-container/index.js
78831
- function isInsideContainer() {
78832
- if (cachedResult === void 0) {
78833
- cachedResult = hasContainerEnv() || isDocker();
78834
- }
78835
- return cachedResult;
78836
- }
78837
- var import_node_fs4, cachedResult, hasContainerEnv;
78838
- var init_is_inside_container = __esm({
78839
- "../../node_modules/is-inside-container/index.js"() {
78840
- "use strict";
78841
- import_node_fs4 = __toESM(require("fs"), 1);
78842
- init_is_docker();
78843
- hasContainerEnv = () => {
78844
- try {
78845
- import_node_fs4.default.statSync("/run/.containerenv");
78846
- return true;
78847
- } catch {
78848
- return false;
78849
- }
78850
- };
78851
- }
78852
- });
78853
-
78854
- // ../../node_modules/is-wsl/index.js
78855
- var import_node_process10, import_node_os5, import_node_fs5, isWsl, is_wsl_default;
78856
- var init_is_wsl = __esm({
78857
- "../../node_modules/is-wsl/index.js"() {
78858
- "use strict";
78859
- import_node_process10 = __toESM(require("process"), 1);
78860
- import_node_os5 = __toESM(require("os"), 1);
78861
- import_node_fs5 = __toESM(require("fs"), 1);
78862
- init_is_inside_container();
78863
- isWsl = () => {
78864
- if (import_node_process10.default.platform !== "linux") {
78865
- return false;
78866
- }
78867
- if (import_node_os5.default.release().toLowerCase().includes("microsoft")) {
78868
- if (isInsideContainer()) {
78869
- return false;
78870
- }
78871
- return true;
78872
- }
78873
- try {
78874
- if (import_node_fs5.default.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
78875
- return !isInsideContainer();
78876
- }
78877
- } catch {
78878
- }
78879
- if (import_node_fs5.default.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || import_node_fs5.default.existsSync("/run/WSL")) {
78880
- return !isInsideContainer();
78881
- }
78882
- return false;
78883
- };
78884
- is_wsl_default = import_node_process10.default.env.__IS_WSL_TEST__ ? isWsl : isWsl();
78885
- }
78886
- });
78887
-
78888
- // ../../node_modules/wsl-utils/index.js
78889
- var import_node_process11, import_promises4, wslDrivesMountPoint, powerShellPathFromWsl, powerShellPath;
78890
- var init_wsl_utils = __esm({
78891
- "../../node_modules/wsl-utils/index.js"() {
78892
- "use strict";
78893
- import_node_process11 = __toESM(require("process"), 1);
78894
- import_promises4 = __toESM(require("fs/promises"), 1);
78895
- init_is_wsl();
78896
- init_is_wsl();
78897
- wslDrivesMountPoint = /* @__PURE__ */ (() => {
78898
- const defaultMountPoint = "/mnt/";
78899
- let mountPoint;
78900
- return async function() {
78901
- if (mountPoint) {
78902
- return mountPoint;
78903
- }
78904
- const configFilePath = "/etc/wsl.conf";
78905
- let isConfigFileExists = false;
78906
- try {
78907
- await import_promises4.default.access(configFilePath, import_promises4.constants.F_OK);
78908
- isConfigFileExists = true;
78909
- } catch {
78910
- }
78911
- if (!isConfigFileExists) {
78912
- return defaultMountPoint;
78913
- }
78914
- const configContent = await import_promises4.default.readFile(configFilePath, { encoding: "utf8" });
78915
- const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
78916
- if (!configMountPoint) {
78917
- return defaultMountPoint;
78918
- }
78919
- mountPoint = configMountPoint.groups.mountPoint.trim();
78920
- mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
78921
- return mountPoint;
78922
- };
78923
- })();
78924
- powerShellPathFromWsl = async () => {
78925
- const mountPoint = await wslDrivesMountPoint();
78926
- return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
78927
- };
78928
- powerShellPath = async () => {
78929
- if (is_wsl_default) {
78930
- return powerShellPathFromWsl();
78931
- }
78932
- return `${import_node_process11.default.env.SYSTEMROOT || import_node_process11.default.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
78933
- };
78934
- }
78935
- });
78936
-
78937
- // ../../node_modules/define-lazy-prop/index.js
78938
- function defineLazyProperty(object2, propertyName, valueGetter) {
78939
- const define = (value) => Object.defineProperty(object2, propertyName, { value, enumerable: true, writable: true });
78940
- Object.defineProperty(object2, propertyName, {
78941
- configurable: true,
78942
- enumerable: true,
78943
- get() {
78944
- const result = valueGetter();
78945
- define(result);
78946
- return result;
78947
- },
78948
- set(value) {
78949
- define(value);
78950
- }
78951
- });
78952
- return object2;
78953
- }
78954
- var init_define_lazy_prop = __esm({
78955
- "../../node_modules/define-lazy-prop/index.js"() {
78956
- "use strict";
78957
- }
78958
- });
78959
-
78960
- // ../../node_modules/default-browser-id/index.js
78961
- async function defaultBrowserId() {
78962
- if (import_node_process12.default.platform !== "darwin") {
78963
- throw new Error("macOS only");
78964
- }
78965
- const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
78966
- const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
78967
- const browserId = match?.groups.id ?? "com.apple.Safari";
78968
- if (browserId === "com.apple.safari") {
78969
- return "com.apple.Safari";
78970
- }
78971
- return browserId;
78972
- }
78973
- var import_node_util, import_node_process12, import_node_child_process, execFileAsync;
78974
- var init_default_browser_id = __esm({
78975
- "../../node_modules/default-browser-id/index.js"() {
78976
- "use strict";
78977
- import_node_util = require("util");
78978
- import_node_process12 = __toESM(require("process"), 1);
78979
- import_node_child_process = require("child_process");
78980
- execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
78981
- }
78982
- });
78983
-
78984
- // ../../node_modules/run-applescript/index.js
78985
- async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
78986
- if (import_node_process13.default.platform !== "darwin") {
78987
- throw new Error("macOS only");
78988
- }
78989
- const outputArguments = humanReadableOutput ? [] : ["-ss"];
78990
- const execOptions = {};
78991
- if (signal) {
78992
- execOptions.signal = signal;
78993
- }
78994
- const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
78995
- return stdout.trim();
78996
- }
78997
- var import_node_process13, import_node_util2, import_node_child_process2, execFileAsync2;
78998
- var init_run_applescript = __esm({
78999
- "../../node_modules/run-applescript/index.js"() {
79000
- "use strict";
79001
- import_node_process13 = __toESM(require("process"), 1);
79002
- import_node_util2 = require("util");
79003
- import_node_child_process2 = require("child_process");
79004
- execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process2.execFile);
79005
- }
79006
- });
79007
-
79008
- // ../../node_modules/bundle-name/index.js
79009
- async function bundleName(bundleId) {
79010
- return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
79011
- tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
79012
- }
79013
- var init_bundle_name = __esm({
79014
- "../../node_modules/bundle-name/index.js"() {
79015
- "use strict";
79016
- init_run_applescript();
79017
- }
79018
- });
79019
-
79020
- // ../../node_modules/default-browser/windows.js
79021
- async function defaultBrowser(_execFileAsync = execFileAsync3) {
79022
- const { stdout } = await _execFileAsync("reg", [
79023
- "QUERY",
79024
- " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
79025
- "/v",
79026
- "ProgId"
79027
- ]);
79028
- const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
79029
- if (!match) {
79030
- throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
79031
- }
79032
- const { id } = match.groups;
79033
- const dotIndex = id.lastIndexOf(".");
79034
- const hyphenIndex = id.lastIndexOf("-");
79035
- const baseIdByDot = dotIndex === -1 ? void 0 : id.slice(0, dotIndex);
79036
- const baseIdByHyphen = hyphenIndex === -1 ? void 0 : id.slice(0, hyphenIndex);
79037
- return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
79038
- }
79039
- var import_node_util3, import_node_child_process3, execFileAsync3, windowsBrowserProgIds, _windowsBrowserProgIdMap, UnknownBrowserError;
79040
- var init_windows = __esm({
79041
- "../../node_modules/default-browser/windows.js"() {
79042
- "use strict";
79043
- import_node_util3 = require("util");
79044
- import_node_child_process3 = require("child_process");
79045
- execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
79046
- windowsBrowserProgIds = {
79047
- MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
79048
- // The missing `L` is correct.
79049
- MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
79050
- MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
79051
- AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
79052
- ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
79053
- ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
79054
- ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
79055
- ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
79056
- BraveHTML: { name: "Brave", id: "com.brave.Browser" },
79057
- BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
79058
- BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
79059
- BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
79060
- FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
79061
- OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
79062
- VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
79063
- "IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
79064
- };
79065
- _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
79066
- UnknownBrowserError = class extends Error {
79067
- };
79068
- }
79069
- });
79070
-
79071
- // ../../node_modules/default-browser/index.js
79072
- async function defaultBrowser2() {
79073
- if (import_node_process14.default.platform === "darwin") {
79074
- const id = await defaultBrowserId();
79075
- const name = await bundleName(id);
79076
- return { name, id };
79077
- }
79078
- if (import_node_process14.default.platform === "linux") {
79079
- const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
79080
- const id = stdout.trim();
79081
- const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
79082
- return { name, id };
79083
- }
79084
- if (import_node_process14.default.platform === "win32") {
79085
- return defaultBrowser();
79086
- }
79087
- throw new Error("Only macOS, Linux, and Windows are supported");
79088
- }
79089
- var import_node_util4, import_node_process14, import_node_child_process4, execFileAsync4, titleize;
79090
- var init_default_browser = __esm({
79091
- "../../node_modules/default-browser/index.js"() {
79092
- "use strict";
79093
- import_node_util4 = require("util");
79094
- import_node_process14 = __toESM(require("process"), 1);
79095
- import_node_child_process4 = require("child_process");
79096
- init_default_browser_id();
79097
- init_bundle_name();
79098
- init_windows();
79099
- execFileAsync4 = (0, import_node_util4.promisify)(import_node_child_process4.execFile);
79100
- titleize = (string4) => string4.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
79101
- }
79102
- });
79103
-
79104
- // ../../node_modules/open/index.js
79105
- async function getWindowsDefaultBrowserFromWsl() {
79106
- const powershellPath = await powerShellPath();
79107
- const rawCommand = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
79108
- const encodedCommand = import_node_buffer.Buffer.from(rawCommand, "utf16le").toString("base64");
79109
- const { stdout } = await execFile5(
79110
- powershellPath,
79111
- [
79112
- "-NoProfile",
79113
- "-NonInteractive",
79114
- "-ExecutionPolicy",
79115
- "Bypass",
79116
- "-EncodedCommand",
79117
- encodedCommand
79118
- ],
79119
- { encoding: "utf8" }
79120
- );
79121
- const progId = stdout.trim();
79122
- const browserMap = {
79123
- ChromeHTML: "com.google.chrome",
79124
- BraveHTML: "com.brave.Browser",
79125
- MSEdgeHTM: "com.microsoft.edge",
79126
- FirefoxURL: "org.mozilla.firefox"
79127
- };
79128
- return browserMap[progId] ? { id: browserMap[progId] } : {};
79129
- }
79130
- function detectArchBinary(binary) {
79131
- if (typeof binary === "string" || Array.isArray(binary)) {
79132
- return binary;
79133
- }
79134
- const { [arch3]: archBinary } = binary;
79135
- if (!archBinary) {
79136
- throw new Error(`${arch3} is not supported`);
79137
- }
79138
- return archBinary;
79139
- }
79140
- function detectPlatformBinary({ [platform11]: platformBinary }, { wsl }) {
79141
- if (wsl && is_wsl_default) {
79142
- return detectArchBinary(wsl);
79143
- }
79144
- if (!platformBinary) {
79145
- throw new Error(`${platform11} is not supported`);
79146
- }
79147
- return detectArchBinary(platformBinary);
79148
- }
79149
- var import_node_process15, import_node_buffer, import_node_path3, import_node_url, import_node_util5, import_node_child_process5, import_promises5, import_meta, execFile5, __dirname2, localXdgOpenPath, platform11, arch3, pTryEach, baseOpen, open2, apps, open_default;
79150
- var init_open = __esm({
79151
- "../../node_modules/open/index.js"() {
79152
- "use strict";
79153
- import_node_process15 = __toESM(require("process"), 1);
79154
- import_node_buffer = require("buffer");
79155
- import_node_path3 = __toESM(require("path"), 1);
79156
- import_node_url = require("url");
79157
- import_node_util5 = require("util");
79158
- import_node_child_process5 = __toESM(require("child_process"), 1);
79159
- import_promises5 = __toESM(require("fs/promises"), 1);
79160
- init_wsl_utils();
79161
- init_define_lazy_prop();
79162
- init_default_browser();
79163
- init_is_inside_container();
79164
- import_meta = {};
79165
- execFile5 = (0, import_node_util5.promisify)(import_node_child_process5.default.execFile);
79166
- __dirname2 = import_node_path3.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
79167
- localXdgOpenPath = import_node_path3.default.join(__dirname2, "xdg-open");
79168
- ({ platform: platform11, arch: arch3 } = import_node_process15.default);
79169
- pTryEach = async (array2, mapper) => {
79170
- let latestError;
79171
- for (const item of array2) {
79172
- try {
79173
- return await mapper(item);
79174
- } catch (error48) {
79175
- latestError = error48;
79176
- }
79177
- }
79178
- throw latestError;
79179
- };
79180
- baseOpen = async (options) => {
79181
- options = {
79182
- wait: false,
79183
- background: false,
79184
- newInstance: false,
79185
- allowNonzeroExitCode: false,
79186
- ...options
79187
- };
79188
- if (Array.isArray(options.app)) {
79189
- return pTryEach(options.app, (singleApp) => baseOpen({
79190
- ...options,
79191
- app: singleApp
79192
- }));
79193
- }
79194
- let { name: app, arguments: appArguments = [] } = options.app ?? {};
79195
- appArguments = [...appArguments];
79196
- if (Array.isArray(app)) {
79197
- return pTryEach(app, (appName) => baseOpen({
79198
- ...options,
79199
- app: {
79200
- name: appName,
79201
- arguments: appArguments
79202
- }
79203
- }));
79204
- }
79205
- if (app === "browser" || app === "browserPrivate") {
79206
- const ids = {
79207
- "com.google.chrome": "chrome",
79208
- "google-chrome.desktop": "chrome",
79209
- "com.brave.Browser": "brave",
79210
- "org.mozilla.firefox": "firefox",
79211
- "firefox.desktop": "firefox",
79212
- "com.microsoft.msedge": "edge",
79213
- "com.microsoft.edge": "edge",
79214
- "com.microsoft.edgemac": "edge",
79215
- "microsoft-edge.desktop": "edge"
79216
- };
79217
- const flags = {
79218
- chrome: "--incognito",
79219
- brave: "--incognito",
79220
- firefox: "--private-window",
79221
- edge: "--inPrivate"
79222
- };
79223
- const browser = is_wsl_default ? await getWindowsDefaultBrowserFromWsl() : await defaultBrowser2();
79224
- if (browser.id in ids) {
79225
- const browserName = ids[browser.id];
79226
- if (app === "browserPrivate") {
79227
- appArguments.push(flags[browserName]);
79228
- }
79229
- return baseOpen({
79230
- ...options,
79231
- app: {
79232
- name: apps[browserName],
79233
- arguments: appArguments
79234
- }
79235
- });
79236
- }
79237
- throw new Error(`${browser.name} is not supported as a default browser`);
79238
- }
79239
- let command;
79240
- const cliArguments = [];
79241
- const childProcessOptions = {};
79242
- if (platform11 === "darwin") {
79243
- command = "open";
79244
- if (options.wait) {
79245
- cliArguments.push("--wait-apps");
79246
- }
79247
- if (options.background) {
79248
- cliArguments.push("--background");
79249
- }
79250
- if (options.newInstance) {
79251
- cliArguments.push("--new");
79252
- }
79253
- if (app) {
79254
- cliArguments.push("-a", app);
79255
- }
79256
- } else if (platform11 === "win32" || is_wsl_default && !isInsideContainer() && !app) {
79257
- command = await powerShellPath();
79258
- cliArguments.push(
79259
- "-NoProfile",
79260
- "-NonInteractive",
79261
- "-ExecutionPolicy",
79262
- "Bypass",
79263
- "-EncodedCommand"
79264
- );
79265
- if (!is_wsl_default) {
79266
- childProcessOptions.windowsVerbatimArguments = true;
79267
- }
79268
- const encodedArguments = ["Start"];
79269
- if (options.wait) {
79270
- encodedArguments.push("-Wait");
79271
- }
79272
- if (app) {
79273
- encodedArguments.push(`"\`"${app}\`""`);
79274
- if (options.target) {
79275
- appArguments.push(options.target);
79276
- }
79277
- } else if (options.target) {
79278
- encodedArguments.push(`"${options.target}"`);
79279
- }
79280
- if (appArguments.length > 0) {
79281
- appArguments = appArguments.map((argument) => `"\`"${argument}\`""`);
79282
- encodedArguments.push("-ArgumentList", appArguments.join(","));
79283
- }
79284
- options.target = import_node_buffer.Buffer.from(encodedArguments.join(" "), "utf16le").toString("base64");
79285
- } else {
79286
- if (app) {
79287
- command = app;
79288
- } else {
79289
- const isBundled = !__dirname2 || __dirname2 === "/";
79290
- let exeLocalXdgOpen = false;
79291
- try {
79292
- await import_promises5.default.access(localXdgOpenPath, import_promises5.constants.X_OK);
79293
- exeLocalXdgOpen = true;
79294
- } catch {
79295
- }
79296
- const useSystemXdgOpen = import_node_process15.default.versions.electron ?? (platform11 === "android" || isBundled || !exeLocalXdgOpen);
79297
- command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
79298
- }
79299
- if (appArguments.length > 0) {
79300
- cliArguments.push(...appArguments);
79301
- }
79302
- if (!options.wait) {
79303
- childProcessOptions.stdio = "ignore";
79304
- childProcessOptions.detached = true;
79305
- }
79306
- }
79307
- if (platform11 === "darwin" && appArguments.length > 0) {
79308
- cliArguments.push("--args", ...appArguments);
79309
- }
79310
- if (options.target) {
79311
- cliArguments.push(options.target);
79312
- }
79313
- const subprocess = import_node_child_process5.default.spawn(command, cliArguments, childProcessOptions);
79314
- if (options.wait) {
79315
- return new Promise((resolve18, reject) => {
79316
- subprocess.once("error", reject);
79317
- subprocess.once("close", (exitCode) => {
79318
- if (!options.allowNonzeroExitCode && exitCode > 0) {
79319
- reject(new Error(`Exited with code ${exitCode}`));
79320
- return;
79321
- }
79322
- resolve18(subprocess);
79323
- });
79324
- });
79325
- }
79326
- subprocess.unref();
79327
- return subprocess;
79328
- };
79329
- open2 = (target, options) => {
79330
- if (typeof target !== "string") {
79331
- throw new TypeError("Expected a `target`");
79332
- }
79333
- return baseOpen({
79334
- ...options,
79335
- target
79336
- });
79337
- };
79338
- apps = {};
79339
- defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
79340
- darwin: "google chrome",
79341
- win32: "chrome",
79342
- linux: ["google-chrome", "google-chrome-stable", "chromium"]
79343
- }, {
79344
- wsl: {
79345
- ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
79346
- x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
79347
- }
79348
- }));
79349
- defineLazyProperty(apps, "brave", () => detectPlatformBinary({
79350
- darwin: "brave browser",
79351
- win32: "brave",
79352
- linux: ["brave-browser", "brave"]
79353
- }, {
79354
- wsl: {
79355
- ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
79356
- x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
79357
- }
79358
- }));
79359
- defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
79360
- darwin: "firefox",
79361
- win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
79362
- linux: "firefox"
79363
- }, {
79364
- wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
79365
- }));
79366
- defineLazyProperty(apps, "edge", () => detectPlatformBinary({
79367
- darwin: "microsoft edge",
79368
- win32: "msedge",
79369
- linux: ["microsoft-edge", "microsoft-edge-dev"]
79370
- }, {
79371
- wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
79372
- }));
79373
- defineLazyProperty(apps, "browser", () => "browser");
79374
- defineLazyProperty(apps, "browserPrivate", () => "browserPrivate");
79375
- open_default = open2;
79376
- }
79377
- });
79378
-
79379
79428
  // src/version.ts
79380
79429
  function resolvePackageVersion(options) {
79381
79430
  const injectedVersion = options?.injectedVersion || "unknown";
@@ -80603,12 +80652,12 @@ var init_peer_connection_manager = __esm({
80603
80652
  });
80604
80653
 
80605
80654
  // src/daemon-p2p/index.ts
80606
- var fs20, path26, import_node_module2, esmRequire, DaemonP2PSender;
80655
+ var fs15, path25, import_node_module2, esmRequire, DaemonP2PSender;
80607
80656
  var init_daemon_p2p = __esm({
80608
80657
  "src/daemon-p2p/index.ts"() {
80609
80658
  "use strict";
80610
- fs20 = __toESM(require("fs"));
80611
- path26 = __toESM(require("path"));
80659
+ fs15 = __toESM(require("fs"));
80660
+ path25 = __toESM(require("path"));
80612
80661
  import_node_module2 = require("module");
80613
80662
  init_src();
80614
80663
  init_data_channel_router();
@@ -80682,22 +80731,22 @@ var init_daemon_p2p = __esm({
80682
80731
  log(`node-datachannel not found: ${e?.message}
80683
80732
  ${e?.stack || ""}`);
80684
80733
  }
80685
- const platform13 = process.platform;
80686
- const arch4 = process.arch;
80687
- const prebuildKey = `${platform13}-${arch4}`;
80734
+ const platform12 = process.platform;
80735
+ const arch3 = process.arch;
80736
+ const prebuildKey = `${platform12}-${arch3}`;
80688
80737
  try {
80689
80738
  const candidates = [
80690
- path26.join(__dirname, "node_modules", "node-datachannel"),
80691
- path26.join(__dirname, "..", "node_modules", "node-datachannel"),
80692
- path26.join(__dirname, "..", "..", "node_modules", "node-datachannel")
80739
+ path25.join(__dirname, "node_modules", "node-datachannel"),
80740
+ path25.join(__dirname, "..", "node_modules", "node-datachannel"),
80741
+ path25.join(__dirname, "..", "..", "node_modules", "node-datachannel")
80693
80742
  ];
80694
80743
  for (const candidate of candidates) {
80695
- const prebuildPath = path26.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
80696
- if (fs20.existsSync(prebuildPath)) {
80697
- const targetDir = path26.join(candidate, "build", "Release");
80698
- const targetPath = path26.join(targetDir, "node_datachannel.node");
80699
- fs20.mkdirSync(targetDir, { recursive: true });
80700
- fs20.copyFileSync(prebuildPath, targetPath);
80744
+ const prebuildPath = path25.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
80745
+ if (fs15.existsSync(prebuildPath)) {
80746
+ const targetDir = path25.join(candidate, "build", "Release");
80747
+ const targetPath = path25.join(targetDir, "node_datachannel.node");
80748
+ fs15.mkdirSync(targetDir, { recursive: true });
80749
+ fs15.copyFileSync(prebuildPath, targetPath);
80701
80750
  try {
80702
80751
  delete esmRequire.cache[esmRequire.resolve("node-datachannel")];
80703
80752
  } catch {
@@ -81064,27 +81113,27 @@ var require_process = __commonJS({
81064
81113
  var require_filesystem = __commonJS({
81065
81114
  "../../node_modules/detect-libc/lib/filesystem.js"(exports2, module2) {
81066
81115
  "use strict";
81067
- var fs27 = require("fs");
81116
+ var fs22 = require("fs");
81068
81117
  var LDD_PATH = "/usr/bin/ldd";
81069
81118
  var SELF_PATH = "/proc/self/exe";
81070
81119
  var MAX_LENGTH = 2048;
81071
- var readFileSync20 = (path36) => {
81072
- const fd = fs27.openSync(path36, "r");
81120
+ var readFileSync20 = (path35) => {
81121
+ const fd = fs22.openSync(path35, "r");
81073
81122
  const buffer = Buffer.alloc(MAX_LENGTH);
81074
- const bytesRead = fs27.readSync(fd, buffer, 0, MAX_LENGTH, 0);
81075
- fs27.close(fd, () => {
81123
+ const bytesRead = fs22.readSync(fd, buffer, 0, MAX_LENGTH, 0);
81124
+ fs22.close(fd, () => {
81076
81125
  });
81077
81126
  return buffer.subarray(0, bytesRead);
81078
81127
  };
81079
- var readFile = (path36) => new Promise((resolve18, reject) => {
81080
- fs27.open(path36, "r", (err, fd) => {
81128
+ var readFile = (path35) => new Promise((resolve18, reject) => {
81129
+ fs22.open(path35, "r", (err, fd) => {
81081
81130
  if (err) {
81082
81131
  reject(err);
81083
81132
  } else {
81084
81133
  const buffer = Buffer.alloc(MAX_LENGTH);
81085
- fs27.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
81134
+ fs22.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
81086
81135
  resolve18(buffer.subarray(0, bytesRead));
81087
- fs27.close(fd, () => {
81136
+ fs22.close(fd, () => {
81088
81137
  });
81089
81138
  });
81090
81139
  }
@@ -81140,7 +81189,7 @@ var require_elf = __commonJS({
81140
81189
  var require_detect_libc = __commonJS({
81141
81190
  "../../node_modules/detect-libc/lib/detect-libc.js"(exports2, module2) {
81142
81191
  "use strict";
81143
- var childProcess2 = require("child_process");
81192
+ var childProcess = require("child_process");
81144
81193
  var { isLinux: isLinux2, getReport } = require_process();
81145
81194
  var { LDD_PATH, SELF_PATH, readFile, readFileSync: readFileSync20 } = require_filesystem();
81146
81195
  var { interpreterPath } = require_elf();
@@ -81152,7 +81201,7 @@ var require_detect_libc = __commonJS({
81152
81201
  var safeCommand = () => {
81153
81202
  if (!commandOut) {
81154
81203
  return new Promise((resolve18) => {
81155
- childProcess2.exec(command, (err, out) => {
81204
+ childProcess.exec(command, (err, out) => {
81156
81205
  commandOut = err ? " " : out;
81157
81206
  resolve18(commandOut);
81158
81207
  });
@@ -81163,7 +81212,7 @@ var require_detect_libc = __commonJS({
81163
81212
  var safeCommandSync = () => {
81164
81213
  if (!commandOut) {
81165
81214
  try {
81166
- commandOut = childProcess2.execSync(command, { encoding: "utf8" });
81215
+ commandOut = childProcess.execSync(command, { encoding: "utf8" });
81167
81216
  } catch (_err) {
81168
81217
  commandOut = " ";
81169
81218
  }
@@ -81196,11 +81245,11 @@ var require_detect_libc = __commonJS({
81196
81245
  }
81197
81246
  return null;
81198
81247
  };
81199
- var familyFromInterpreterPath = (path36) => {
81200
- if (path36) {
81201
- if (path36.includes("/ld-musl-")) {
81248
+ var familyFromInterpreterPath = (path35) => {
81249
+ if (path35) {
81250
+ if (path35.includes("/ld-musl-")) {
81202
81251
  return MUSL;
81203
- } else if (path36.includes("/ld-linux-")) {
81252
+ } else if (path35.includes("/ld-linux-")) {
81204
81253
  return GLIBC;
81205
81254
  }
81206
81255
  }
@@ -81247,8 +81296,8 @@ var require_detect_libc = __commonJS({
81247
81296
  cachedFamilyInterpreter = null;
81248
81297
  try {
81249
81298
  const selfContent = await readFile(SELF_PATH);
81250
- const path36 = interpreterPath(selfContent);
81251
- cachedFamilyInterpreter = familyFromInterpreterPath(path36);
81299
+ const path35 = interpreterPath(selfContent);
81300
+ cachedFamilyInterpreter = familyFromInterpreterPath(path35);
81252
81301
  } catch (e) {
81253
81302
  }
81254
81303
  return cachedFamilyInterpreter;
@@ -81260,8 +81309,8 @@ var require_detect_libc = __commonJS({
81260
81309
  cachedFamilyInterpreter = null;
81261
81310
  try {
81262
81311
  const selfContent = readFileSync20(SELF_PATH);
81263
- const path36 = interpreterPath(selfContent);
81264
- cachedFamilyInterpreter = familyFromInterpreterPath(path36);
81312
+ const path35 = interpreterPath(selfContent);
81313
+ cachedFamilyInterpreter = familyFromInterpreterPath(path35);
81265
81314
  } catch (e) {
81266
81315
  }
81267
81316
  return cachedFamilyInterpreter;
@@ -82980,18 +83029,18 @@ var require_sharp = __commonJS({
82980
83029
  `@img/sharp-${runtimePlatform}/sharp.node`,
82981
83030
  "@img/sharp-wasm32/sharp.node"
82982
83031
  ];
82983
- var path36;
83032
+ var path35;
82984
83033
  var sharp;
82985
83034
  var errors = [];
82986
- for (path36 of paths) {
83035
+ for (path35 of paths) {
82987
83036
  try {
82988
- sharp = require(path36);
83037
+ sharp = require(path35);
82989
83038
  break;
82990
83039
  } catch (err) {
82991
83040
  errors.push(err);
82992
83041
  }
82993
83042
  }
82994
- if (sharp && path36.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
83043
+ if (sharp && path35.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
82995
83044
  const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
82996
83045
  err.code = "Unsupported CPU";
82997
83046
  errors.push(err);
@@ -83000,7 +83049,7 @@ var require_sharp = __commonJS({
83000
83049
  if (sharp) {
83001
83050
  module2.exports = sharp;
83002
83051
  } else {
83003
- const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((os31) => runtimePlatform.startsWith(os31));
83052
+ const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((os30) => runtimePlatform.startsWith(os30));
83004
83053
  const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
83005
83054
  errors.forEach((err) => {
83006
83055
  if (err.code !== "MODULE_NOT_FOUND") {
@@ -83017,15 +83066,15 @@ var require_sharp = __commonJS({
83017
83066
  ` Requires ${expected}`
83018
83067
  );
83019
83068
  } else if (prebuiltPlatforms.includes(runtimePlatform)) {
83020
- const [os31, cpu] = runtimePlatform.split("-");
83021
- const libc = os31.endsWith("musl") ? " --libc=musl" : "";
83069
+ const [os30, cpu] = runtimePlatform.split("-");
83070
+ const libc = os30.endsWith("musl") ? " --libc=musl" : "";
83022
83071
  help.push(
83023
83072
  "- Ensure optional dependencies can be installed:",
83024
83073
  " npm install --include=optional sharp",
83025
83074
  "- Ensure your package manager supports multi-platform installation:",
83026
83075
  " See https://sharp.pixelplumbing.com/install#cross-platform",
83027
83076
  "- Add platform-specific dependencies:",
83028
- ` npm install --os=${os31.replace("musl", "")}${libc} --cpu=${cpu} sharp`
83077
+ ` npm install --os=${os30.replace("musl", "")}${libc} --cpu=${cpu} sharp`
83029
83078
  );
83030
83079
  } else {
83031
83080
  help.push(
@@ -85900,15 +85949,15 @@ var require_color = __commonJS({
85900
85949
  };
85901
85950
  }
85902
85951
  function wrapConversion(toModel, graph) {
85903
- const path36 = [graph[toModel].parent, toModel];
85952
+ const path35 = [graph[toModel].parent, toModel];
85904
85953
  let fn = conversions_default[graph[toModel].parent][toModel];
85905
85954
  let cur = graph[toModel].parent;
85906
85955
  while (graph[cur].parent) {
85907
- path36.unshift(graph[cur].parent);
85956
+ path35.unshift(graph[cur].parent);
85908
85957
  fn = link(conversions_default[graph[cur].parent][cur], fn);
85909
85958
  cur = graph[cur].parent;
85910
85959
  }
85911
- fn.conversion = path36;
85960
+ fn.conversion = path35;
85912
85961
  return fn;
85913
85962
  }
85914
85963
  function route(fromModel) {
@@ -86525,7 +86574,7 @@ var require_channel = __commonJS({
86525
86574
  var require_output = __commonJS({
86526
86575
  "../../node_modules/sharp/lib/output.js"(exports2, module2) {
86527
86576
  "use strict";
86528
- var path36 = require("path");
86577
+ var path35 = require("path");
86529
86578
  var is = require_is();
86530
86579
  var sharp = require_sharp();
86531
86580
  var formats = /* @__PURE__ */ new Map([
@@ -86556,9 +86605,9 @@ var require_output = __commonJS({
86556
86605
  let err;
86557
86606
  if (!is.string(fileOut)) {
86558
86607
  err = new Error("Missing output file path");
86559
- } else if (is.string(this.options.input.file) && path36.resolve(this.options.input.file) === path36.resolve(fileOut)) {
86608
+ } else if (is.string(this.options.input.file) && path35.resolve(this.options.input.file) === path35.resolve(fileOut)) {
86560
86609
  err = new Error("Cannot use same file for input and output");
86561
- } else if (jp2Regex.test(path36.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
86610
+ } else if (jp2Regex.test(path35.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
86562
86611
  err = errJp2Save();
86563
86612
  }
86564
86613
  if (err) {
@@ -87832,21 +87881,21 @@ function quarantineLegacyStandaloneSessions(options) {
87832
87881
  if (shouldSkipForExplicitOverride(env3)) {
87833
87882
  return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
87834
87883
  }
87835
- const homeDir = options.homeDir || os26.homedir();
87884
+ const homeDir = options.homeDir || os25.homedir();
87836
87885
  const now = options.now || (() => /* @__PURE__ */ new Date());
87837
87886
  const isPidRunning = options.isPidRunning || defaultPidRunning;
87838
- const runtimesDir = path27.join(homeDir, ".adhdev", "session-host", options.appName, "runtimes");
87839
- if (!fs21.existsSync(runtimesDir)) {
87887
+ const runtimesDir = path26.join(homeDir, ".adhdev", "session-host", options.appName, "runtimes");
87888
+ if (!fs16.existsSync(runtimesDir)) {
87840
87889
  return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
87841
87890
  }
87842
- const candidates = fs21.readdirSync(runtimesDir).filter((name) => name.endsWith(".json")).map((name) => path27.join(runtimesDir, name));
87891
+ const candidates = fs16.readdirSync(runtimesDir).filter((name) => name.endsWith(".json")).map((name) => path26.join(runtimesDir, name));
87843
87892
  let movedCount = 0;
87844
87893
  let skippedActiveCount = 0;
87845
87894
  let backupDir = null;
87846
87895
  for (const sourcePath of candidates) {
87847
87896
  let parsed;
87848
87897
  try {
87849
- parsed = JSON.parse(fs21.readFileSync(sourcePath, "utf8"));
87898
+ parsed = JSON.parse(fs16.readFileSync(sourcePath, "utf8"));
87850
87899
  } catch {
87851
87900
  continue;
87852
87901
  }
@@ -87857,26 +87906,26 @@ function quarantineLegacyStandaloneSessions(options) {
87857
87906
  continue;
87858
87907
  }
87859
87908
  if (!backupDir) {
87860
- backupDir = path27.join(
87909
+ backupDir = path26.join(
87861
87910
  homeDir,
87862
87911
  ".adhdev",
87863
87912
  "session-host-backups",
87864
87913
  `legacy-standalone-${options.appName}-${formatTimestamp(now())}`
87865
87914
  );
87866
- fs21.mkdirSync(path27.join(backupDir, "runtimes"), { recursive: true });
87915
+ fs16.mkdirSync(path26.join(backupDir, "runtimes"), { recursive: true });
87867
87916
  }
87868
- fs21.renameSync(sourcePath, path27.join(backupDir, "runtimes", path27.basename(sourcePath)));
87917
+ fs16.renameSync(sourcePath, path26.join(backupDir, "runtimes", path26.basename(sourcePath)));
87869
87918
  movedCount += 1;
87870
87919
  }
87871
87920
  return { movedCount, skippedActiveCount, backupDir };
87872
87921
  }
87873
- var fs21, os26, path27, LEGACY_STANDALONE_MANAGER_TAG;
87922
+ var fs16, os25, path26, LEGACY_STANDALONE_MANAGER_TAG;
87874
87923
  var init_session_host_hygiene = __esm({
87875
87924
  "src/session-host-hygiene.ts"() {
87876
87925
  "use strict";
87877
- fs21 = __toESM(require("fs"));
87878
- os26 = __toESM(require("os"));
87879
- path27 = __toESM(require("path"));
87926
+ fs16 = __toESM(require("fs"));
87927
+ os25 = __toESM(require("os"));
87928
+ path26 = __toESM(require("path"));
87880
87929
  init_src();
87881
87930
  LEGACY_STANDALONE_MANAGER_TAG = "adhdev-standalone";
87882
87931
  }
@@ -87900,18 +87949,18 @@ function buildSessionHostEnv(baseEnv) {
87900
87949
  }
87901
87950
  function resolveSessionHostEntry() {
87902
87951
  const packagedCandidates = [
87903
- path28.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
87904
- path28.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
87952
+ path27.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
87953
+ path27.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
87905
87954
  ];
87906
87955
  for (const candidate of packagedCandidates) {
87907
- if (fs22.existsSync(candidate)) {
87956
+ if (fs17.existsSync(candidate)) {
87908
87957
  return candidate;
87909
87958
  }
87910
87959
  }
87911
87960
  return require.resolve("@adhdev/session-host-daemon");
87912
87961
  }
87913
87962
  function getSessionHostPidFile() {
87914
- return path28.join(os27.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
87963
+ return path27.join(os26.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
87915
87964
  }
87916
87965
  function getSessionHostStatusPaths() {
87917
87966
  return {
@@ -87922,8 +87971,8 @@ function getSessionHostStatusPaths() {
87922
87971
  function getSessionHostPid() {
87923
87972
  try {
87924
87973
  const pidFile = getSessionHostPidFile();
87925
- if (!fs22.existsSync(pidFile)) return null;
87926
- const pid = Number.parseInt(fs22.readFileSync(pidFile, "utf8").trim(), 10);
87974
+ if (!fs17.existsSync(pidFile)) return null;
87975
+ const pid = Number.parseInt(fs17.readFileSync(pidFile, "utf8").trim(), 10);
87927
87976
  return Number.isFinite(pid) ? pid : null;
87928
87977
  } catch {
87929
87978
  return null;
@@ -87993,8 +88042,8 @@ function stopManagedSessionHostProcess() {
87993
88042
  let stopped = false;
87994
88043
  const pidFile = getSessionHostPidFile();
87995
88044
  try {
87996
- if (fs22.existsSync(pidFile)) {
87997
- const pid = Number.parseInt(fs22.readFileSync(pidFile, "utf8").trim(), 10);
88045
+ if (fs17.existsSync(pidFile)) {
88046
+ const pid = Number.parseInt(fs17.readFileSync(pidFile, "utf8").trim(), 10);
87998
88047
  if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid2(pid)) {
87999
88048
  stopped = killPid2(pid) || stopped;
88000
88049
  }
@@ -88002,7 +88051,7 @@ function stopManagedSessionHostProcess() {
88002
88051
  } catch {
88003
88052
  } finally {
88004
88053
  try {
88005
- fs22.unlinkSync(pidFile);
88054
+ fs17.unlinkSync(pidFile);
88006
88055
  } catch {
88007
88056
  }
88008
88057
  }
@@ -88030,9 +88079,9 @@ async function ensureSessionHostReady2() {
88030
88079
  }
88031
88080
  const spawnHost = () => {
88032
88081
  const entry = resolveSessionHostEntry();
88033
- const logDir = path28.join(os27.homedir(), ".adhdev", "logs");
88034
- fs22.mkdirSync(logDir, { recursive: true });
88035
- const logFd = fs22.openSync(path28.join(logDir, "session-host.log"), "a");
88082
+ const logDir = path27.join(os26.homedir(), ".adhdev", "logs");
88083
+ fs17.mkdirSync(logDir, { recursive: true });
88084
+ const logFd = fs17.openSync(path27.join(logDir, "session-host.log"), "a");
88036
88085
  const child = (0, import_child_process13.spawn)(process.execPath, [entry], {
88037
88086
  detached: true,
88038
88087
  stdio: ["ignore", logFd, logFd],
@@ -88041,7 +88090,7 @@ async function ensureSessionHostReady2() {
88041
88090
  });
88042
88091
  child.unref();
88043
88092
  try {
88044
- fs22.closeSync(logFd);
88093
+ fs17.closeSync(logFd);
88045
88094
  } catch {
88046
88095
  }
88047
88096
  };
@@ -88094,14 +88143,14 @@ async function probeSessionHostStatus() {
88094
88143
  };
88095
88144
  }
88096
88145
  }
88097
- var import_child_process13, fs22, os27, path28, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
88146
+ var import_child_process13, fs17, os26, path27, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
88098
88147
  var init_session_host = __esm({
88099
88148
  "src/session-host.ts"() {
88100
88149
  "use strict";
88101
88150
  import_child_process13 = require("child_process");
88102
- fs22 = __toESM(require("fs"));
88103
- os27 = __toESM(require("os"));
88104
- path28 = __toESM(require("path"));
88151
+ fs17 = __toESM(require("fs"));
88152
+ os26 = __toESM(require("os"));
88153
+ path27 = __toESM(require("path"));
88105
88154
  init_src();
88106
88155
  init_dist();
88107
88156
  init_session_host_hygiene();
@@ -88329,29 +88378,29 @@ function resolveDaemonPort(ref = {}) {
88329
88378
  return Number.isFinite(ref.port) && Number(ref.port) > 0 ? Number(ref.port) : DEFAULT_DAEMON_PORT;
88330
88379
  }
88331
88380
  function getDaemonPidFile(ref = {}) {
88332
- const dir = path29.join(ref.homeDir || os28.homedir(), ".adhdev");
88333
- if (!fs23.existsSync(dir)) fs23.mkdirSync(dir, { recursive: true });
88381
+ const dir = path28.join(ref.homeDir || os27.homedir(), ".adhdev");
88382
+ if (!fs18.existsSync(dir)) fs18.mkdirSync(dir, { recursive: true });
88334
88383
  const port = resolveDaemonPort(ref);
88335
- return path29.join(dir, port === DEFAULT_DAEMON_PORT ? "daemon.pid" : `daemon-${port}.pid`);
88384
+ return path28.join(dir, port === DEFAULT_DAEMON_PORT ? "daemon.pid" : `daemon-${port}.pid`);
88336
88385
  }
88337
88386
  function writeDaemonPid(pid, ref = {}) {
88338
88387
  const pidFile = getDaemonPidFile(ref);
88339
88388
  try {
88340
- fs23.writeFileSync(pidFile, String(pid), { encoding: "utf-8", flag: "wx" });
88389
+ fs18.writeFileSync(pidFile, String(pid), { encoding: "utf-8", flag: "wx" });
88341
88390
  } catch {
88342
- fs23.writeFileSync(pidFile, String(pid), "utf-8");
88391
+ fs18.writeFileSync(pidFile, String(pid), "utf-8");
88343
88392
  }
88344
88393
  }
88345
88394
  function removeDaemonPid(ref = {}) {
88346
88395
  try {
88347
- fs23.unlinkSync(getDaemonPidFile(ref));
88396
+ fs18.unlinkSync(getDaemonPidFile(ref));
88348
88397
  } catch (e) {
88349
88398
  }
88350
88399
  }
88351
88400
  function isDaemonRunning(ref = {}) {
88352
88401
  const port = resolveDaemonPort(ref);
88353
88402
  try {
88354
- const { execFileSync: execFileSync7 } = require("child_process");
88403
+ const { execFileSync: execFileSync6 } = require("child_process");
88355
88404
  const probe = `
88356
88405
  const http = require('http');
88357
88406
  const req = http.get('http://127.0.0.1:${port}/health', { timeout: 1500 }, (res) => {
@@ -88361,7 +88410,7 @@ function isDaemonRunning(ref = {}) {
88361
88410
  req.on('error', () => process.stdout.write('0'));
88362
88411
  req.on('timeout', () => { req.destroy(); process.stdout.write('0'); });
88363
88412
  `;
88364
- const result = execFileSync7(process.execPath, ["-e", probe], {
88413
+ const result = execFileSync6(process.execPath, ["-e", probe], {
88365
88414
  encoding: "utf-8",
88366
88415
  timeout: 3e3,
88367
88416
  stdio: ["ignore", "pipe", "ignore"]
@@ -88371,8 +88420,8 @@ function isDaemonRunning(ref = {}) {
88371
88420
  }
88372
88421
  const pidFile = getDaemonPidFile(ref);
88373
88422
  try {
88374
- if (!fs23.existsSync(pidFile)) return false;
88375
- const pid = parseInt(fs23.readFileSync(pidFile, "utf-8").trim());
88423
+ if (!fs18.existsSync(pidFile)) return false;
88424
+ const pid = parseInt(fs18.readFileSync(pidFile, "utf-8").trim());
88376
88425
  process.kill(pid, 0);
88377
88426
  if (!isAdhdevProcess(pid)) {
88378
88427
  removeDaemonPid(ref);
@@ -88387,9 +88436,9 @@ function isDaemonRunning(ref = {}) {
88387
88436
  function isAdhdevProcess(pid) {
88388
88437
  try {
88389
88438
  if (process.platform === "win32") {
88390
- const { execFileSync: execFileSync7 } = require("child_process");
88439
+ const { execFileSync: execFileSync6 } = require("child_process");
88391
88440
  try {
88392
- const psOut = execFileSync7("powershell.exe", [
88441
+ const psOut = execFileSync6("powershell.exe", [
88393
88442
  "-NoProfile",
88394
88443
  "-NonInteractive",
88395
88444
  "-ExecutionPolicy",
@@ -88402,8 +88451,8 @@ function isAdhdevProcess(pid) {
88402
88451
  return true;
88403
88452
  }
88404
88453
  } else {
88405
- const { execFileSync: execFileSync7 } = require("child_process");
88406
- const cmdline = execFileSync7("ps", ["-o", "command=", "-p", String(pid)], {
88454
+ const { execFileSync: execFileSync6 } = require("child_process");
88455
+ const cmdline = execFileSync6("ps", ["-o", "command=", "-p", String(pid)], {
88407
88456
  encoding: "utf-8",
88408
88457
  timeout: 2e3,
88409
88458
  stdio: ["ignore", "pipe", "ignore"]
@@ -88417,7 +88466,7 @@ function isAdhdevProcess(pid) {
88417
88466
  function getDaemonHealthPid(ref = {}) {
88418
88467
  const port = resolveDaemonPort(ref);
88419
88468
  try {
88420
- const { execFileSync: execFileSync7 } = require("child_process");
88469
+ const { execFileSync: execFileSync6 } = require("child_process");
88421
88470
  const probe = `
88422
88471
  const http = require('http');
88423
88472
  const req = http.get('http://127.0.0.1:${port}/health', { timeout: 1500 }, (res) => {
@@ -88435,7 +88484,7 @@ function getDaemonHealthPid(ref = {}) {
88435
88484
  req.on('error', () => {});
88436
88485
  req.on('timeout', () => { req.destroy(); });
88437
88486
  `;
88438
- const result = execFileSync7(process.execPath, ["-e", probe], {
88487
+ const result = execFileSync6(process.execPath, ["-e", probe], {
88439
88488
  encoding: "utf-8",
88440
88489
  timeout: 3e3,
88441
88490
  stdio: ["ignore", "pipe", "ignore"]
@@ -88449,8 +88498,8 @@ function getDaemonHealthPid(ref = {}) {
88449
88498
  function getDaemonPid(ref = {}) {
88450
88499
  const pidFile = getDaemonPidFile(ref);
88451
88500
  try {
88452
- if (fs23.existsSync(pidFile)) {
88453
- const pid = parseInt(fs23.readFileSync(pidFile, "utf-8").trim(), 10);
88501
+ if (fs18.existsSync(pidFile)) {
88502
+ const pid = parseInt(fs18.readFileSync(pidFile, "utf-8").trim(), 10);
88454
88503
  if (Number.isFinite(pid)) return pid;
88455
88504
  }
88456
88505
  } catch {
@@ -88461,8 +88510,8 @@ function stopDaemon(ref = {}) {
88461
88510
  const pidFile = getDaemonPidFile(ref);
88462
88511
  let pid = null;
88463
88512
  try {
88464
- if (fs23.existsSync(pidFile)) {
88465
- const pidFromFile = parseInt(fs23.readFileSync(pidFile, "utf-8").trim(), 10);
88513
+ if (fs18.existsSync(pidFile)) {
88514
+ const pidFromFile = parseInt(fs18.readFileSync(pidFile, "utf-8").trim(), 10);
88466
88515
  if (Number.isFinite(pidFromFile)) pid = pidFromFile;
88467
88516
  }
88468
88517
  } catch {
@@ -88481,7 +88530,7 @@ function stopDaemon(ref = {}) {
88481
88530
  return false;
88482
88531
  }
88483
88532
  }
88484
- var os28, fs23, path29, import_http, import_child_process14, import_ws3, pkgVersion, AdhdevDaemon;
88533
+ var os27, fs18, path28, import_http, import_child_process14, import_ws3, pkgVersion, AdhdevDaemon;
88485
88534
  var init_adhdev_daemon = __esm({
88486
88535
  "src/adhdev-daemon.ts"() {
88487
88536
  "use strict";
@@ -88493,9 +88542,9 @@ var init_adhdev_daemon = __esm({
88493
88542
  init_startup_restore_policy();
88494
88543
  init_dist();
88495
88544
  init_session_host_controller();
88496
- os28 = __toESM(require("os"));
88497
- fs23 = __toESM(require("fs"));
88498
- path29 = __toESM(require("path"));
88545
+ os27 = __toESM(require("os"));
88546
+ fs18 = __toESM(require("fs"));
88547
+ path28 = __toESM(require("path"));
88499
88548
  import_http = require("http");
88500
88549
  import_child_process14 = require("child_process");
88501
88550
  import_ws3 = require("ws");
@@ -88503,7 +88552,7 @@ var init_adhdev_daemon = __esm({
88503
88552
  init_version();
88504
88553
  init_src();
88505
88554
  init_runtime_defaults();
88506
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.44" });
88555
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.45" });
88507
88556
  AdhdevDaemon = class _AdhdevDaemon {
88508
88557
  localHttpServer = null;
88509
88558
  localWss = null;
@@ -89027,8 +89076,8 @@ ${err?.stack || ""}`);
89027
89076
  cliInfo: {
89028
89077
  type: "adhdev-daemon",
89029
89078
  version: pkgVersion,
89030
- platform: os28.platform(),
89031
- hostname: os28.hostname(),
89079
+ platform: os27.platform(),
89080
+ hostname: os27.hostname(),
89032
89081
  machineId: config2.machineId,
89033
89082
  instanceId
89034
89083
  }
@@ -89627,6 +89676,10 @@ var wizard_exports = {};
89627
89676
  __export(wizard_exports, {
89628
89677
  runWizard: () => runWizard
89629
89678
  });
89679
+ async function openBrowser(url2) {
89680
+ const mod = await import("open");
89681
+ return mod.default(url2);
89682
+ }
89630
89683
  function hasCloudMachineAuth() {
89631
89684
  const config2 = loadConfig();
89632
89685
  return Boolean(config2.machineSecret && config2.machineSecret.trim());
@@ -89676,9 +89729,9 @@ async function runWizard(options = {}) {
89676
89729
  }
89677
89730
  async function checkForUpdate() {
89678
89731
  try {
89679
- const { execFileSync: execFileSync7 } = await import("child_process");
89732
+ const { execFileSync: execFileSync6 } = await import("child_process");
89680
89733
  const currentVersion = resolvePackageVersion();
89681
- const latestVersion = readLatestPublishedCliVersion(execFileSync7);
89734
+ const latestVersion = readLatestPublishedCliVersion(execFileSync6);
89682
89735
  if (!latestVersion) return;
89683
89736
  if (!currentVersion || !latestVersion || currentVersion === latestVersion) return;
89684
89737
  console.log(source_default.yellow(` Update available: ${currentVersion} \u2192 ${latestVersion}`));
@@ -89695,7 +89748,7 @@ async function checkForUpdate() {
89695
89748
  const spinner = (await Promise.resolve().then(() => (init_ora(), ora_exports))).default("Updating adhdev CLI...").start();
89696
89749
  try {
89697
89750
  const installCommand = buildPinnedGlobalInstallCommand({ packageName: "adhdev", targetVersion: "latest" });
89698
- execFileSync7(installCommand.command, installCommand.args, {
89751
+ execFileSync6(installCommand.command, installCommand.args, {
89699
89752
  encoding: "utf-8",
89700
89753
  timeout: 6e4,
89701
89754
  stdio: ["pipe", "pipe", "pipe"]
@@ -89779,15 +89832,15 @@ async function loginFlow() {
89779
89832
  let verificationUrl;
89780
89833
  try {
89781
89834
  const config2 = loadConfig();
89782
- const os31 = await import("os");
89835
+ const os30 = await import("os");
89783
89836
  const res = await fetch(`${SERVER_URL}/auth/cli/init`, {
89784
89837
  method: "POST",
89785
89838
  headers: { "Content-Type": "application/json" },
89786
89839
  body: JSON.stringify({
89787
89840
  clientMachineId: config2.machineId,
89788
- hostname: os31.hostname(),
89789
- platform: os31.platform(),
89790
- arch: os31.arch()
89841
+ hostname: os30.hostname(),
89842
+ platform: os30.platform(),
89843
+ arch: os30.arch()
89791
89844
  })
89792
89845
  });
89793
89846
  if (!res.ok) {
@@ -89811,7 +89864,7 @@ async function loginFlow() {
89811
89864
  console.log(source_default.gray(` Opening: ${verificationUrl}`));
89812
89865
  console.log();
89813
89866
  try {
89814
- await open_default(verificationUrl);
89867
+ await openBrowser(verificationUrl);
89815
89868
  console.log(source_default.green(" \u2713 Browser opened \u2014 please sign in and approve"));
89816
89869
  } catch {
89817
89870
  console.log(source_default.yellow(` \u26A0 Could not open browser. Visit: ${verificationUrl}`));
@@ -89892,10 +89945,10 @@ async function startDaemonFlow() {
89892
89945
  const { execSync: execSync8 } = await import("child_process");
89893
89946
  const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
89894
89947
  const logPath = getCurrentDaemonLogPath2();
89895
- const os31 = await import("os");
89896
- const platform13 = os31.platform();
89948
+ const os30 = await import("os");
89949
+ const platform12 = os30.platform();
89897
89950
  try {
89898
- if (platform13 === "win32") {
89951
+ if (platform12 === "win32") {
89899
89952
  execSync8("start /B adhdev daemon >NUL 2>&1", {
89900
89953
  timeout: 3e3,
89901
89954
  stdio: "ignore",
@@ -90008,7 +90061,6 @@ var init_wizard = __esm({
90008
90061
  init_source();
90009
90062
  init_lib();
90010
90063
  init_ora();
90011
- init_open();
90012
90064
  init_src();
90013
90065
  init_version();
90014
90066
  SERVER_URL = process.env.ADHDEV_SERVER_URL || "https://api.adhf.dev";
@@ -91041,7 +91093,7 @@ init_source();
91041
91093
  init_src();
91042
91094
 
91043
91095
  // src/cli/setup-commands.ts
91044
- var import_node_path4 = __toESM(require("path"));
91096
+ var import_node_path3 = __toESM(require("path"));
91045
91097
  init_source();
91046
91098
  init_src();
91047
91099
 
@@ -91194,7 +91246,7 @@ function parsePositiveInteger(value, fallback2) {
91194
91246
  return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback2;
91195
91247
  }
91196
91248
  function buildHistoryResumeLaunchPayload(cliType, session, overrideDir) {
91197
- const dir = typeof overrideDir === "string" && overrideDir.trim() ? import_node_path4.default.resolve(overrideDir.trim()) : typeof session.workspace === "string" && session.workspace.trim() ? import_node_path4.default.resolve(session.workspace.trim()) : "";
91249
+ const dir = typeof overrideDir === "string" && overrideDir.trim() ? import_node_path3.default.resolve(overrideDir.trim()) : typeof session.workspace === "string" && session.workspace.trim() ? import_node_path3.default.resolve(session.workspace.trim()) : "";
91198
91250
  if (!dir) {
91199
91251
  throw new Error(`Saved history ${session.providerSessionId} is missing workspace metadata. Pass --dir to resume it explicitly.`);
91200
91252
  }
@@ -91314,7 +91366,7 @@ function registerSetupCommands(program2, getProviderLoader2) {
91314
91366
  console.log(source_default.gray(" Then run: adhdev launch " + targetArg));
91315
91367
  process.exit(1);
91316
91368
  }
91317
- const resolvedDir = import_node_path4.default.resolve(workingDir);
91369
+ const resolvedDir = import_node_path3.default.resolve(workingDir);
91318
91370
  const result = await sendDaemonCommand("launch_cli", {
91319
91371
  cliType,
91320
91372
  dir: resolvedDir
@@ -91786,9 +91838,9 @@ function registerSetupCommands(program2, getProviderLoader2) {
91786
91838
  });
91787
91839
  program2.command("uninstall").description("Completely wipe all setting, configuration, stop daemon and uninstall service").option("-f, --force", "Skip confirmation prompt").action(async (options) => {
91788
91840
  const inquirer2 = await Promise.resolve().then(() => (init_lib(), lib_exports));
91789
- const fs27 = await import("fs");
91790
- const path36 = await import("path");
91791
- const os31 = await import("os");
91841
+ const fs22 = await import("fs");
91842
+ const path35 = await import("path");
91843
+ const os30 = await import("os");
91792
91844
  const { spawnSync: spawnSync3 } = await import("child_process");
91793
91845
  if (!options.force) {
91794
91846
  const { confirm } = await inquirer2.default.prompt([
@@ -91813,11 +91865,11 @@ function registerSetupCommands(program2, getProviderLoader2) {
91813
91865
  }
91814
91866
  console.log(source_default.gray(" Removing OS background service..."));
91815
91867
  spawnSync3(process.execPath, [process.argv[1], "service", "uninstall"], { stdio: "inherit" });
91816
- const adhdevDir = path36.join(os31.homedir(), ".adhdev");
91817
- if (fs27.existsSync(adhdevDir)) {
91868
+ const adhdevDir = path35.join(os30.homedir(), ".adhdev");
91869
+ if (fs22.existsSync(adhdevDir)) {
91818
91870
  console.log(source_default.gray(` Deleting ${adhdevDir}...`));
91819
91871
  try {
91820
- fs27.rmSync(adhdevDir, { recursive: true, force: true });
91872
+ fs22.rmSync(adhdevDir, { recursive: true, force: true });
91821
91873
  console.log(source_default.green(" \u2713 Data wiped."));
91822
91874
  } catch (e) {
91823
91875
  console.log(source_default.red(` \u2717 Failed to delete ~/.adhdev: ${e.message}`));
@@ -91836,11 +91888,11 @@ init_source();
91836
91888
  init_src();
91837
91889
 
91838
91890
  // src/cli/runtime-tools.ts
91839
- var fs24 = __toESM(require("fs"));
91840
- var path31 = __toESM(require("path"));
91891
+ var fs19 = __toESM(require("fs"));
91892
+ var path30 = __toESM(require("path"));
91841
91893
  function defaultPackageRoot() {
91842
- const currentCliPath = process.argv[1] ? fs24.realpathSync.native(process.argv[1]) : process.cwd();
91843
- return path31.resolve(path31.dirname(currentCliPath), "../..");
91894
+ const currentCliPath = process.argv[1] ? fs19.realpathSync.native(process.argv[1]) : process.cwd();
91895
+ return path30.resolve(path30.dirname(currentCliPath), "../..");
91844
91896
  }
91845
91897
  function normalizePath2(value) {
91846
91898
  return value.replace(/\\/g, "/").toLowerCase();
@@ -91849,19 +91901,19 @@ function shouldPreferSource(currentCliPath, packageRoot) {
91849
91901
  const normalizedCliPath = normalizePath2(currentCliPath || "");
91850
91902
  if (normalizedCliPath.includes("/src/cli/")) return true;
91851
91903
  if (normalizedCliPath.includes("/dist/cli/")) return false;
91852
- return fs24.existsSync(path31.join(packageRoot, "src", "cli", "index.ts"));
91904
+ return fs19.existsSync(path30.join(packageRoot, "src", "cli", "index.ts"));
91853
91905
  }
91854
91906
  function getVendoredToolEntry(packageRoot, tool) {
91855
91907
  if (tool === "session-host-daemon") {
91856
- return path31.join(packageRoot, "vendor", "session-host-daemon", "index.js");
91908
+ return path30.join(packageRoot, "vendor", "session-host-daemon", "index.js");
91857
91909
  }
91858
- return path31.join(packageRoot, "vendor", "terminal-mux-cli", "index.js");
91910
+ return path30.join(packageRoot, "vendor", "terminal-mux-cli", "index.js");
91859
91911
  }
91860
91912
  function getSourceToolEntry(packageRoot, tool) {
91861
91913
  if (tool === "session-host-daemon") {
91862
- return path31.resolve(packageRoot, "../../oss/packages/session-host-daemon/src/index.ts");
91914
+ return path30.resolve(packageRoot, "../../oss/packages/session-host-daemon/src/index.ts");
91863
91915
  }
91864
- return path31.resolve(packageRoot, "../../oss/packages/terminal-mux-cli/src/index.ts");
91916
+ return path30.resolve(packageRoot, "../../oss/packages/terminal-mux-cli/src/index.ts");
91865
91917
  }
91866
91918
  function getGlobalToolCommand(tool) {
91867
91919
  return tool === "session-host-daemon" ? "adhdev-sessiond" : "adhmux";
@@ -91874,7 +91926,7 @@ function resolveRuntimeToolLaunch(tool, context = {}) {
91874
91926
  const vendoredEntry = getVendoredToolEntry(packageRoot, tool);
91875
91927
  const resolutionOrder = preferSource ? ["source", "vendored", "global"] : ["vendored", "source", "global"];
91876
91928
  for (const resolution of resolutionOrder) {
91877
- if (resolution === "source" && fs24.existsSync(sourceEntry)) {
91929
+ if (resolution === "source" && fs19.existsSync(sourceEntry)) {
91878
91930
  return {
91879
91931
  tool,
91880
91932
  resolvedVia: "source",
@@ -91883,7 +91935,7 @@ function resolveRuntimeToolLaunch(tool, context = {}) {
91883
91935
  env: env3
91884
91936
  };
91885
91937
  }
91886
- if (resolution === "vendored" && fs24.existsSync(vendoredEntry)) {
91938
+ if (resolution === "vendored" && fs19.existsSync(vendoredEntry)) {
91887
91939
  return {
91888
91940
  tool,
91889
91941
  resolvedVia: "vendored",
@@ -93014,9 +93066,9 @@ function registerDaemonCommands(program2, pkgVersion3) {
93014
93066
  // src/cli/doctor-commands.ts
93015
93067
  init_source();
93016
93068
  var import_child_process15 = require("child_process");
93017
- var fs26 = __toESM(require("fs"));
93018
- var os30 = __toESM(require("os"));
93019
- var path34 = __toESM(require("path"));
93069
+ var fs21 = __toESM(require("fs"));
93070
+ var os29 = __toESM(require("os"));
93071
+ var path33 = __toESM(require("path"));
93020
93072
  init_src();
93021
93073
  init_session_host();
93022
93074
 
@@ -93132,33 +93184,33 @@ function buildDoctorAdvice(input) {
93132
93184
  }
93133
93185
 
93134
93186
  // src/cli/service-commands.ts
93135
- var import_node_fs6 = __toESM(require("fs"));
93136
- var import_node_path5 = __toESM(require("path"));
93137
- var import_node_os6 = __toESM(require("os"));
93138
- var import_node_child_process6 = require("child_process");
93187
+ var import_node_fs3 = __toESM(require("fs"));
93188
+ var import_node_path4 = __toESM(require("path"));
93189
+ var import_node_os5 = __toESM(require("os"));
93190
+ var import_node_child_process = require("child_process");
93139
93191
  init_source();
93140
93192
  init_src();
93141
93193
  var DEFAULT_LOCAL_DAEMON_HEALTH_TIMEOUT_MS3 = 1500;
93142
93194
  var LAUNCHD_LABEL = "dev.adhf.daemon";
93143
- var ADHDEV_DIR = import_node_path5.default.join(import_node_os6.default.homedir(), ".adhdev");
93144
- var LOG_OUT = import_node_path5.default.join(ADHDEV_DIR, "daemon-launchd.out");
93145
- var LOG_ERR = import_node_path5.default.join(ADHDEV_DIR, "daemon-launchd.err");
93195
+ var ADHDEV_DIR = import_node_path4.default.join(import_node_os5.default.homedir(), ".adhdev");
93196
+ var LOG_OUT = import_node_path4.default.join(ADHDEV_DIR, "daemon-launchd.out");
93197
+ var LOG_ERR = import_node_path4.default.join(ADHDEV_DIR, "daemon-launchd.err");
93146
93198
  var MAX_LOG_SIZE2 = 10 * 1024 * 1024;
93147
93199
  function getDarwinPlistPath() {
93148
- return import_node_path5.default.join(import_node_os6.default.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
93200
+ return import_node_path4.default.join(import_node_os5.default.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
93149
93201
  }
93150
93202
  function getWindowsStartupDir() {
93151
- const appData = process.env.APPDATA || import_node_path5.default.join(import_node_os6.default.homedir(), "AppData", "Roaming");
93152
- return import_node_path5.default.join(appData, "Microsoft", "Windows", "Start Menu", "Programs", "Startup");
93203
+ const appData = process.env.APPDATA || import_node_path4.default.join(import_node_os5.default.homedir(), "AppData", "Roaming");
93204
+ return import_node_path4.default.join(appData, "Microsoft", "Windows", "Start Menu", "Programs", "Startup");
93153
93205
  }
93154
93206
  function getWindowsVbsPath() {
93155
- return import_node_path5.default.join(getWindowsStartupDir(), "adhdev-daemon.vbs");
93207
+ return import_node_path4.default.join(getWindowsStartupDir(), "adhdev-daemon.vbs");
93156
93208
  }
93157
93209
  function resolveCliPath() {
93158
- return import_node_fs6.default.realpathSync(process.argv[1]);
93210
+ return import_node_fs3.default.realpathSync(process.argv[1]);
93159
93211
  }
93160
93212
  function ensureDir(dir) {
93161
- if (!import_node_fs6.default.existsSync(dir)) import_node_fs6.default.mkdirSync(dir, { recursive: true });
93213
+ if (!import_node_fs3.default.existsSync(dir)) import_node_fs3.default.mkdirSync(dir, { recursive: true });
93162
93214
  }
93163
93215
  async function fetchHealth() {
93164
93216
  const controller = new AbortController();
@@ -93176,12 +93228,12 @@ async function fetchHealth() {
93176
93228
  function getProcessInfo(pid) {
93177
93229
  try {
93178
93230
  if (process.platform === "win32") {
93179
- const out = (0, import_node_child_process6.execSync)(`tasklist /FI "PID eq ${pid}" /FO CSV /NH`, { encoding: "utf-8" });
93231
+ const out = (0, import_node_child_process.execSync)(`tasklist /FI "PID eq ${pid}" /FO CSV /NH`, { encoding: "utf-8" });
93180
93232
  const match = out.match(/"(\d[\d,]+)\sK"/);
93181
93233
  const memKB = match ? parseInt(match[1].replace(/,/g, ""), 10) : 0;
93182
93234
  return { uptime: "-", memMB: Math.round(memKB / 1024) };
93183
93235
  } else {
93184
- const out = (0, import_node_child_process6.execSync)(`ps -o etime=,rss= -p ${pid}`, { encoding: "utf-8" }).trim();
93236
+ const out = (0, import_node_child_process.execSync)(`ps -o etime=,rss= -p ${pid}`, { encoding: "utf-8" }).trim();
93185
93237
  const parts = out.split(/\s+/);
93186
93238
  const etime = parts[0] || "-";
93187
93239
  const rssKB = parseInt(parts[1] || "0", 10);
@@ -93200,13 +93252,13 @@ function formatElapsed(etime) {
93200
93252
  }
93201
93253
  function rotateLogIfNeeded(logPath) {
93202
93254
  try {
93203
- if (!import_node_fs6.default.existsSync(logPath)) return;
93204
- const stat4 = import_node_fs6.default.statSync(logPath);
93255
+ if (!import_node_fs3.default.existsSync(logPath)) return;
93256
+ const stat4 = import_node_fs3.default.statSync(logPath);
93205
93257
  if (stat4.size > MAX_LOG_SIZE2) {
93206
93258
  const rotated = logPath + ".old";
93207
- if (import_node_fs6.default.existsSync(rotated)) import_node_fs6.default.unlinkSync(rotated);
93208
- import_node_fs6.default.renameSync(logPath, rotated);
93209
- import_node_fs6.default.writeFileSync(logPath, `[log rotated at ${(/* @__PURE__ */ new Date()).toISOString()}]
93259
+ if (import_node_fs3.default.existsSync(rotated)) import_node_fs3.default.unlinkSync(rotated);
93260
+ import_node_fs3.default.renameSync(logPath, rotated);
93261
+ import_node_fs3.default.writeFileSync(logPath, `[log rotated at ${(/* @__PURE__ */ new Date()).toISOString()}]
93210
93262
  `, "utf-8");
93211
93263
  }
93212
93264
  } catch {
@@ -93217,8 +93269,8 @@ function rotateLogs() {
93217
93269
  rotateLogIfNeeded(LOG_ERR);
93218
93270
  }
93219
93271
  function buildPlist(nodeExe, cliExe) {
93220
- const brewPrefix = import_node_fs6.default.existsSync("/opt/homebrew/bin") ? "/opt/homebrew/bin" : "/usr/local/bin";
93221
- const nodeDir = import_node_path5.default.dirname(nodeExe);
93272
+ const brewPrefix = import_node_fs3.default.existsSync("/opt/homebrew/bin") ? "/opt/homebrew/bin" : "/usr/local/bin";
93273
+ const nodeDir = import_node_path4.default.dirname(nodeExe);
93222
93274
  const pathEntries = /* @__PURE__ */ new Set([nodeDir, brewPrefix, "/usr/local/bin", "/usr/bin", "/bin", "/usr/sbin", "/sbin"]);
93223
93275
  const pathValue = Array.from(pathEntries).join(":");
93224
93276
  return `<?xml version="1.0" encoding="UTF-8"?>
@@ -93257,15 +93309,15 @@ function buildPlist(nodeExe, cliExe) {
93257
93309
  function installDarwin(nodeExe, cliExe) {
93258
93310
  const plistPath = getDarwinPlistPath();
93259
93311
  ensureDir(ADHDEV_DIR);
93260
- ensureDir(import_node_path5.default.dirname(plistPath));
93261
- import_node_fs6.default.writeFileSync(plistPath, buildPlist(nodeExe, cliExe), "utf-8");
93312
+ ensureDir(import_node_path4.default.dirname(plistPath));
93313
+ import_node_fs3.default.writeFileSync(plistPath, buildPlist(nodeExe, cliExe), "utf-8");
93262
93314
  console.log(source_default.gray(` Plist: ${plistPath}`));
93263
93315
  try {
93264
- (0, import_node_child_process6.execSync)(`launchctl unload "${plistPath}" 2>/dev/null`, { stdio: "ignore" });
93316
+ (0, import_node_child_process.execSync)(`launchctl unload "${plistPath}" 2>/dev/null`, { stdio: "ignore" });
93265
93317
  } catch {
93266
93318
  }
93267
93319
  try {
93268
- (0, import_node_child_process6.execSync)(`launchctl load -w "${plistPath}"`, { stdio: "ignore" });
93320
+ (0, import_node_child_process.execSync)(`launchctl load -w "${plistPath}"`, { stdio: "ignore" });
93269
93321
  console.log(source_default.green("\n \u2713 Registered as LaunchAgent \u2014 daemon will start on login."));
93270
93322
  console.log(source_default.gray(` Logs: ~/.adhdev/daemon-launchd.{out,err}`));
93271
93323
  } catch (e) {
@@ -93275,22 +93327,22 @@ function installDarwin(nodeExe, cliExe) {
93275
93327
  }
93276
93328
  function uninstallDarwin() {
93277
93329
  const plistPath = getDarwinPlistPath();
93278
- if (!import_node_fs6.default.existsSync(plistPath)) {
93330
+ if (!import_node_fs3.default.existsSync(plistPath)) {
93279
93331
  console.log(source_default.yellow("\n \u26A0 Service is not installed."));
93280
93332
  return;
93281
93333
  }
93282
93334
  try {
93283
- (0, import_node_child_process6.execSync)(`launchctl unload "${plistPath}" 2>/dev/null`, { stdio: "ignore" });
93335
+ (0, import_node_child_process.execSync)(`launchctl unload "${plistPath}" 2>/dev/null`, { stdio: "ignore" });
93284
93336
  } catch {
93285
93337
  }
93286
- import_node_fs6.default.unlinkSync(plistPath);
93338
+ import_node_fs3.default.unlinkSync(plistPath);
93287
93339
  console.log(source_default.green("\n \u2713 Removed LaunchAgent. Daemon will no longer auto-start."));
93288
93340
  }
93289
93341
  function isInstalledDarwin() {
93290
- return import_node_fs6.default.existsSync(getDarwinPlistPath());
93342
+ return import_node_fs3.default.existsSync(getDarwinPlistPath());
93291
93343
  }
93292
93344
  function buildVbs(nodeExe, cliExe) {
93293
- const logFile = import_node_path5.default.join(ADHDEV_DIR, "daemon-service.log").replace(/\\/g, "\\\\");
93345
+ const logFile = import_node_path4.default.join(ADHDEV_DIR, "daemon-service.log").replace(/\\/g, "\\\\");
93294
93346
  const escapedNodeExe = nodeExe.replace(/\\/g, "\\\\");
93295
93347
  const escapedCliExe = cliExe.replace(/\\/g, "\\\\");
93296
93348
  return `' ADHDev Daemon Auto-Start (generated by adhdev service install)
@@ -93301,39 +93353,39 @@ WshShell.Run "cmd.exe /c """"${escapedNodeExe}"""" """"${escapedCliExe}"""" daem
93301
93353
  function installWindows(nodeExe, cliExe) {
93302
93354
  const vbsPath = getWindowsVbsPath();
93303
93355
  ensureDir(ADHDEV_DIR);
93304
- ensureDir(import_node_path5.default.dirname(vbsPath));
93305
- import_node_fs6.default.writeFileSync(vbsPath, buildVbs(nodeExe, cliExe), "utf-8");
93356
+ ensureDir(import_node_path4.default.dirname(vbsPath));
93357
+ import_node_fs3.default.writeFileSync(vbsPath, buildVbs(nodeExe, cliExe), "utf-8");
93306
93358
  console.log(source_default.gray(` Startup script: ${vbsPath}`));
93307
93359
  console.log(source_default.green("\n \u2713 Registered in Startup folder \u2014 daemon will start on login (hidden)."));
93308
- console.log(source_default.gray(` Logs: ${import_node_path5.default.join(ADHDEV_DIR, "daemon-service.log")}`));
93360
+ console.log(source_default.gray(` Logs: ${import_node_path4.default.join(ADHDEV_DIR, "daemon-service.log")}`));
93309
93361
  console.log(source_default.gray(" To start now without rebooting, run: adhdev daemon"));
93310
93362
  }
93311
93363
  function uninstallWindows() {
93312
93364
  const vbsPath = getWindowsVbsPath();
93313
- if (!import_node_fs6.default.existsSync(vbsPath)) {
93365
+ if (!import_node_fs3.default.existsSync(vbsPath)) {
93314
93366
  console.log(source_default.yellow("\n \u26A0 Service is not installed."));
93315
93367
  return;
93316
93368
  }
93317
- import_node_fs6.default.unlinkSync(vbsPath);
93369
+ import_node_fs3.default.unlinkSync(vbsPath);
93318
93370
  console.log(source_default.green("\n \u2713 Removed Startup script. Daemon will no longer auto-start."));
93319
93371
  console.log(source_default.gray(" Note: a currently running daemon is not affected. Stop with: adhdev daemon:stop"));
93320
93372
  }
93321
93373
  function isInstalledWindows() {
93322
- return import_node_fs6.default.existsSync(getWindowsVbsPath());
93374
+ return import_node_fs3.default.existsSync(getWindowsVbsPath());
93323
93375
  }
93324
93376
  function registerServiceCommands(program2) {
93325
93377
  const svc = program2.command("service").description("\u{1F50C} Manage ADHDev as an OS background auto-start service");
93326
93378
  svc.command("install").description("Register ADHDev daemon to start automatically on login").action(async () => {
93327
93379
  console.log(source_default.bold("\n \u{1F680} Installing ADHDev Background Service"));
93328
- const platform13 = import_node_os6.default.platform();
93380
+ const platform12 = import_node_os5.default.platform();
93329
93381
  const nodeExe = process.execPath;
93330
93382
  const cliExe = resolveCliPath();
93331
93383
  console.log(source_default.gray(` Node: ${nodeExe}`));
93332
93384
  console.log(source_default.gray(` CLI: ${cliExe}`));
93333
- console.log(source_default.gray(` Platform: ${platform13}`));
93334
- if (platform13 === "darwin") {
93385
+ console.log(source_default.gray(` Platform: ${platform12}`));
93386
+ if (platform12 === "darwin") {
93335
93387
  installDarwin(nodeExe, cliExe);
93336
- } else if (platform13 === "win32") {
93388
+ } else if (platform12 === "win32") {
93337
93389
  installWindows(nodeExe, cliExe);
93338
93390
  } else {
93339
93391
  console.log(source_default.yellow("\n \u26A0 Auto-start service install is not supported on this platform."));
@@ -93344,10 +93396,10 @@ function registerServiceCommands(program2) {
93344
93396
  });
93345
93397
  svc.command("uninstall").description("Remove the OS background service").action(async () => {
93346
93398
  console.log(source_default.bold("\n \u{1F5D1}\uFE0F Removing ADHDev Background Service"));
93347
- const platform13 = import_node_os6.default.platform();
93348
- if (platform13 === "darwin") {
93399
+ const platform12 = import_node_os5.default.platform();
93400
+ if (platform12 === "darwin") {
93349
93401
  uninstallDarwin();
93350
- } else if (platform13 === "win32") {
93402
+ } else if (platform12 === "win32") {
93351
93403
  uninstallWindows();
93352
93404
  } else {
93353
93405
  console.log(source_default.yellow("\n \u26A0 Not supported on this platform."));
@@ -93355,11 +93407,11 @@ function registerServiceCommands(program2) {
93355
93407
  console.log();
93356
93408
  });
93357
93409
  svc.command("status").description("Show service installation state and live daemon health").action(async () => {
93358
- const platform13 = import_node_os6.default.platform();
93359
- const installed = platform13 === "darwin" ? isInstalledDarwin() : platform13 === "win32" ? isInstalledWindows() : false;
93410
+ const platform12 = import_node_os5.default.platform();
93411
+ const installed = platform12 === "darwin" ? isInstalledDarwin() : platform12 === "win32" ? isInstalledWindows() : false;
93360
93412
  if (installed) {
93361
93413
  console.log(source_default.green("\n \u2713 Service is installed."));
93362
- if (platform13 === "darwin") console.log(source_default.gray(` Plist: ${getDarwinPlistPath()}`));
93414
+ if (platform12 === "darwin") console.log(source_default.gray(` Plist: ${getDarwinPlistPath()}`));
93363
93415
  else console.log(source_default.gray(` Script: ${getWindowsVbsPath()}`));
93364
93416
  } else {
93365
93417
  console.log(source_default.gray("\n \u2717 Service is not installed. Run: adhdev service install"));
@@ -93375,8 +93427,8 @@ function registerServiceCommands(program2) {
93375
93427
  } else {
93376
93428
  console.log(source_default.yellow(" \u2717 Daemon is not running."));
93377
93429
  }
93378
- const outSize = import_node_fs6.default.existsSync(LOG_OUT) ? import_node_fs6.default.statSync(LOG_OUT).size : 0;
93379
- const errSize = import_node_fs6.default.existsSync(LOG_ERR) ? import_node_fs6.default.statSync(LOG_ERR).size : 0;
93430
+ const outSize = import_node_fs3.default.existsSync(LOG_OUT) ? import_node_fs3.default.statSync(LOG_OUT).size : 0;
93431
+ const errSize = import_node_fs3.default.existsSync(LOG_ERR) ? import_node_fs3.default.statSync(LOG_ERR).size : 0;
93380
93432
  if (outSize > 0 || errSize > 0) {
93381
93433
  console.log(source_default.gray(` Logs: stdout ${formatBytes(outSize)}, stderr ${formatBytes(errSize)}`));
93382
93434
  }
@@ -93385,13 +93437,13 @@ function registerServiceCommands(program2) {
93385
93437
  svc.command("logs").description("View daemon service logs").option("--err", "Show stderr log instead of stdout").option("--clear", "Truncate all log files").option("-n, --lines <count>", "Number of lines to show", "30").action(async (options) => {
93386
93438
  if (options.clear) {
93387
93439
  for (const f of [LOG_OUT, LOG_ERR]) {
93388
- if (import_node_fs6.default.existsSync(f)) import_node_fs6.default.writeFileSync(f, "", "utf-8");
93440
+ if (import_node_fs3.default.existsSync(f)) import_node_fs3.default.writeFileSync(f, "", "utf-8");
93389
93441
  }
93390
93442
  console.log(source_default.green("\n \u2713 Logs cleared.\n"));
93391
93443
  return;
93392
93444
  }
93393
93445
  const logFile = options.err ? LOG_ERR : LOG_OUT;
93394
- if (!import_node_fs6.default.existsSync(logFile)) {
93446
+ if (!import_node_fs3.default.existsSync(logFile)) {
93395
93447
  console.log(source_default.gray(`
93396
93448
  No log file found: ${logFile}
93397
93449
  `));
@@ -93401,20 +93453,20 @@ function registerServiceCommands(program2) {
93401
93453
  console.log(source_default.gray(`
93402
93454
  \u2500\u2500 ${options.err ? "stderr" : "stdout"}: ${logFile} (last ${lines} lines) \u2500\u2500
93403
93455
  `));
93404
- const content = import_node_fs6.default.readFileSync(logFile, "utf-8");
93456
+ const content = import_node_fs3.default.readFileSync(logFile, "utf-8");
93405
93457
  const allLines = content.split("\n");
93406
93458
  const lastLines = allLines.slice(-lines).join("\n");
93407
93459
  if (lastLines.trim()) console.log(lastLines);
93408
93460
  console.log(source_default.gray("\n (watching for new output, Ctrl+C to stop)\n"));
93409
93461
  let offset = Buffer.byteLength(content, "utf-8");
93410
- const watcher = import_node_fs6.default.watchFile(logFile, { interval: 500 }, () => {
93462
+ const watcher = import_node_fs3.default.watchFile(logFile, { interval: 500 }, () => {
93411
93463
  try {
93412
- const stat4 = import_node_fs6.default.statSync(logFile);
93464
+ const stat4 = import_node_fs3.default.statSync(logFile);
93413
93465
  if (stat4.size > offset) {
93414
- const fd = import_node_fs6.default.openSync(logFile, "r");
93466
+ const fd = import_node_fs3.default.openSync(logFile, "r");
93415
93467
  const buf = Buffer.alloc(stat4.size - offset);
93416
- import_node_fs6.default.readSync(fd, buf, 0, buf.length, offset);
93417
- import_node_fs6.default.closeSync(fd);
93468
+ import_node_fs3.default.readSync(fd, buf, 0, buf.length, offset);
93469
+ import_node_fs3.default.closeSync(fd);
93418
93470
  process.stdout.write(buf.toString("utf-8"));
93419
93471
  offset = stat4.size;
93420
93472
  } else if (stat4.size < offset) {
@@ -93424,15 +93476,15 @@ function registerServiceCommands(program2) {
93424
93476
  }
93425
93477
  });
93426
93478
  const cleanup = () => {
93427
- import_node_fs6.default.unwatchFile(logFile);
93479
+ import_node_fs3.default.unwatchFile(logFile);
93428
93480
  process.exit(0);
93429
93481
  };
93430
93482
  process.on("SIGINT", cleanup);
93431
93483
  process.on("SIGTERM", cleanup);
93432
93484
  });
93433
93485
  svc.command("restart").description("Restart the daemon process (service will auto-relaunch)").action(async () => {
93434
- const platform13 = import_node_os6.default.platform();
93435
- const installed = platform13 === "darwin" ? isInstalledDarwin() : platform13 === "win32" ? isInstalledWindows() : false;
93486
+ const platform12 = import_node_os5.default.platform();
93487
+ const installed = platform12 === "darwin" ? isInstalledDarwin() : platform12 === "win32" ? isInstalledWindows() : false;
93436
93488
  if (!installed) {
93437
93489
  console.log(source_default.yellow("\n \u26A0 Service is not installed. Use `adhdev daemon:restart` for manual restart."));
93438
93490
  console.log(source_default.gray(" Or install the service first: adhdev service install\n"));
@@ -93442,10 +93494,10 @@ function registerServiceCommands(program2) {
93442
93494
  const health = await fetchHealth();
93443
93495
  if (!health?.pid) {
93444
93496
  console.log(source_default.yellow("\n \u26A0 Daemon is not currently running."));
93445
- if (platform13 === "darwin") {
93497
+ if (platform12 === "darwin") {
93446
93498
  console.log(source_default.gray(" Starting via launchctl..."));
93447
93499
  try {
93448
- (0, import_node_child_process6.execSync)(`launchctl start ${LAUNCHD_LABEL}`, { stdio: "ignore" });
93500
+ (0, import_node_child_process.execSync)(`launchctl start ${LAUNCHD_LABEL}`, { stdio: "ignore" });
93449
93501
  console.log(source_default.green(" \u2713 Started.\n"));
93450
93502
  } catch {
93451
93503
  console.log(source_default.red(" \u2717 Failed to start. Check: adhdev service logs --err\n"));
@@ -93463,11 +93515,11 @@ function registerServiceCommands(program2) {
93463
93515
  console.log(source_default.yellow(" Could not send SIGTERM. Process may have already exited."));
93464
93516
  }
93465
93517
  await new Promise((r) => setTimeout(r, 2e3));
93466
- if (platform13 === "win32") {
93518
+ if (platform12 === "win32") {
93467
93519
  const vbsPath = getWindowsVbsPath();
93468
- if (import_node_fs6.default.existsSync(vbsPath)) {
93520
+ if (import_node_fs3.default.existsSync(vbsPath)) {
93469
93521
  try {
93470
- (0, import_node_child_process6.execSync)(`wscript.exe "${vbsPath}"`, { stdio: "ignore", windowsHide: true });
93522
+ (0, import_node_child_process.execSync)(`wscript.exe "${vbsPath}"`, { stdio: "ignore", windowsHide: true });
93471
93523
  } catch {
93472
93524
  }
93473
93525
  }
@@ -93499,11 +93551,11 @@ function formatBytes(bytes) {
93499
93551
 
93500
93552
  // src/cli/doctor-commands.ts
93501
93553
  function resolvePackageRoot() {
93502
- return path34.resolve(__dirname, "..", "..");
93554
+ return path33.resolve(__dirname, "..", "..");
93503
93555
  }
93504
93556
  function isLinkedInstall(packageRoot) {
93505
- const normalized = path34.normalize(packageRoot);
93506
- return !normalized.includes(`${path34.sep}node_modules${path34.sep}adhdev`);
93557
+ const normalized = path33.normalize(packageRoot);
93558
+ return !normalized.includes(`${path33.sep}node_modules${path33.sep}adhdev`);
93507
93559
  }
93508
93560
  function formatCheck(check2) {
93509
93561
  const icon = check2.ok ? source_default.green("\u2713") : source_default.red("\u2717");
@@ -93587,11 +93639,11 @@ function probeSharpRuntime(packageRoot, nativeSharpPackage) {
93587
93639
  }
93588
93640
  }
93589
93641
  function probeConfigAccess() {
93590
- const configDir = path34.join(os30.homedir(), ".adhdev");
93591
- const configPath = path34.join(configDir, "config.json");
93642
+ const configDir = path33.join(os29.homedir(), ".adhdev");
93643
+ const configPath = path33.join(configDir, "config.json");
93592
93644
  const checks = [];
93593
93645
  try {
93594
- fs26.mkdirSync(configDir, { recursive: true });
93646
+ fs21.mkdirSync(configDir, { recursive: true });
93595
93647
  checks.push({
93596
93648
  label: "Config directory",
93597
93649
  ok: true,
@@ -93606,8 +93658,8 @@ function probeConfigAccess() {
93606
93658
  }];
93607
93659
  }
93608
93660
  try {
93609
- if (fs26.existsSync(configPath)) {
93610
- fs26.readFileSync(configPath, "utf-8");
93661
+ if (fs21.existsSync(configPath)) {
93662
+ fs21.readFileSync(configPath, "utf-8");
93611
93663
  checks.push({
93612
93664
  label: "Config file",
93613
93665
  ok: true,
@@ -93628,10 +93680,10 @@ function probeConfigAccess() {
93628
93680
  fatal: true
93629
93681
  });
93630
93682
  }
93631
- const probePath = path34.join(configDir, `.doctor-write-${process.pid}-${Date.now()}.tmp`);
93683
+ const probePath = path33.join(configDir, `.doctor-write-${process.pid}-${Date.now()}.tmp`);
93632
93684
  try {
93633
- fs26.writeFileSync(probePath, "ok", "utf-8");
93634
- fs26.rmSync(probePath, { force: true });
93685
+ fs21.writeFileSync(probePath, "ok", "utf-8");
93686
+ fs21.rmSync(probePath, { force: true });
93635
93687
  checks.push({
93636
93688
  label: "Config write",
93637
93689
  ok: true,
@@ -93639,7 +93691,7 @@ function probeConfigAccess() {
93639
93691
  });
93640
93692
  } catch (error48) {
93641
93693
  try {
93642
- fs26.rmSync(probePath, { force: true });
93694
+ fs21.rmSync(probePath, { force: true });
93643
93695
  } catch {
93644
93696
  }
93645
93697
  checks.push({
@@ -93695,9 +93747,9 @@ function probeCliBinary(commandPath, currentVersion) {
93695
93747
  return probe;
93696
93748
  }
93697
93749
  function readLogHints(logPath) {
93698
- if (!fs26.existsSync(logPath)) return [];
93750
+ if (!fs21.existsSync(logPath)) return [];
93699
93751
  try {
93700
- const content = fs26.readFileSync(logPath, "utf-8");
93752
+ const content = fs21.readFileSync(logPath, "utf-8");
93701
93753
  const lines = content.split(/\r?\n/);
93702
93754
  const recent = lines.slice(-400);
93703
93755
  const hits = recent.filter(
@@ -93711,11 +93763,11 @@ function readLogHints(logPath) {
93711
93763
  function buildBrowseProbeChecks() {
93712
93764
  const probes = process.platform === "win32" ? [
93713
93765
  process.env.SystemDrive ? `${process.env.SystemDrive.replace(/[\\/]+$/, "")}\\` : "C:\\",
93714
- os30.homedir()
93715
- ] : ["/", os30.homedir()];
93766
+ os29.homedir()
93767
+ ] : ["/", os29.homedir()];
93716
93768
  return probes.map((probePath, index) => {
93717
93769
  try {
93718
- const entries = fs26.readdirSync(probePath, { withFileTypes: true });
93770
+ const entries = fs21.readdirSync(probePath, { withFileTypes: true });
93719
93771
  const directoryCount = entries.filter((entry) => entry.isDirectory()).length;
93720
93772
  return {
93721
93773
  label: index === 0 ? "Folder browse root" : "Folder browse home",
@@ -93735,7 +93787,7 @@ function buildBrowseProbeChecks() {
93735
93787
  function registerDoctorCommands(program2, pkgVersion3) {
93736
93788
  program2.command("doctor").description("Diagnose install, native dependencies, CLI resolution, and folder browse access").action(async () => {
93737
93789
  const packageRoot = resolvePackageRoot();
93738
- const cliPath = fs26.realpathSync(process.argv[1]);
93790
+ const cliPath = fs21.realpathSync(process.argv[1]);
93739
93791
  const linked = isLinkedInstall(packageRoot);
93740
93792
  const logPath = getCurrentDaemonLogPath();
93741
93793
  const claudePaths = findCommandPaths("claude");
@@ -93817,12 +93869,12 @@ function registerDoctorCommands(program2, pkgVersion3) {
93817
93869
  });
93818
93870
  }
93819
93871
  if (process.platform === "darwin") {
93820
- serviceDefinitionPath = path34.join(os30.homedir(), "Library", "LaunchAgents", "dev.adhf.daemon.plist");
93821
- if (fs26.existsSync(serviceDefinitionPath)) {
93872
+ serviceDefinitionPath = path33.join(os29.homedir(), "Library", "LaunchAgents", "dev.adhf.daemon.plist");
93873
+ if (fs21.existsSync(serviceDefinitionPath)) {
93822
93874
  serviceDefinitionCheck = evaluateServiceDefinitionDrift({
93823
93875
  serviceKind: "launchd",
93824
93876
  servicePath: serviceDefinitionPath,
93825
- installedDefinition: fs26.readFileSync(serviceDefinitionPath, "utf8"),
93877
+ installedDefinition: fs21.readFileSync(serviceDefinitionPath, "utf8"),
93826
93878
  expectedDefinition: buildPlist(process.execPath, cliPath)
93827
93879
  });
93828
93880
  checks.push({
@@ -93890,12 +93942,12 @@ function registerDoctorCommands(program2, pkgVersion3) {
93890
93942
  serviceCheck: serviceDefinitionCheck || void 0,
93891
93943
  sourceCliExample: "node --import tsx packages/daemon-cloud/src/cli/index.ts doctor"
93892
93944
  });
93893
- const sessionHostLogPath = path34.join(os30.homedir(), ".adhdev", "logs", "session-host.log");
93945
+ const sessionHostLogPath = path33.join(os29.homedir(), ".adhdev", "logs", "session-host.log");
93894
93946
  console.log(source_default.bold("\n\u{1FA7A} ADHDev Doctor\n"));
93895
93947
  console.log(source_default.gray(` Version: ${pkgVersion3}`));
93896
93948
  console.log(source_default.gray(` Platform: ${process.platform} ${process.arch}`));
93897
93949
  console.log(source_default.gray(` Node: ${process.version}`));
93898
- console.log(source_default.gray(` Home: ${os30.homedir()}`));
93950
+ console.log(source_default.gray(` Home: ${os29.homedir()}`));
93899
93951
  console.log(source_default.gray(` Log file: ${logPath}`));
93900
93952
  console.log(source_default.gray(` SH log: ${sessionHostLogPath}`));
93901
93953
  console.log();
@@ -93932,7 +93984,7 @@ function registerDoctorCommands(program2, pkgVersion3) {
93932
93984
 
93933
93985
  // src/cli/provider-commands.ts
93934
93986
  init_source();
93935
- var path35 = __toESM(require("path"));
93987
+ var path34 = __toESM(require("path"));
93936
93988
  init_cdp_utils();
93937
93989
  var DEV_SERVER_PORT3 = 19280;
93938
93990
  var IDE_AUTO_FIX_FUNCTIONS = [
@@ -94015,7 +94067,7 @@ function getProviderSourceCandidatePaths(options) {
94015
94067
  const results = [];
94016
94068
  for (const root of roots) {
94017
94069
  for (const name of relativeNames) {
94018
- results.push(path35.join(root, options.category, options.type, name));
94070
+ results.push(path34.join(root, options.category, options.type, name));
94019
94071
  }
94020
94072
  }
94021
94073
  return results;
@@ -94150,35 +94202,35 @@ function registerProviderCommands(program2) {
94150
94202
  let osPaths = {};
94151
94203
  let processNames = {};
94152
94204
  if (category === "ide") {
94153
- const fs27 = await import("fs");
94154
- const path36 = await import("path");
94155
- const os31 = await import("os");
94156
- if (os31.platform() === "darwin") {
94205
+ const fs22 = await import("fs");
94206
+ const path35 = await import("path");
94207
+ const os30 = await import("os");
94208
+ if (os30.platform() === "darwin") {
94157
94209
  while (true) {
94158
94210
  const p = (await rl.question(`macOS Application Path (e.g. /Applications/${defaultName}.app): `)).trim() || `/Applications/${defaultName}.app`;
94159
94211
  if (p === "skip") break;
94160
- if (!fs27.existsSync(p)) {
94212
+ if (!fs22.existsSync(p)) {
94161
94213
  console.log(source_default.red(` \u2717 Path not found: ${p}`));
94162
94214
  console.log(source_default.gray(` (Please provide the exact absolute path to the .app or binary, or type 'skip')`));
94163
94215
  continue;
94164
94216
  }
94165
94217
  console.log(source_default.green(` \u2713 Path verified: ${p}`));
94166
94218
  osPaths["darwin"] = [p];
94167
- processNames["darwin"] = path36.basename(p, ".app");
94219
+ processNames["darwin"] = path35.basename(p, ".app");
94168
94220
  break;
94169
94221
  }
94170
- } else if (os31.platform() === "win32") {
94222
+ } else if (os30.platform() === "win32") {
94171
94223
  while (true) {
94172
94224
  const p = (await rl.question(`Windows Executable Path (e.g. C:\\Program Files\\${defaultName}\\${defaultName}.exe): `)).trim();
94173
94225
  if (!p || p === "skip") break;
94174
- if (!fs27.existsSync(p)) {
94226
+ if (!fs22.existsSync(p)) {
94175
94227
  console.log(source_default.red(` \u2717 Path not found: ${p}`));
94176
94228
  console.log(source_default.gray(` (Please provide the exact absolute path, or type 'skip')`));
94177
94229
  continue;
94178
94230
  }
94179
94231
  console.log(source_default.green(` \u2713 Path verified: ${p}`));
94180
94232
  osPaths["win32"] = [p];
94181
- processNames["win32"] = path36.basename(p, ".exe");
94233
+ processNames["win32"] = path35.basename(p, ".exe");
94182
94234
  break;
94183
94235
  }
94184
94236
  }
@@ -94865,8 +94917,8 @@ function registerCdpCommands(program2) {
94865
94917
  }
94866
94918
  const output = typeof result === "string" ? result : JSON.stringify(result, null, 2);
94867
94919
  if (options.output) {
94868
- const fs27 = await import("fs");
94869
- fs27.writeFileSync(options.output, output, "utf-8");
94920
+ const fs22 = await import("fs");
94921
+ fs22.writeFileSync(options.output, output, "utf-8");
94870
94922
  console.log(source_default.green(`
94871
94923
  \u2713 Saved to ${options.output} (${output.length} chars)
94872
94924
  `));
@@ -94969,8 +95021,8 @@ function registerCdpCommands(program2) {
94969
95021
  ws.on("message", async (data) => {
94970
95022
  const msg = JSON.parse(data.toString());
94971
95023
  if (msg.id === 1 && msg.result?.data) {
94972
- const fs27 = await import("fs");
94973
- fs27.writeFileSync(options.output, Buffer.from(msg.result.data, "base64"));
95024
+ const fs22 = await import("fs");
95025
+ fs22.writeFileSync(options.output, Buffer.from(msg.result.data, "base64"));
94974
95026
  console.log(source_default.green(`
94975
95027
  \u2713 Screenshot saved to ${options.output}
94976
95028
  `));