@threadbase-sh/streamer 1.36.1 → 1.36.2

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.cjs CHANGED
@@ -26158,7 +26158,7 @@ var require_thread_stream = __commonJS({
26158
26158
  var { version: version2 } = require_package();
26159
26159
  var { EventEmitter: EventEmitter5 } = require("events");
26160
26160
  var { Worker } = require("worker_threads");
26161
- var { join: join28 } = require("path");
26161
+ var { join: join29 } = require("path");
26162
26162
  var { pathToFileURL } = require("url");
26163
26163
  var { wait } = require_wait();
26164
26164
  var {
@@ -26209,7 +26209,7 @@ var require_thread_stream = __commonJS({
26209
26209
  function createWorker(stream, opts) {
26210
26210
  const { filename, workerData } = opts;
26211
26211
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
26212
- const toExecute = bundlerOverrides["thread-stream-worker"] || join28(__dirname, "lib", "worker.js");
26212
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join29(__dirname, "lib", "worker.js");
26213
26213
  const worker = new Worker(toExecute, {
26214
26214
  ...opts.workerOpts,
26215
26215
  name: opts.workerOpts?.name || "thread-stream",
@@ -26677,7 +26677,7 @@ var require_transport = __commonJS({
26677
26677
  var { createRequire } = require("module");
26678
26678
  var { existsSync: existsSync15 } = require("fs");
26679
26679
  var getCallers = require_caller();
26680
- var { join: join28, isAbsolute: isAbsolute2, sep: sep3 } = require("path");
26680
+ var { join: join29, isAbsolute: isAbsolute2, sep: sep3 } = require("path");
26681
26681
  var { fileURLToPath: fileURLToPath3 } = require("url");
26682
26682
  var sleep = require_atomic_sleep();
26683
26683
  var onExit = require_on_exit_leak_free();
@@ -26830,7 +26830,7 @@ var require_transport = __commonJS({
26830
26830
  throw new Error("only one of target or targets can be specified");
26831
26831
  }
26832
26832
  if (targets) {
26833
- target = bundlerOverrides["pino-worker"] || join28(__dirname, "worker.js");
26833
+ target = bundlerOverrides["pino-worker"] || join29(__dirname, "worker.js");
26834
26834
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
26835
26835
  return {
26836
26836
  ...dest,
@@ -26848,7 +26848,7 @@ var require_transport = __commonJS({
26848
26848
  });
26849
26849
  });
26850
26850
  } else if (pipeline2) {
26851
- target = bundlerOverrides["pino-worker"] || join28(__dirname, "worker.js");
26851
+ target = bundlerOverrides["pino-worker"] || join29(__dirname, "worker.js");
26852
26852
  options.pipelines = [pipeline2.map((dest) => {
26853
26853
  return {
26854
26854
  ...dest,
@@ -26871,7 +26871,7 @@ var require_transport = __commonJS({
26871
26871
  return origin;
26872
26872
  }
26873
26873
  if (origin === "pino/file") {
26874
- return join28(__dirname, "..", "file.js");
26874
+ return join29(__dirname, "..", "file.js");
26875
26875
  }
26876
26876
  let fixTarget2;
26877
26877
  for (const filePath of callers) {
@@ -27852,7 +27852,7 @@ var require_safe_stable_stringify = __commonJS({
27852
27852
  return circularValue;
27853
27853
  }
27854
27854
  let res = "";
27855
- let join28 = ",";
27855
+ let join29 = ",";
27856
27856
  const originalIndentation = indentation;
27857
27857
  if (Array.isArray(value)) {
27858
27858
  if (value.length === 0) {
@@ -27866,7 +27866,7 @@ var require_safe_stable_stringify = __commonJS({
27866
27866
  indentation += spacer;
27867
27867
  res += `
27868
27868
  ${indentation}`;
27869
- join28 = `,
27869
+ join29 = `,
27870
27870
  ${indentation}`;
27871
27871
  }
27872
27872
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -27874,13 +27874,13 @@ ${indentation}`;
27874
27874
  for (; i < maximumValuesToStringify - 1; i++) {
27875
27875
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
27876
27876
  res += tmp2 !== void 0 ? tmp2 : "null";
27877
- res += join28;
27877
+ res += join29;
27878
27878
  }
27879
27879
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
27880
27880
  res += tmp !== void 0 ? tmp : "null";
27881
27881
  if (value.length - 1 > maximumBreadth) {
27882
27882
  const removedKeys = value.length - maximumBreadth - 1;
27883
- res += `${join28}"... ${getItemCount(removedKeys)} not stringified"`;
27883
+ res += `${join29}"... ${getItemCount(removedKeys)} not stringified"`;
27884
27884
  }
27885
27885
  if (spacer !== "") {
27886
27886
  res += `
@@ -27901,7 +27901,7 @@ ${originalIndentation}`;
27901
27901
  let separator = "";
27902
27902
  if (spacer !== "") {
27903
27903
  indentation += spacer;
27904
- join28 = `,
27904
+ join29 = `,
27905
27905
  ${indentation}`;
27906
27906
  whitespace = " ";
27907
27907
  }
@@ -27915,13 +27915,13 @@ ${indentation}`;
27915
27915
  const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
27916
27916
  if (tmp !== void 0) {
27917
27917
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
27918
- separator = join28;
27918
+ separator = join29;
27919
27919
  }
27920
27920
  }
27921
27921
  if (keyLength > maximumBreadth) {
27922
27922
  const removedKeys = keyLength - maximumBreadth;
27923
27923
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
27924
- separator = join28;
27924
+ separator = join29;
27925
27925
  }
27926
27926
  if (spacer !== "" && separator.length > 1) {
27927
27927
  res = `
@@ -27962,7 +27962,7 @@ ${originalIndentation}`;
27962
27962
  }
27963
27963
  const originalIndentation = indentation;
27964
27964
  let res = "";
27965
- let join28 = ",";
27965
+ let join29 = ",";
27966
27966
  if (Array.isArray(value)) {
27967
27967
  if (value.length === 0) {
27968
27968
  return "[]";
@@ -27975,7 +27975,7 @@ ${originalIndentation}`;
27975
27975
  indentation += spacer;
27976
27976
  res += `
27977
27977
  ${indentation}`;
27978
- join28 = `,
27978
+ join29 = `,
27979
27979
  ${indentation}`;
27980
27980
  }
27981
27981
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -27983,13 +27983,13 @@ ${indentation}`;
27983
27983
  for (; i < maximumValuesToStringify - 1; i++) {
27984
27984
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
27985
27985
  res += tmp2 !== void 0 ? tmp2 : "null";
27986
- res += join28;
27986
+ res += join29;
27987
27987
  }
27988
27988
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
27989
27989
  res += tmp !== void 0 ? tmp : "null";
27990
27990
  if (value.length - 1 > maximumBreadth) {
27991
27991
  const removedKeys = value.length - maximumBreadth - 1;
27992
- res += `${join28}"... ${getItemCount(removedKeys)} not stringified"`;
27992
+ res += `${join29}"... ${getItemCount(removedKeys)} not stringified"`;
27993
27993
  }
27994
27994
  if (spacer !== "") {
27995
27995
  res += `
@@ -28002,7 +28002,7 @@ ${originalIndentation}`;
28002
28002
  let whitespace = "";
28003
28003
  if (spacer !== "") {
28004
28004
  indentation += spacer;
28005
- join28 = `,
28005
+ join29 = `,
28006
28006
  ${indentation}`;
28007
28007
  whitespace = " ";
28008
28008
  }
@@ -28011,7 +28011,7 @@ ${indentation}`;
28011
28011
  const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
28012
28012
  if (tmp !== void 0) {
28013
28013
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
28014
- separator = join28;
28014
+ separator = join29;
28015
28015
  }
28016
28016
  }
28017
28017
  if (spacer !== "" && separator.length > 1) {
@@ -28069,20 +28069,20 @@ ${originalIndentation}`;
28069
28069
  indentation += spacer;
28070
28070
  let res2 = `
28071
28071
  ${indentation}`;
28072
- const join29 = `,
28072
+ const join30 = `,
28073
28073
  ${indentation}`;
28074
28074
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
28075
28075
  let i = 0;
28076
28076
  for (; i < maximumValuesToStringify - 1; i++) {
28077
28077
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
28078
28078
  res2 += tmp2 !== void 0 ? tmp2 : "null";
28079
- res2 += join29;
28079
+ res2 += join30;
28080
28080
  }
28081
28081
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
28082
28082
  res2 += tmp !== void 0 ? tmp : "null";
28083
28083
  if (value.length - 1 > maximumBreadth) {
28084
28084
  const removedKeys = value.length - maximumBreadth - 1;
28085
- res2 += `${join29}"... ${getItemCount(removedKeys)} not stringified"`;
28085
+ res2 += `${join30}"... ${getItemCount(removedKeys)} not stringified"`;
28086
28086
  }
28087
28087
  res2 += `
28088
28088
  ${originalIndentation}`;
@@ -28098,16 +28098,16 @@ ${originalIndentation}`;
28098
28098
  return '"[Object]"';
28099
28099
  }
28100
28100
  indentation += spacer;
28101
- const join28 = `,
28101
+ const join29 = `,
28102
28102
  ${indentation}`;
28103
28103
  let res = "";
28104
28104
  let separator = "";
28105
28105
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
28106
28106
  if (isTypedArrayWithEntries(value)) {
28107
- res += stringifyTypedArray(value, join28, maximumBreadth);
28107
+ res += stringifyTypedArray(value, join29, maximumBreadth);
28108
28108
  keys = keys.slice(value.length);
28109
28109
  maximumPropertiesToStringify -= value.length;
28110
- separator = join28;
28110
+ separator = join29;
28111
28111
  }
28112
28112
  if (deterministic) {
28113
28113
  keys = sort(keys, comparator);
@@ -28118,13 +28118,13 @@ ${indentation}`;
28118
28118
  const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
28119
28119
  if (tmp !== void 0) {
28120
28120
  res += `${separator}${strEscape(key2)}: ${tmp}`;
28121
- separator = join28;
28121
+ separator = join29;
28122
28122
  }
28123
28123
  }
28124
28124
  if (keyLength > maximumBreadth) {
28125
28125
  const removedKeys = keyLength - maximumBreadth;
28126
28126
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
28127
- separator = join28;
28127
+ separator = join29;
28128
28128
  }
28129
28129
  if (separator !== "") {
28130
28130
  res = `
@@ -100397,11 +100397,11 @@ var require_out = __commonJS({
100397
100397
  async.read(path2, getSettings(optionsOrSettingsOrCallback), callback);
100398
100398
  }
100399
100399
  exports2.stat = stat7;
100400
- function statSync13(path2, optionsOrSettings) {
100400
+ function statSync14(path2, optionsOrSettings) {
100401
100401
  const settings = getSettings(optionsOrSettings);
100402
100402
  return sync.read(path2, settings);
100403
100403
  }
100404
- exports2.statSync = statSync13;
100404
+ exports2.statSync = statSync14;
100405
100405
  function getSettings(settingsOrOptions = {}) {
100406
100406
  if (settingsOrOptions instanceof settings_1.default) {
100407
100407
  return settingsOrOptions;
@@ -135143,11 +135143,11 @@ async function search(query, options, scanner) {
135143
135143
 
135144
135144
  // src/server.ts
135145
135145
  var import_events2 = require("events");
135146
- var import_fs28 = require("fs");
135146
+ var import_fs29 = require("fs");
135147
135147
  var import_promises16 = require("fs/promises");
135148
135148
  var import_http = require("http");
135149
- var import_os11 = require("os");
135150
- var import_path28 = require("path");
135149
+ var import_os12 = require("os");
135150
+ var import_path29 = require("path");
135151
135151
  var import_readline4 = require("readline");
135152
135152
 
135153
135153
  // src/agent/agent-client.ts
@@ -142397,6 +142397,14 @@ function seal(plaintext, recipientPublicKeyBase64) {
142397
142397
  };
142398
142398
  }
142399
142399
 
142400
+ // src/services/cache/cacheMetadata.ts
142401
+ function getCacheMetadata(repo, key) {
142402
+ return repo.getCacheMetadata(key);
142403
+ }
142404
+ function setCacheMetadata(repo, key, value) {
142405
+ repo.setCacheMetadata(key, value);
142406
+ }
142407
+
142400
142408
  // src/services/cache-integrity/cacheIntegrityMonitor.ts
142401
142409
  var import_crypto10 = require("crypto");
142402
142410
  var import_fs24 = require("fs");
@@ -142936,6 +142944,360 @@ function pruneAgentConversations(cache) {
142936
142944
  return { scanned: rows.length, pruned, missing };
142937
142945
  }
142938
142946
 
142947
+ // node_modules/date-fns/constants.js
142948
+ var daysInYear = 365.2425;
142949
+ var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
142950
+ var minTime = -maxTime;
142951
+ var millisecondsInMinute = 6e4;
142952
+ var millisecondsInHour = 36e5;
142953
+ var secondsInHour = 3600;
142954
+ var secondsInDay = secondsInHour * 24;
142955
+ var secondsInWeek = secondsInDay * 7;
142956
+ var secondsInYear = secondsInDay * daysInYear;
142957
+ var secondsInMonth = secondsInYear / 12;
142958
+ var secondsInQuarter = secondsInMonth * 3;
142959
+ var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
142960
+
142961
+ // node_modules/date-fns/constructFrom.js
142962
+ function constructFrom(date5, value) {
142963
+ if (typeof date5 === "function") return date5(value);
142964
+ if (date5 && typeof date5 === "object" && constructFromSymbol in date5)
142965
+ return date5[constructFromSymbol](value);
142966
+ if (date5 instanceof Date) return new date5.constructor(value);
142967
+ return new Date(value);
142968
+ }
142969
+
142970
+ // node_modules/date-fns/toDate.js
142971
+ function toDate(argument, context) {
142972
+ return constructFrom(context || argument, argument);
142973
+ }
142974
+
142975
+ // node_modules/date-fns/compareDesc.js
142976
+ function compareDesc(dateLeft, dateRight) {
142977
+ const diff = +toDate(dateLeft) - +toDate(dateRight);
142978
+ if (diff > 0) return -1;
142979
+ else if (diff < 0) return 1;
142980
+ return diff;
142981
+ }
142982
+
142983
+ // node_modules/date-fns/isDate.js
142984
+ function isDate(value) {
142985
+ return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
142986
+ }
142987
+
142988
+ // node_modules/date-fns/isValid.js
142989
+ function isValid(date5) {
142990
+ return !(!isDate(date5) && typeof date5 !== "number" || isNaN(+toDate(date5)));
142991
+ }
142992
+
142993
+ // node_modules/date-fns/parseISO.js
142994
+ function parseISO(argument, options) {
142995
+ const invalidDate = () => constructFrom(options?.in, NaN);
142996
+ const additionalDigits = options?.additionalDigits ?? 2;
142997
+ const dateStrings = splitDateString(argument);
142998
+ let date5;
142999
+ if (dateStrings.date) {
143000
+ const parseYearResult = parseYear(dateStrings.date, additionalDigits);
143001
+ date5 = parseDate(parseYearResult.restDateString, parseYearResult.year);
143002
+ }
143003
+ if (!date5 || isNaN(+date5)) return invalidDate();
143004
+ const timestamp2 = +date5;
143005
+ let time3 = 0;
143006
+ let offset;
143007
+ if (dateStrings.time) {
143008
+ time3 = parseTime(dateStrings.time);
143009
+ if (isNaN(time3)) return invalidDate();
143010
+ }
143011
+ if (dateStrings.timezone) {
143012
+ offset = parseTimezone(dateStrings.timezone);
143013
+ if (isNaN(offset)) return invalidDate();
143014
+ } else {
143015
+ const tmpDate = new Date(timestamp2 + time3);
143016
+ const result = toDate(0, options?.in);
143017
+ result.setFullYear(
143018
+ tmpDate.getUTCFullYear(),
143019
+ tmpDate.getUTCMonth(),
143020
+ tmpDate.getUTCDate()
143021
+ );
143022
+ result.setHours(
143023
+ tmpDate.getUTCHours(),
143024
+ tmpDate.getUTCMinutes(),
143025
+ tmpDate.getUTCSeconds(),
143026
+ tmpDate.getUTCMilliseconds()
143027
+ );
143028
+ return result;
143029
+ }
143030
+ return toDate(timestamp2 + time3 + offset, options?.in);
143031
+ }
143032
+ var patterns = {
143033
+ dateTimeDelimiter: /[T ]/,
143034
+ timeZoneDelimiter: /[Z ]/i,
143035
+ timezone: /([Z+-].*)$/
143036
+ };
143037
+ var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
143038
+ var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
143039
+ var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
143040
+ function splitDateString(dateString) {
143041
+ const dateStrings = {};
143042
+ const array2 = dateString.split(patterns.dateTimeDelimiter);
143043
+ let timeString;
143044
+ if (array2.length > 2) {
143045
+ return dateStrings;
143046
+ }
143047
+ if (/:/.test(array2[0])) {
143048
+ timeString = array2[0];
143049
+ } else {
143050
+ dateStrings.date = array2[0];
143051
+ timeString = array2[1];
143052
+ if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
143053
+ dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
143054
+ timeString = dateString.substr(
143055
+ dateStrings.date.length,
143056
+ dateString.length
143057
+ );
143058
+ }
143059
+ }
143060
+ if (timeString) {
143061
+ const token = patterns.timezone.exec(timeString);
143062
+ if (token) {
143063
+ dateStrings.time = timeString.replace(token[1], "");
143064
+ dateStrings.timezone = token[1];
143065
+ } else {
143066
+ dateStrings.time = timeString;
143067
+ }
143068
+ }
143069
+ return dateStrings;
143070
+ }
143071
+ function parseYear(dateString, additionalDigits) {
143072
+ const regex = new RegExp(
143073
+ "^(?:(\\d{4}|[+-]\\d{" + (4 + additionalDigits) + "})|(\\d{2}|[+-]\\d{" + (2 + additionalDigits) + "})$)"
143074
+ );
143075
+ const captures = dateString.match(regex);
143076
+ if (!captures) return { year: NaN, restDateString: "" };
143077
+ const year = captures[1] ? parseInt(captures[1]) : null;
143078
+ const century = captures[2] ? parseInt(captures[2]) : null;
143079
+ return {
143080
+ year: century === null ? year : century * 100,
143081
+ restDateString: dateString.slice((captures[1] || captures[2]).length)
143082
+ };
143083
+ }
143084
+ function parseDate(dateString, year) {
143085
+ if (year === null) return /* @__PURE__ */ new Date(NaN);
143086
+ const captures = dateString.match(dateRegex);
143087
+ if (!captures) return /* @__PURE__ */ new Date(NaN);
143088
+ const isWeekDate = !!captures[4];
143089
+ const dayOfYear = parseDateUnit(captures[1]);
143090
+ const month = parseDateUnit(captures[2]) - 1;
143091
+ const day = parseDateUnit(captures[3]);
143092
+ const week = parseDateUnit(captures[4]);
143093
+ const dayOfWeek = parseDateUnit(captures[5]) - 1;
143094
+ if (isWeekDate) {
143095
+ if (!validateWeekDate(year, week, dayOfWeek)) {
143096
+ return /* @__PURE__ */ new Date(NaN);
143097
+ }
143098
+ return dayOfISOWeekYear(year, week, dayOfWeek);
143099
+ } else {
143100
+ const date5 = /* @__PURE__ */ new Date(0);
143101
+ if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {
143102
+ return /* @__PURE__ */ new Date(NaN);
143103
+ }
143104
+ date5.setUTCFullYear(year, month, Math.max(dayOfYear, day));
143105
+ return date5;
143106
+ }
143107
+ }
143108
+ function parseDateUnit(value) {
143109
+ return value ? parseInt(value) : 1;
143110
+ }
143111
+ function parseTime(timeString) {
143112
+ const captures = timeString.match(timeRegex);
143113
+ if (!captures) return NaN;
143114
+ const hours = parseTimeUnit(captures[1]);
143115
+ const minutes = parseTimeUnit(captures[2]);
143116
+ const seconds = parseTimeUnit(captures[3]);
143117
+ if (!validateTime(hours, minutes, seconds)) {
143118
+ return NaN;
143119
+ }
143120
+ return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1e3;
143121
+ }
143122
+ function parseTimeUnit(value) {
143123
+ return value && parseFloat(value.replace(",", ".")) || 0;
143124
+ }
143125
+ function parseTimezone(timezoneString) {
143126
+ if (timezoneString === "Z") return 0;
143127
+ const captures = timezoneString.match(timezoneRegex);
143128
+ if (!captures) return 0;
143129
+ const sign = captures[1] === "+" ? -1 : 1;
143130
+ const hours = parseInt(captures[2]);
143131
+ const minutes = captures[3] && parseInt(captures[3]) || 0;
143132
+ if (!validateTimezone(hours, minutes)) {
143133
+ return NaN;
143134
+ }
143135
+ return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
143136
+ }
143137
+ function dayOfISOWeekYear(isoWeekYear, week, day) {
143138
+ const date5 = /* @__PURE__ */ new Date(0);
143139
+ date5.setUTCFullYear(isoWeekYear, 0, 4);
143140
+ const fourthOfJanuaryDay = date5.getUTCDay() || 7;
143141
+ const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
143142
+ date5.setUTCDate(date5.getUTCDate() + diff);
143143
+ return date5;
143144
+ }
143145
+ var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
143146
+ function isLeapYearIndex(year) {
143147
+ return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
143148
+ }
143149
+ function validateDate(year, month, date5) {
143150
+ return month >= 0 && month <= 11 && date5 >= 1 && date5 <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));
143151
+ }
143152
+ function validateDayOfYearDate(year, dayOfYear) {
143153
+ return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
143154
+ }
143155
+ function validateWeekDate(_year, week, day) {
143156
+ return week >= 1 && week <= 53 && day >= 0 && day <= 6;
143157
+ }
143158
+ function validateTime(hours, minutes, seconds) {
143159
+ if (hours === 24) {
143160
+ return minutes === 0 && seconds === 0;
143161
+ }
143162
+ return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
143163
+ }
143164
+ function validateTimezone(_hours, minutes) {
143165
+ return minutes >= 0 && minutes <= 59;
143166
+ }
143167
+
143168
+ // src/utils/dates.ts
143169
+ function parseIsoDateOrNull(value) {
143170
+ if (!value) return null;
143171
+ const parsed = parseISO(value);
143172
+ return isValid(parsed) ? parsed : null;
143173
+ }
143174
+ function compareIsoDesc(a, b2) {
143175
+ const dateA = parseIsoDateOrNull(a);
143176
+ const dateB = parseIsoDateOrNull(b2);
143177
+ if (!dateA && !dateB) return 0;
143178
+ if (!dateA) return 1;
143179
+ if (!dateB) return -1;
143180
+ return compareDesc(dateA, dateB);
143181
+ }
143182
+
143183
+ // src/services/projects/ensureProjectsForConversations.ts
143184
+ function ensureProjectsForConversations(repo, conversations) {
143185
+ const conversationsByPath = /* @__PURE__ */ new Map();
143186
+ for (const conversation of conversations) {
143187
+ if (!conversation.projectPath) continue;
143188
+ const canonical = canonicalizeProjectPath(conversation.projectPath);
143189
+ if (!canonical) continue;
143190
+ const existing = conversationsByPath.get(canonical) ?? [];
143191
+ existing.push(conversation);
143192
+ conversationsByPath.set(canonical, existing);
143193
+ }
143194
+ const pathToProjectId = /* @__PURE__ */ new Map();
143195
+ for (const [path2, projectConversations] of conversationsByPath) {
143196
+ const latest = pickLatestConversation(projectConversations);
143197
+ const project = repo.upsertProjectByPath(path2, {
143198
+ lastConversationId: latest?.id ?? null,
143199
+ lastConversationCreatedAt: latest?.createdAt ?? null,
143200
+ latestMessageAt: latest?.latestMessageAt ?? null
143201
+ });
143202
+ pathToProjectId.set(path2, project.id);
143203
+ }
143204
+ return pathToProjectId;
143205
+ }
143206
+ function pickLatestConversation(conversations) {
143207
+ if (conversations.length === 0) return void 0;
143208
+ return [...conversations].sort((a, b2) => {
143209
+ const cmp = compareIsoDesc(a.latestMessageAt ?? null, b2.latestMessageAt ?? null);
143210
+ if (cmp !== 0) return cmp;
143211
+ return compareIsoDesc(a.createdAt ?? null, b2.createdAt ?? null);
143212
+ })[0];
143213
+ }
143214
+
143215
+ // src/services/conversations/refreshConversationCache.ts
143216
+ function refreshConversationCache(deps) {
143217
+ const { projectsRepo, conversationsRepo, cacheMetadataRepo } = deps;
143218
+ const conversations = conversationsRepo.listConversationsForProjectBackfill();
143219
+ const pathToProjectId = ensureProjectsForConversations(
143220
+ projectsRepo,
143221
+ conversations.map((c) => ({
143222
+ id: c.id,
143223
+ projectPath: c.projectPath,
143224
+ latestMessageAt: c.lastActivity ?? null,
143225
+ createdAt: c.lastActivity ?? null
143226
+ }))
143227
+ );
143228
+ let conversationsBackfilled = 0;
143229
+ for (const conversation of conversations) {
143230
+ if (!conversation.projectPath) continue;
143231
+ if (conversation.projectId) continue;
143232
+ const projectId = pathToProjectId.get(canonicalizeProjectPath(conversation.projectPath));
143233
+ if (!projectId) continue;
143234
+ conversationsRepo.updateConversationProjectId({
143235
+ conversationId: conversation.id,
143236
+ projectId
143237
+ });
143238
+ conversationsBackfilled += 1;
143239
+ }
143240
+ const latest = conversationsRepo.getLatestConversation();
143241
+ if (latest) {
143242
+ setCacheMetadata(cacheMetadataRepo, "last_conversation_id", latest.id);
143243
+ if (latest.lastActivity) {
143244
+ setCacheMetadata(cacheMetadataRepo, "last_conversation_created_at", latest.lastActivity);
143245
+ }
143246
+ }
143247
+ setCacheMetadata(cacheMetadataRepo, "conversations_last_indexed_at", (/* @__PURE__ */ new Date()).toISOString());
143248
+ return {
143249
+ projectsTouched: pathToProjectId.size,
143250
+ conversationsBackfilled,
143251
+ latestConversationId: latest?.id ?? null
143252
+ };
143253
+ }
143254
+
143255
+ // src/services/conversations/shouldRefreshProjectsFromHdd.ts
143256
+ var import_fs27 = require("fs");
143257
+ var import_os11 = require("os");
143258
+ var import_path27 = require("path");
143259
+ var DEFAULT_PROJECTS_DIR = (0, import_path27.join)((0, import_os11.homedir)(), ".claude", "projects");
143260
+ function maxProjectsTreeMtimeMs(projectsDir) {
143261
+ let maxMs;
143262
+ try {
143263
+ maxMs = (0, import_fs27.statSync)(projectsDir).mtimeMs;
143264
+ } catch {
143265
+ return null;
143266
+ }
143267
+ try {
143268
+ for (const ent of (0, import_fs27.readdirSync)(projectsDir, { withFileTypes: true })) {
143269
+ if (!ent.isDirectory()) continue;
143270
+ try {
143271
+ const childMs = (0, import_fs27.statSync)((0, import_path27.join)(projectsDir, ent.name)).mtimeMs;
143272
+ if (childMs > maxMs) maxMs = childMs;
143273
+ } catch {
143274
+ }
143275
+ }
143276
+ } catch {
143277
+ }
143278
+ return maxMs;
143279
+ }
143280
+ function shouldRefreshProjectsFromHdd(conversationsRepo, cacheMetadataRepo, opts = {}) {
143281
+ if (conversationsRepo.hasOrphanRows()) return true;
143282
+ const dirs = /* @__PURE__ */ new Set();
143283
+ if (opts.projectsDirs) {
143284
+ for (const d of opts.projectsDirs) dirs.add(d);
143285
+ }
143286
+ dirs.add(opts.projectsDir ?? DEFAULT_PROJECTS_DIR);
143287
+ let newestMs = null;
143288
+ for (const dir of dirs) {
143289
+ const ms2 = maxProjectsTreeMtimeMs(dir);
143290
+ if (ms2 === null) continue;
143291
+ if (newestMs === null || ms2 > newestMs) newestMs = ms2;
143292
+ }
143293
+ if (newestMs === null) return false;
143294
+ const lastIndexedIso = getCacheMetadata(cacheMetadataRepo, "conversations_last_indexed_at");
143295
+ if (!lastIndexedIso) return true;
143296
+ const lastIndexedMs = Date.parse(lastIndexedIso);
143297
+ if (Number.isNaN(lastIndexedMs)) return true;
143298
+ return newestMs > lastIndexedMs;
143299
+ }
143300
+
142939
143301
  // src/services/projectChats/deriveProjectChatTitle.ts
142940
143302
  function deriveProjectChatTitle(input) {
142941
143303
  const trimmed = input.title?.trim();
@@ -143097,7 +143459,7 @@ function resolveAnswer(pending, body) {
143097
143459
  }
143098
143460
 
143099
143461
  // src/services/sessions/conversationBusy.ts
143100
- var import_fs27 = require("fs");
143462
+ var import_fs28 = require("fs");
143101
143463
  var RESUME_BUSY_WINDOW_MS = 12e4;
143102
143464
  function resolveResumeBusyWindowMs(env = process.env) {
143103
143465
  const raw2 = env.THREADBASE_RESUME_BUSY_WINDOW_MS;
@@ -143114,7 +143476,7 @@ function conversationBusy(input) {
143114
143476
  let lastActivityMs = null;
143115
143477
  if (input.jsonlPath) {
143116
143478
  try {
143117
- const mtimeMs = (0, import_fs27.statSync)(input.jsonlPath).mtimeMs;
143479
+ const mtimeMs = (0, import_fs28.statSync)(input.jsonlPath).mtimeMs;
143118
143480
  const age = now - mtimeMs;
143119
143481
  lastActivityMs = Math.max(0, age);
143120
143482
  const isSelfEcho = input.selfPtyEndedAt != null && mtimeMs <= input.selfPtyEndedAt + SELF_ACTIVITY_SKEW_MS;
@@ -143368,7 +143730,7 @@ function discoveredToResponse(d, conversationId) {
143368
143730
  var import_crypto11 = require("crypto");
143369
143731
  var import_promises15 = require("fs/promises");
143370
143732
  var import_heic_convert = __toESM(require_heic_convert(), 1);
143371
- var import_path27 = require("path");
143733
+ var import_path28 = require("path");
143372
143734
  var UPLOAD_DIR_NAME = ".threadbase-uploads";
143373
143735
  var MAX_BYTES = 25 * 1024 * 1024;
143374
143736
  var HEIC_MIMES = /* @__PURE__ */ new Set(["image/heic", "image/heif"]);
@@ -143401,9 +143763,9 @@ async function saveUploadFile(input) {
143401
143763
  }
143402
143764
  const id = `up_${(0, import_crypto11.randomBytes)(8).toString("hex")}`;
143403
143765
  const safeName = sanitizeFilename(originalName) || `file${MIME_TO_EXT[mimeType] ?? ""}`;
143404
- const dir = (0, import_path27.join)(input.projectPath, UPLOAD_DIR_NAME, input.sessionId);
143766
+ const dir = (0, import_path28.join)(input.projectPath, UPLOAD_DIR_NAME, input.sessionId);
143405
143767
  await (0, import_promises15.mkdir)(dir, { recursive: true });
143406
- const filePath = (0, import_path27.join)(dir, `${Date.now()}-${id}-${safeName}`);
143768
+ const filePath = (0, import_path28.join)(dir, `${Date.now()}-${id}-${safeName}`);
143407
143769
  await (0, import_promises15.writeFile)(filePath, buffer);
143408
143770
  return {
143409
143771
  id,
@@ -143513,226 +143875,6 @@ function computeConversationEtag({
143513
143875
  return `"${digest}"`;
143514
143876
  }
143515
143877
 
143516
- // node_modules/date-fns/constants.js
143517
- var daysInYear = 365.2425;
143518
- var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
143519
- var minTime = -maxTime;
143520
- var millisecondsInMinute = 6e4;
143521
- var millisecondsInHour = 36e5;
143522
- var secondsInHour = 3600;
143523
- var secondsInDay = secondsInHour * 24;
143524
- var secondsInWeek = secondsInDay * 7;
143525
- var secondsInYear = secondsInDay * daysInYear;
143526
- var secondsInMonth = secondsInYear / 12;
143527
- var secondsInQuarter = secondsInMonth * 3;
143528
- var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
143529
-
143530
- // node_modules/date-fns/constructFrom.js
143531
- function constructFrom(date5, value) {
143532
- if (typeof date5 === "function") return date5(value);
143533
- if (date5 && typeof date5 === "object" && constructFromSymbol in date5)
143534
- return date5[constructFromSymbol](value);
143535
- if (date5 instanceof Date) return new date5.constructor(value);
143536
- return new Date(value);
143537
- }
143538
-
143539
- // node_modules/date-fns/toDate.js
143540
- function toDate(argument, context) {
143541
- return constructFrom(context || argument, argument);
143542
- }
143543
-
143544
- // node_modules/date-fns/isDate.js
143545
- function isDate(value) {
143546
- return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
143547
- }
143548
-
143549
- // node_modules/date-fns/isValid.js
143550
- function isValid(date5) {
143551
- return !(!isDate(date5) && typeof date5 !== "number" || isNaN(+toDate(date5)));
143552
- }
143553
-
143554
- // node_modules/date-fns/parseISO.js
143555
- function parseISO(argument, options) {
143556
- const invalidDate = () => constructFrom(options?.in, NaN);
143557
- const additionalDigits = options?.additionalDigits ?? 2;
143558
- const dateStrings = splitDateString(argument);
143559
- let date5;
143560
- if (dateStrings.date) {
143561
- const parseYearResult = parseYear(dateStrings.date, additionalDigits);
143562
- date5 = parseDate(parseYearResult.restDateString, parseYearResult.year);
143563
- }
143564
- if (!date5 || isNaN(+date5)) return invalidDate();
143565
- const timestamp2 = +date5;
143566
- let time3 = 0;
143567
- let offset;
143568
- if (dateStrings.time) {
143569
- time3 = parseTime(dateStrings.time);
143570
- if (isNaN(time3)) return invalidDate();
143571
- }
143572
- if (dateStrings.timezone) {
143573
- offset = parseTimezone(dateStrings.timezone);
143574
- if (isNaN(offset)) return invalidDate();
143575
- } else {
143576
- const tmpDate = new Date(timestamp2 + time3);
143577
- const result = toDate(0, options?.in);
143578
- result.setFullYear(
143579
- tmpDate.getUTCFullYear(),
143580
- tmpDate.getUTCMonth(),
143581
- tmpDate.getUTCDate()
143582
- );
143583
- result.setHours(
143584
- tmpDate.getUTCHours(),
143585
- tmpDate.getUTCMinutes(),
143586
- tmpDate.getUTCSeconds(),
143587
- tmpDate.getUTCMilliseconds()
143588
- );
143589
- return result;
143590
- }
143591
- return toDate(timestamp2 + time3 + offset, options?.in);
143592
- }
143593
- var patterns = {
143594
- dateTimeDelimiter: /[T ]/,
143595
- timeZoneDelimiter: /[Z ]/i,
143596
- timezone: /([Z+-].*)$/
143597
- };
143598
- var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
143599
- var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
143600
- var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
143601
- function splitDateString(dateString) {
143602
- const dateStrings = {};
143603
- const array2 = dateString.split(patterns.dateTimeDelimiter);
143604
- let timeString;
143605
- if (array2.length > 2) {
143606
- return dateStrings;
143607
- }
143608
- if (/:/.test(array2[0])) {
143609
- timeString = array2[0];
143610
- } else {
143611
- dateStrings.date = array2[0];
143612
- timeString = array2[1];
143613
- if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
143614
- dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
143615
- timeString = dateString.substr(
143616
- dateStrings.date.length,
143617
- dateString.length
143618
- );
143619
- }
143620
- }
143621
- if (timeString) {
143622
- const token = patterns.timezone.exec(timeString);
143623
- if (token) {
143624
- dateStrings.time = timeString.replace(token[1], "");
143625
- dateStrings.timezone = token[1];
143626
- } else {
143627
- dateStrings.time = timeString;
143628
- }
143629
- }
143630
- return dateStrings;
143631
- }
143632
- function parseYear(dateString, additionalDigits) {
143633
- const regex = new RegExp(
143634
- "^(?:(\\d{4}|[+-]\\d{" + (4 + additionalDigits) + "})|(\\d{2}|[+-]\\d{" + (2 + additionalDigits) + "})$)"
143635
- );
143636
- const captures = dateString.match(regex);
143637
- if (!captures) return { year: NaN, restDateString: "" };
143638
- const year = captures[1] ? parseInt(captures[1]) : null;
143639
- const century = captures[2] ? parseInt(captures[2]) : null;
143640
- return {
143641
- year: century === null ? year : century * 100,
143642
- restDateString: dateString.slice((captures[1] || captures[2]).length)
143643
- };
143644
- }
143645
- function parseDate(dateString, year) {
143646
- if (year === null) return /* @__PURE__ */ new Date(NaN);
143647
- const captures = dateString.match(dateRegex);
143648
- if (!captures) return /* @__PURE__ */ new Date(NaN);
143649
- const isWeekDate = !!captures[4];
143650
- const dayOfYear = parseDateUnit(captures[1]);
143651
- const month = parseDateUnit(captures[2]) - 1;
143652
- const day = parseDateUnit(captures[3]);
143653
- const week = parseDateUnit(captures[4]);
143654
- const dayOfWeek = parseDateUnit(captures[5]) - 1;
143655
- if (isWeekDate) {
143656
- if (!validateWeekDate(year, week, dayOfWeek)) {
143657
- return /* @__PURE__ */ new Date(NaN);
143658
- }
143659
- return dayOfISOWeekYear(year, week, dayOfWeek);
143660
- } else {
143661
- const date5 = /* @__PURE__ */ new Date(0);
143662
- if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {
143663
- return /* @__PURE__ */ new Date(NaN);
143664
- }
143665
- date5.setUTCFullYear(year, month, Math.max(dayOfYear, day));
143666
- return date5;
143667
- }
143668
- }
143669
- function parseDateUnit(value) {
143670
- return value ? parseInt(value) : 1;
143671
- }
143672
- function parseTime(timeString) {
143673
- const captures = timeString.match(timeRegex);
143674
- if (!captures) return NaN;
143675
- const hours = parseTimeUnit(captures[1]);
143676
- const minutes = parseTimeUnit(captures[2]);
143677
- const seconds = parseTimeUnit(captures[3]);
143678
- if (!validateTime(hours, minutes, seconds)) {
143679
- return NaN;
143680
- }
143681
- return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1e3;
143682
- }
143683
- function parseTimeUnit(value) {
143684
- return value && parseFloat(value.replace(",", ".")) || 0;
143685
- }
143686
- function parseTimezone(timezoneString) {
143687
- if (timezoneString === "Z") return 0;
143688
- const captures = timezoneString.match(timezoneRegex);
143689
- if (!captures) return 0;
143690
- const sign = captures[1] === "+" ? -1 : 1;
143691
- const hours = parseInt(captures[2]);
143692
- const minutes = captures[3] && parseInt(captures[3]) || 0;
143693
- if (!validateTimezone(hours, minutes)) {
143694
- return NaN;
143695
- }
143696
- return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
143697
- }
143698
- function dayOfISOWeekYear(isoWeekYear, week, day) {
143699
- const date5 = /* @__PURE__ */ new Date(0);
143700
- date5.setUTCFullYear(isoWeekYear, 0, 4);
143701
- const fourthOfJanuaryDay = date5.getUTCDay() || 7;
143702
- const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
143703
- date5.setUTCDate(date5.getUTCDate() + diff);
143704
- return date5;
143705
- }
143706
- var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
143707
- function isLeapYearIndex(year) {
143708
- return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
143709
- }
143710
- function validateDate(year, month, date5) {
143711
- return month >= 0 && month <= 11 && date5 >= 1 && date5 <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));
143712
- }
143713
- function validateDayOfYearDate(year, dayOfYear) {
143714
- return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
143715
- }
143716
- function validateWeekDate(_year, week, day) {
143717
- return week >= 1 && week <= 53 && day >= 0 && day <= 6;
143718
- }
143719
- function validateTime(hours, minutes, seconds) {
143720
- if (hours === 24) {
143721
- return minutes === 0 && seconds === 0;
143722
- }
143723
- return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
143724
- }
143725
- function validateTimezone(_hours, minutes) {
143726
- return minutes >= 0 && minutes <= 59;
143727
- }
143728
-
143729
- // src/utils/dates.ts
143730
- function parseIsoDateOrNull(value) {
143731
- if (!value) return null;
143732
- const parsed = parseISO(value);
143733
- return isValid(parsed) ? parsed : null;
143734
- }
143735
-
143736
143878
  // src/utils/isScannedSnapshotStale.ts
143737
143879
  var STALENESS_TOLERANCE_MS = 1e3;
143738
143880
  function isScannedSnapshotStale(snapshotTimestamp, fileMtimeMs) {
@@ -144033,13 +144175,13 @@ var StreamerServer = class {
144033
144175
  this.disableDb = config2.disableDb ?? false;
144034
144176
  this.scannerPersistenceDisabled = config2.scannerPersistent === false;
144035
144177
  this.scanProfiles = config2.scanProfiles;
144036
- this.codexRoots = config2.codexRoots ?? [(0, import_path28.join)((0, import_os11.homedir)(), ".codex", "sessions")];
144178
+ this.codexRoots = config2.codexRoots ?? [(0, import_path29.join)((0, import_os12.homedir)(), ".codex", "sessions")];
144037
144179
  this.ptyGracePeriodMs = config2.ptyGracePeriodMs ?? DEFAULT_PTY_GRACE_PERIOD_MS;
144038
144180
  this.defaultSystemPrompt = config2.defaultSystemPrompt ?? DEFAULT_SYSTEM_PROMPT;
144039
144181
  this.defaultPermissionMode = config2.defaultPermissionMode ?? loadDefaultPermissionMode() ?? "acceptEdits";
144040
144182
  this.defaultModel = config2.defaultModel ?? "sonnet";
144041
144183
  this.defaultEffort = config2.defaultEffort ?? "low";
144042
- this.cacheDir = config2.cacheDir ?? loadCacheDir() ?? (0, import_path28.join)((0, import_os11.homedir)(), ".threadbase", "cache");
144184
+ this.cacheDir = config2.cacheDir ?? loadCacheDir() ?? (0, import_path29.join)((0, import_os12.homedir)(), ".threadbase", "cache");
144043
144185
  this.tailSize = config2.tailSize ?? loadTailSize() ?? 10;
144044
144186
  this.directoryDebounceMs = parseDirScanDebounceEnv(process.env.THREADBASE_DIR_SCAN_DEBOUNCE_MS) ?? config2.directoryScanDebounceMs ?? 1e3;
144045
144187
  this.markScannerStaleDebounced = debounce(() => {
@@ -144080,7 +144222,7 @@ var StreamerServer = class {
144080
144222
  const seqs = cache.extendMessageIndex(
144081
144223
  filePath,
144082
144224
  spans,
144083
- (0, import_fs28.statSync)(filePath),
144225
+ (0, import_fs29.statSync)(filePath),
144084
144226
  readFrom,
144085
144227
  endOffset
144086
144228
  );
@@ -144246,7 +144388,7 @@ var StreamerServer = class {
144246
144388
  temporalClient,
144247
144389
  taskQueue: agentConfig.temporal.taskQueue
144248
144390
  });
144249
- const conversationsBaseDir = agentConfig.conversationsDir || (0, import_path28.join)((0, import_path28.dirname)(this.cacheDir), "conversations");
144391
+ const conversationsBaseDir = agentConfig.conversationsDir || (0, import_path29.join)((0, import_path29.dirname)(this.cacheDir), "conversations");
144250
144392
  conversationWriter = createConversationWriter({
144251
144393
  baseDir: conversationsBaseDir
144252
144394
  });
@@ -144569,7 +144711,7 @@ var StreamerServer = class {
144569
144711
  });
144570
144712
  try {
144571
144713
  this.cache = ConversationCache.open(
144572
- (0, import_path28.join)(this.cacheDir, "cache.db"),
144714
+ (0, import_path29.join)(this.cacheDir, "cache.db"),
144573
144715
  this.tailSize,
144574
144716
  void 0,
144575
144717
  {
@@ -144614,7 +144756,7 @@ var StreamerServer = class {
144614
144756
  this.fileWatcher.watchDirectory(dir);
144615
144757
  }
144616
144758
  for (const dir of this.codexRoots) {
144617
- if (!(0, import_fs28.existsSync)(dir)) continue;
144759
+ if (!(0, import_fs29.existsSync)(dir)) continue;
144618
144760
  this.fileWatcher.watchDirectory(dir);
144619
144761
  }
144620
144762
  } catch (err) {
@@ -144695,6 +144837,20 @@ var StreamerServer = class {
144695
144837
  count: pruned.length,
144696
144838
  event: "cache.prune_ghosts"
144697
144839
  });
144840
+ if (this.projectsRepo && this.conversationsRepo && this.cacheMetadataRepo) {
144841
+ refreshConversationCache({
144842
+ cache: this.cache,
144843
+ projectsRepo: this.projectsRepo,
144844
+ conversationsRepo: this.conversationsRepo,
144845
+ cacheMetadataRepo: this.cacheMetadataRepo
144846
+ });
144847
+ } else if (this.cacheMetadataRepo) {
144848
+ setCacheMetadata(
144849
+ this.cacheMetadataRepo,
144850
+ "conversations_last_indexed_at",
144851
+ (/* @__PURE__ */ new Date()).toISOString()
144852
+ );
144853
+ }
144698
144854
  }
144699
144855
  }).catch((err) => {
144700
144856
  const message = err instanceof Error ? err.message : String(err);
@@ -144934,6 +145090,56 @@ var StreamerServer = class {
144934
145090
  checkSessionInputRateLimit(sessionId) {
144935
145091
  return this.checkRateLimit(this.sessionInputAttempts, sessionId, 500, 6e4);
144936
145092
  }
145093
+ /** Project roots watched for conversation JSONLs (profiles or ~/.claude/projects). */
145094
+ projectsDirsForFreshnessCheck() {
145095
+ if (this.scanProfiles && this.scanProfiles.length > 0) {
145096
+ return this.scanProfiles.filter((p2) => p2.enabled).map((p2) => (0, import_path29.join)(p2.configDir, "projects"));
145097
+ }
145098
+ return [(0, import_path29.join)((0, import_os12.homedir)(), ".claude", "projects")];
145099
+ }
145100
+ /**
145101
+ * Full-glob scan + cache upsert/delete reconcile. Used by ?refresh=1 and by
145102
+ * the automatic freshness path when the directory watcher marked the scanner
145103
+ * stale or shouldRefreshProjectsFromHdd detected disk drift.
145104
+ */
145105
+ async reconcileConversationsCacheFromDisk() {
145106
+ if (!this.cache) return;
145107
+ const scanner = await this.rescanForRefresh();
145108
+ const metas = [...scanner.getMetadataCache().values()];
145109
+ try {
145110
+ this.cache.upsertFromScannerMeta(metas);
145111
+ if (!this.cacheMonitor?.pending) {
145112
+ this.cache.reconcileDeletions(canonicalLivePathSet(metas));
145113
+ }
145114
+ if (this.projectsRepo && this.conversationsRepo && this.cacheMetadataRepo) {
145115
+ refreshConversationCache({
145116
+ cache: this.cache,
145117
+ projectsRepo: this.projectsRepo,
145118
+ conversationsRepo: this.conversationsRepo,
145119
+ cacheMetadataRepo: this.cacheMetadataRepo
145120
+ });
145121
+ } else if (this.cacheMetadataRepo) {
145122
+ setCacheMetadata(
145123
+ this.cacheMetadataRepo,
145124
+ "conversations_last_indexed_at",
145125
+ (/* @__PURE__ */ new Date()).toISOString()
145126
+ );
145127
+ }
145128
+ } catch (err) {
145129
+ this.log.warn(
145130
+ `refresh reconcile failed: ${err instanceof Error ? err.message : String(err)}`,
145131
+ { event: "conversations.reconcile_failed" }
145132
+ );
145133
+ }
145134
+ }
145135
+ shouldAutoReconcileConversationList() {
145136
+ if (!this.cache) return false;
145137
+ if (this.scannerStale) return true;
145138
+ if (!this.conversationsRepo || !this.cacheMetadataRepo) return false;
145139
+ return shouldRefreshProjectsFromHdd(this.conversationsRepo, this.cacheMetadataRepo, {
145140
+ projectsDirs: this.projectsDirsForFreshnessCheck()
145141
+ });
145142
+ }
144937
145143
  async handleListConversations(url2, res) {
144938
145144
  if (this.rejectIfWarmingUp(res)) return;
144939
145145
  const limit = intParam(url2, "limit", 50);
@@ -144942,19 +145148,14 @@ var StreamerServer = class {
144942
145148
  const project = url2.searchParams.get("project") ?? void 0;
144943
145149
  const providerFilter = url2.searchParams.get("provider") ?? void 0;
144944
145150
  const bustCache = url2.searchParams.get("refresh") === "1";
144945
- if (bustCache && this.cache) {
144946
- const scanner2 = await this.withWarmup("conversation_refresh", () => this.rescanForRefresh());
144947
- const metas2 = [...scanner2.getMetadataCache().values()];
144948
- try {
144949
- this.cache.upsertFromScannerMeta(metas2);
144950
- if (!this.cacheMonitor?.pending) {
144951
- this.cache.reconcileDeletions(canonicalLivePathSet(metas2));
144952
- }
144953
- } catch (err) {
144954
- this.log.warn(
144955
- `refresh reconcile failed: ${err instanceof Error ? err.message : String(err)}`,
144956
- { event: "conversations.reconcile_failed" }
145151
+ if (this.cache && (bustCache || this.shouldAutoReconcileConversationList())) {
145152
+ if (bustCache) {
145153
+ await this.withWarmup(
145154
+ "conversation_refresh",
145155
+ () => this.reconcileConversationsCacheFromDisk()
144957
145156
  );
145157
+ } else {
145158
+ await this.reconcileConversationsCacheFromDisk();
144958
145159
  }
144959
145160
  }
144960
145161
  if (this.cache) {
@@ -145216,22 +145417,22 @@ var StreamerServer = class {
145216
145417
  */
145217
145418
  projectsDirs() {
145218
145419
  if (this.scanProfiles && this.scanProfiles.length > 0) {
145219
- return this.scanProfiles.filter((p2) => p2.enabled).map((p2) => (0, import_path28.join)(p2.configDir, "projects"));
145420
+ return this.scanProfiles.filter((p2) => p2.enabled).map((p2) => (0, import_path29.join)(p2.configDir, "projects"));
145220
145421
  }
145221
- return [(0, import_path28.join)((0, import_os11.homedir)(), ".claude", "projects")];
145422
+ return [(0, import_path29.join)((0, import_os12.homedir)(), ".claude", "projects")];
145222
145423
  }
145223
145424
  findJsonlPath(uuid3) {
145224
145425
  const filename = `${uuid3}.jsonl`;
145225
145426
  for (const projectsDir of this.projectsDirs()) {
145226
- if (!(0, import_fs28.existsSync)(projectsDir)) continue;
145227
- for (const dir of (0, import_fs28.readdirSync)(projectsDir)) {
145228
- const fp = (0, import_path28.join)(projectsDir, dir, filename);
145229
- if ((0, import_fs28.existsSync)(fp)) return fp;
145230
- const projectDir = (0, import_path28.join)(projectsDir, dir);
145427
+ if (!(0, import_fs29.existsSync)(projectsDir)) continue;
145428
+ for (const dir of (0, import_fs29.readdirSync)(projectsDir)) {
145429
+ const fp = (0, import_path29.join)(projectsDir, dir, filename);
145430
+ if ((0, import_fs29.existsSync)(fp)) return fp;
145431
+ const projectDir = (0, import_path29.join)(projectsDir, dir);
145231
145432
  try {
145232
- for (const sub of (0, import_fs28.readdirSync)(projectDir)) {
145233
- const subagentPath = (0, import_path28.join)(projectDir, sub, "subagents", filename);
145234
- if ((0, import_fs28.existsSync)(subagentPath)) return subagentPath;
145433
+ for (const sub of (0, import_fs29.readdirSync)(projectDir)) {
145434
+ const subagentPath = (0, import_path29.join)(projectDir, sub, "subagents", filename);
145435
+ if ((0, import_fs29.existsSync)(subagentPath)) return subagentPath;
145235
145436
  }
145236
145437
  } catch {
145237
145438
  }
@@ -145241,7 +145442,7 @@ var StreamerServer = class {
145241
145442
  }
145242
145443
  async readCwdFromJsonl(filePath) {
145243
145444
  return new Promise((resolve4) => {
145244
- const rl = (0, import_readline4.createInterface)({ input: (0, import_fs28.createReadStream)(filePath), crlfDelay: Infinity });
145445
+ const rl = (0, import_readline4.createInterface)({ input: (0, import_fs29.createReadStream)(filePath), crlfDelay: Infinity });
145245
145446
  let found = false;
145246
145447
  rl.on("line", (line) => {
145247
145448
  if (found) return;
@@ -145331,7 +145532,7 @@ var StreamerServer = class {
145331
145532
  if (this.isManagedTailPath(key)) return;
145332
145533
  let mtimeMs;
145333
145534
  try {
145334
- mtimeMs = (0, import_fs28.statSync)(filePath).mtimeMs;
145535
+ mtimeMs = (0, import_fs29.statSync)(filePath).mtimeMs;
145335
145536
  } catch {
145336
145537
  return;
145337
145538
  }
@@ -145513,7 +145714,7 @@ var StreamerServer = class {
145513
145714
  if (!conv.filePath) return false;
145514
145715
  let mtimeMs = null;
145515
145716
  try {
145516
- mtimeMs = (0, import_fs28.statSync)(conv.filePath).mtimeMs;
145717
+ mtimeMs = (0, import_fs29.statSync)(conv.filePath).mtimeMs;
145517
145718
  } catch {
145518
145719
  return false;
145519
145720
  }
@@ -145886,7 +146087,7 @@ var StreamerServer = class {
145886
146087
  if (this.rejectIfWarmingUp(res)) return;
145887
146088
  const session = this.sessionStore.get(sessionId, this.ptyAttachedIds());
145888
146089
  if (session) {
145889
- if (!(0, import_fs28.existsSync)(session.projectPath)) {
146090
+ if (!(0, import_fs29.existsSync)(session.projectPath)) {
145890
146091
  session.failureReason = `Project directory not found: ${session.projectPath}`;
145891
146092
  }
145892
146093
  if (this.ptyManager.hasSession(sessionId)) {
@@ -146357,7 +146558,7 @@ var StreamerServer = class {
146357
146558
  const jsonlCwd = jsonlPath ? await this.readCwdFromJsonl(jsonlPath) : null;
146358
146559
  if (jsonlCwd) {
146359
146560
  projectPath = jsonlCwd;
146360
- projectName = projectName || (0, import_path28.basename)(jsonlCwd);
146561
+ projectName = projectName || (0, import_path29.basename)(jsonlCwd);
146361
146562
  }
146362
146563
  }
146363
146564
  if (!projectPath) {
@@ -146433,7 +146634,7 @@ var StreamerServer = class {
146433
146634
  sessionStore: this.sessionStore,
146434
146635
  // biome-ignore lint/style/noNonNullAssertion: agentClient is set when agentConfig.enabled is true
146435
146636
  agentClient: this.agentClient,
146436
- conversationsDir: this.cacheDir ? (0, import_path28.join)((0, import_path28.dirname)(this.cacheDir), "conversations") : "",
146637
+ conversationsDir: this.cacheDir ? (0, import_path29.join)((0, import_path29.dirname)(this.cacheDir), "conversations") : "",
146437
146638
  agentConfig: this.agentConfig
146438
146639
  });
146439
146640
  json2(res, result.status, result.body);
@@ -146577,7 +146778,7 @@ var StreamerServer = class {
146577
146778
  // file isn't slurped in full.
146578
146779
  readFirstLineSessionId(filePath) {
146579
146780
  try {
146580
- const content = (0, import_fs28.readFileSync)(filePath, "utf8");
146781
+ const content = (0, import_fs29.readFileSync)(filePath, "utf8");
146581
146782
  const nl = content.indexOf("\n");
146582
146783
  const firstLine = nl === -1 ? content : content.slice(0, nl);
146583
146784
  if (!firstLine.trim()) return null;
@@ -146592,9 +146793,9 @@ var StreamerServer = class {
146592
146793
  // was passed to Claude via --session-id so the filename matches from the start.
146593
146794
  watchForJsonl(sessionId, projectPath) {
146594
146795
  const encoded = projectPath.replace(/[/\\:.]/g, "-");
146595
- const projectsDir = (0, import_path28.join)((0, import_os11.homedir)(), ".claude", "projects", encoded);
146796
+ const projectsDir = (0, import_path29.join)((0, import_os12.homedir)(), ".claude", "projects", encoded);
146596
146797
  const expectedFile = `${sessionId}.jsonl`;
146597
- const filePath = (0, import_path28.join)(projectsDir, expectedFile);
146798
+ const filePath = (0, import_path29.join)(projectsDir, expectedFile);
146598
146799
  const deadline = Date.now() + 12e4;
146599
146800
  let watcher = null;
146600
146801
  const cleanup = () => {
@@ -146612,14 +146813,14 @@ var StreamerServer = class {
146612
146813
  cleanup();
146613
146814
  return;
146614
146815
  }
146615
- let resolvedFilePath = (0, import_fs28.existsSync)(filePath) ? filePath : null;
146616
- if (!resolvedFilePath && (0, import_fs28.existsSync)(projectsDir)) {
146816
+ let resolvedFilePath = (0, import_fs29.existsSync)(filePath) ? filePath : null;
146817
+ if (!resolvedFilePath && (0, import_fs29.existsSync)(projectsDir)) {
146617
146818
  try {
146618
146819
  const now = Date.now();
146619
- const match2 = (0, import_fs28.readdirSync)(projectsDir).filter((f2) => f2.endsWith(".jsonl")).map((f2) => ({ f: f2, mtime: (0, import_fs28.statSync)((0, import_path28.join)(projectsDir, f2)).mtimeMs })).filter(({ mtime }) => now - mtime < 5e3).filter(
146620
- ({ f: f2 }) => (0, import_path28.basename)(f2, ".jsonl") === sessionId || this.readFirstLineSessionId((0, import_path28.join)(projectsDir, f2)) === sessionId
146820
+ const match2 = (0, import_fs29.readdirSync)(projectsDir).filter((f2) => f2.endsWith(".jsonl")).map((f2) => ({ f: f2, mtime: (0, import_fs29.statSync)((0, import_path29.join)(projectsDir, f2)).mtimeMs })).filter(({ mtime }) => now - mtime < 5e3).filter(
146821
+ ({ f: f2 }) => (0, import_path29.basename)(f2, ".jsonl") === sessionId || this.readFirstLineSessionId((0, import_path29.join)(projectsDir, f2)) === sessionId
146621
146822
  ).sort((a, b2) => b2.mtime - a.mtime)[0];
146622
- if (match2) resolvedFilePath = (0, import_path28.join)(projectsDir, match2.f);
146823
+ if (match2) resolvedFilePath = (0, import_path29.join)(projectsDir, match2.f);
146623
146824
  } catch {
146624
146825
  }
146625
146826
  }
@@ -146627,7 +146828,7 @@ var StreamerServer = class {
146627
146828
  cleanup();
146628
146829
  this.sessionFileMap.set(sessionId, resolvedFilePath);
146629
146830
  try {
146630
- const existing = (0, import_fs28.readFileSync)(resolvedFilePath, "utf8").split("\n").filter(Boolean);
146831
+ const existing = (0, import_fs29.readFileSync)(resolvedFilePath, "utf8").split("\n").filter(Boolean);
146631
146832
  if (existing.length > 0) {
146632
146833
  this.broadcastConversationLines(sessionId, existing);
146633
146834
  }
@@ -146651,7 +146852,7 @@ var StreamerServer = class {
146651
146852
  if (this.sessionFileMap.has(sessionId)) return;
146652
146853
  try {
146653
146854
  require("fs").mkdirSync(projectsDir, { recursive: true });
146654
- watcher = (0, import_fs28.watch)(projectsDir, tryWire);
146855
+ watcher = (0, import_fs29.watch)(projectsDir, tryWire);
146655
146856
  watcher.on("error", cleanup);
146656
146857
  } catch {
146657
146858
  }
@@ -146667,7 +146868,7 @@ var StreamerServer = class {
146667
146868
  watchForCodexRollout(sessionId, projectPath) {
146668
146869
  const deadline = Date.now() + 12e4;
146669
146870
  const now = /* @__PURE__ */ new Date();
146670
- const dateDir = (0, import_path28.join)(
146871
+ const dateDir = (0, import_path29.join)(
146671
146872
  String(now.getFullYear()),
146672
146873
  String(now.getMonth() + 1).padStart(2, "0"),
146673
146874
  String(now.getDate()).padStart(2, "0")
@@ -146680,7 +146881,7 @@ var StreamerServer = class {
146680
146881
  };
146681
146882
  const matchesProjectPath = (candidatePath) => {
146682
146883
  try {
146683
- const firstLine = (0, import_fs28.readFileSync)(candidatePath, "utf8").split("\n", 1)[0];
146884
+ const firstLine = (0, import_fs29.readFileSync)(candidatePath, "utf8").split("\n", 1)[0];
146684
146885
  if (!firstLine) return null;
146685
146886
  const parsed = JSON.parse(firstLine);
146686
146887
  if (parsed?.type !== "session_meta") return null;
@@ -146708,18 +146909,18 @@ var StreamerServer = class {
146708
146909
  this.sessionStore.listManaged().filter((s3) => s3.id !== sessionId && s3.boundConversationId != null).map((s3) => s3.boundConversationId)
146709
146910
  );
146710
146911
  for (const root of this.codexRoots) {
146711
- const sessionsDir = (0, import_path28.join)(root, dateDir);
146712
- if (!(0, import_fs28.existsSync)(sessionsDir)) continue;
146912
+ const sessionsDir = (0, import_path29.join)(root, dateDir);
146913
+ if (!(0, import_fs29.existsSync)(sessionsDir)) continue;
146713
146914
  let candidateFiles;
146714
146915
  try {
146715
- candidateFiles = (0, import_fs28.readdirSync)(sessionsDir).filter((f2) => f2.endsWith(".jsonl"));
146916
+ candidateFiles = (0, import_fs29.readdirSync)(sessionsDir).filter((f2) => f2.endsWith(".jsonl"));
146716
146917
  } catch {
146717
146918
  continue;
146718
146919
  }
146719
146920
  const nowMs = Date.now();
146720
- const recentCandidates = candidateFiles.map((f2) => ({ f: f2, mtime: (0, import_fs28.statSync)((0, import_path28.join)(sessionsDir, f2)).mtimeMs })).filter(({ mtime }) => nowMs - mtime < 1e4).sort((a, b2) => b2.mtime - a.mtime);
146921
+ const recentCandidates = candidateFiles.map((f2) => ({ f: f2, mtime: (0, import_fs29.statSync)((0, import_path29.join)(sessionsDir, f2)).mtimeMs })).filter(({ mtime }) => nowMs - mtime < 1e4).sort((a, b2) => b2.mtime - a.mtime);
146721
146922
  for (const { f: f2 } of recentCandidates) {
146722
- const candidatePath = (0, import_path28.join)(sessionsDir, f2);
146923
+ const candidatePath = (0, import_path29.join)(sessionsDir, f2);
146723
146924
  const match2 = matchesProjectPath(candidatePath);
146724
146925
  if (!match2) continue;
146725
146926
  if (boundElsewhere.has(match2.id)) continue;
@@ -146729,7 +146930,7 @@ var StreamerServer = class {
146729
146930
  this.sessionFileMap.set(sessionId, candidatePath);
146730
146931
  this.fileWatcher.watch(candidatePath);
146731
146932
  try {
146732
- const existing = (0, import_fs28.readFileSync)(candidatePath, "utf8").split("\n").filter(Boolean);
146933
+ const existing = (0, import_fs29.readFileSync)(candidatePath, "utf8").split("\n").filter(Boolean);
146733
146934
  if (existing.length > 0) {
146734
146935
  this.broadcastConversationLines(sessionId, existing);
146735
146936
  }
@@ -146863,7 +147064,7 @@ async function waitForProcessExit(pid, timeoutMs, pollMs = ADOPT_KILL_POLL_MS) {
146863
147064
  }
146864
147065
  function classifyResumability(cwd) {
146865
147066
  if (!cwd) return { resumable: true };
146866
- if ((0, import_fs28.existsSync)(cwd)) return { resumable: true };
147067
+ if ((0, import_fs29.existsSync)(cwd)) return { resumable: true };
146867
147068
  const ranInWorktree = /\/\.worktrees\//.test(cwd) || /\/\.claude\/worktrees\//.test(cwd);
146868
147069
  return {
146869
147070
  resumable: false,
@@ -147533,13 +147734,13 @@ var import_node_fs18 = require("fs");
147533
147734
 
147534
147735
  // node_modules/tar/dist/esm/index.min.js
147535
147736
  var import_events3 = __toESM(require("events"), 1);
147536
- var import_fs29 = __toESM(require("fs"), 1);
147737
+ var import_fs30 = __toESM(require("fs"), 1);
147537
147738
  var import_node_events3 = require("events");
147538
147739
  var import_node_stream2 = __toESM(require("stream"), 1);
147539
147740
  var import_node_string_decoder = require("string_decoder");
147540
147741
  var import_node_path14 = __toESM(require("path"), 1);
147541
147742
  var import_node_fs12 = __toESM(require("fs"), 1);
147542
- var import_path29 = require("path");
147743
+ var import_path30 = require("path");
147543
147744
  var import_events4 = require("events");
147544
147745
  var import_assert = __toESM(require("assert"), 1);
147545
147746
  var import_buffer2 = require("buffer");
@@ -147547,17 +147748,17 @@ var Ps = __toESM(require("zlib"), 1);
147547
147748
  var import_zlib = __toESM(require("zlib"), 1);
147548
147749
  var import_node_path15 = require("path");
147549
147750
  var import_node_path16 = require("path");
147550
- var import_fs30 = __toESM(require("fs"), 1);
147551
147751
  var import_fs31 = __toESM(require("fs"), 1);
147552
- var import_path30 = __toESM(require("path"), 1);
147553
- var import_node_path17 = require("path");
147752
+ var import_fs32 = __toESM(require("fs"), 1);
147554
147753
  var import_path31 = __toESM(require("path"), 1);
147754
+ var import_node_path17 = require("path");
147755
+ var import_path32 = __toESM(require("path"), 1);
147555
147756
  var import_node_fs13 = __toESM(require("fs"), 1);
147556
147757
  var import_node_assert = __toESM(require("assert"), 1);
147557
147758
  var import_node_crypto5 = require("crypto");
147558
147759
  var import_node_fs14 = __toESM(require("fs"), 1);
147559
147760
  var import_node_path18 = __toESM(require("path"), 1);
147560
- var import_fs32 = __toESM(require("fs"), 1);
147761
+ var import_fs33 = __toESM(require("fs"), 1);
147561
147762
  var import_node_fs15 = __toESM(require("fs"), 1);
147562
147763
  var import_node_path19 = __toESM(require("path"), 1);
147563
147764
  var import_node_fs16 = __toESM(require("fs"), 1);
@@ -147909,7 +148110,7 @@ var A = class extends import_node_events3.EventEmitter {
147909
148110
  return Wr;
147910
148111
  }
147911
148112
  };
147912
- var Jr = import_fs29.default.writev;
148113
+ var Jr = import_fs30.default.writev;
147913
148114
  var ht = /* @__PURE__ */ Symbol("_autoClose");
147914
148115
  var H2 = /* @__PURE__ */ Symbol("_close");
147915
148116
  var te = /* @__PURE__ */ Symbol("_ended");
@@ -147964,7 +148165,7 @@ var _t = class extends A {
147964
148165
  throw new TypeError("this is a readable stream");
147965
148166
  }
147966
148167
  [at]() {
147967
- import_fs29.default.open(this[U], "r", (t, e) => this[Ht](t, e));
148168
+ import_fs30.default.open(this[U], "r", (t, e) => this[Ht](t, e));
147968
148169
  }
147969
148170
  [Ht](t, e) {
147970
148171
  t ? this[Ut](t) : (this[u] = e, this.emit("open", e), this[zt]());
@@ -147977,7 +148178,7 @@ var _t = class extends A {
147977
148178
  this[j] = true;
147978
148179
  let t = this[vi]();
147979
148180
  if (t.length === 0) return process.nextTick(() => this[Ii](null, 0, t));
147980
- import_fs29.default.read(this[u], t, 0, t.length, null, (e, i, r) => this[Ii](e, i, r));
148181
+ import_fs30.default.read(this[u], t, 0, t.length, null, (e, i, r) => this[Ii](e, i, r));
147981
148182
  }
147982
148183
  }
147983
148184
  [Ii](t, e, i) {
@@ -147986,7 +148187,7 @@ var _t = class extends A {
147986
148187
  [H2]() {
147987
148188
  if (this[ht] && typeof this[u] == "number") {
147988
148189
  let t = this[u];
147989
- this[u] = void 0, import_fs29.default.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
148190
+ this[u] = void 0, import_fs30.default.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
147990
148191
  }
147991
148192
  }
147992
148193
  [Ut](t) {
@@ -148014,7 +148215,7 @@ var Be = class extends _t {
148014
148215
  [at]() {
148015
148216
  let t = true;
148016
148217
  try {
148017
- this[Ht](null, import_fs29.default.openSync(this[U], "r")), t = false;
148218
+ this[Ht](null, import_fs30.default.openSync(this[U], "r")), t = false;
148018
148219
  } finally {
148019
148220
  t && this[H2]();
148020
148221
  }
@@ -148025,7 +148226,7 @@ var Be = class extends _t {
148025
148226
  if (!this[j]) {
148026
148227
  this[j] = true;
148027
148228
  do {
148028
- let e = this[vi](), i = e.length === 0 ? 0 : import_fs29.default.readSync(this[u], e, 0, e.length, null);
148229
+ let e = this[vi](), i = e.length === 0 ? 0 : import_fs30.default.readSync(this[u], e, 0, e.length, null);
148029
148230
  if (!this[ki](i, e)) break;
148030
148231
  } while (true);
148031
148232
  this[j] = false;
@@ -148038,7 +148239,7 @@ var Be = class extends _t {
148038
148239
  [H2]() {
148039
148240
  if (this[ht] && typeof this[u] == "number") {
148040
148241
  let t = this[u];
148041
- this[u] = void 0, import_fs29.default.closeSync(t), this.emit("close");
148242
+ this[u] = void 0, import_fs30.default.closeSync(t), this.emit("close");
148042
148243
  }
148043
148244
  }
148044
148245
  };
@@ -148080,7 +148281,7 @@ var et = class extends import_events3.default {
148080
148281
  this[H2](), this[gt] = true, this.emit("error", t);
148081
148282
  }
148082
148283
  [at]() {
148083
- import_fs29.default.open(this[U], this[tt], this[ie], (t, e) => this[Ht](t, e));
148284
+ import_fs30.default.open(this[U], this[tt], this[ie], (t, e) => this[Ht](t, e));
148084
148285
  }
148085
148286
  [Ht](t, e) {
148086
148287
  this[Me] && this[tt] === "r+" && t && t.code === "ENOENT" ? (this[tt] = "w", this[at]()) : t ? this[Ut](t) : (this[u] = e, this.emit("open", e), this[gt] || this[Ai]());
@@ -148092,7 +148293,7 @@ var et = class extends import_events3.default {
148092
148293
  return typeof t == "string" && (t = Buffer.from(t, e)), this[te] ? (this.emit("error", new Error("write() after end()")), false) : this[u] === void 0 || this[gt] || this[Y2].length ? (this[Y2].push(t), this[ke] = true, false) : (this[gt] = true, this[ve](t), true);
148093
148294
  }
148094
148295
  [ve](t) {
148095
- import_fs29.default.write(this[u], t, 0, t.length, this[ot], (e, i) => this[Pt](e, i));
148296
+ import_fs30.default.write(this[u], t, 0, t.length, this[ot], (e, i) => this[Pt](e, i));
148096
148297
  }
148097
148298
  [Pt](t, e) {
148098
148299
  t ? this[Ut](t) : (this[ot] !== void 0 && typeof e == "number" && (this[ot] += e), this[Y2].length ? this[Ai]() : (this[gt] = false, this[te] && !this[Ni] ? (this[Ni] = true, this[H2](), this.emit("finish")) : this[ke] && (this[ke] = false, this.emit("drain"))));
@@ -148108,7 +148309,7 @@ var et = class extends import_events3.default {
148108
148309
  [H2]() {
148109
148310
  if (this[ht] && typeof this[u] == "number") {
148110
148311
  let t = this[u];
148111
- this[u] = void 0, import_fs29.default.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
148312
+ this[u] = void 0, import_fs30.default.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
148112
148313
  }
148113
148314
  }
148114
148315
  };
@@ -148116,24 +148317,24 @@ var Wt = class extends et {
148116
148317
  [at]() {
148117
148318
  let t;
148118
148319
  if (this[Me] && this[tt] === "r+") try {
148119
- t = import_fs29.default.openSync(this[U], this[tt], this[ie]);
148320
+ t = import_fs30.default.openSync(this[U], this[tt], this[ie]);
148120
148321
  } catch (e) {
148121
148322
  if (e?.code === "ENOENT") return this[tt] = "w", this[at]();
148122
148323
  throw e;
148123
148324
  }
148124
- else t = import_fs29.default.openSync(this[U], this[tt], this[ie]);
148325
+ else t = import_fs30.default.openSync(this[U], this[tt], this[ie]);
148125
148326
  this[Ht](null, t);
148126
148327
  }
148127
148328
  [H2]() {
148128
148329
  if (this[ht] && typeof this[u] == "number") {
148129
148330
  let t = this[u];
148130
- this[u] = void 0, import_fs29.default.closeSync(t), this.emit("close");
148331
+ this[u] = void 0, import_fs30.default.closeSync(t), this.emit("close");
148131
148332
  }
148132
148333
  }
148133
148334
  [ve](t) {
148134
148335
  let e = true;
148135
148336
  try {
148136
- this[Pt](null, import_fs29.default.writeSync(this[u], t, 0, t.length, this[ot])), e = false;
148337
+ this[Pt](null, import_fs30.default.writeSync(this[u], t, 0, t.length, this[ot])), e = false;
148137
148338
  } finally {
148138
148339
  if (e) try {
148139
148340
  this[H2]();
@@ -148916,11 +149117,11 @@ var vn = (s3) => {
148916
149117
  };
148917
149118
  var Qi = (s3, t) => {
148918
149119
  let e = new Map(t.map((n) => [ut(n), true])), i = s3.filter, r = (n, o = "") => {
148919
- let h = o || (0, import_path29.parse)(n).root || ".", a;
149120
+ let h = o || (0, import_path30.parse)(n).root || ".", a;
148920
149121
  if (n === h) a = false;
148921
149122
  else {
148922
149123
  let l = e.get(n);
148923
- a = l !== void 0 ? l : r((0, import_path29.dirname)(n), h);
149124
+ a = l !== void 0 ? l : r((0, import_path30.dirname)(n), h);
148924
149125
  }
148925
149126
  return e.set(n, a), a;
148926
149127
  };
@@ -149040,7 +149241,7 @@ var de = class extends A {
149040
149241
  let [o, h] = ce(this.path);
149041
149242
  o && typeof h == "string" && (this.path = h, r = o);
149042
149243
  }
149043
- this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = Qs(this.path.replaceAll(/\\/g, "/")), t = t.replaceAll(/\\/g, "/")), this.absolute = f(i.absolute || import_path30.default.resolve(this.cwd, t)), this.path === "" && (this.path = "./"), r && this.warn("TAR_ENTRY_INFO", `stripping ${r} from absolute path`, { entry: this, path: r + this.path });
149244
+ this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = Qs(this.path.replaceAll(/\\/g, "/")), t = t.replaceAll(/\\/g, "/")), this.absolute = f(i.absolute || import_path31.default.resolve(this.cwd, t)), this.path === "" && (this.path = "./"), r && this.warn("TAR_ENTRY_INFO", `stripping ${r} from absolute path`, { entry: this, path: r + this.path });
149044
149245
  let n = this.statCache.get(this.absolute);
149045
149246
  n ? this[si](n) : this[ss]();
149046
149247
  }
@@ -149051,7 +149252,7 @@ var de = class extends A {
149051
149252
  return t === "error" && (this.#t = true), super.emit(t, ...e);
149052
149253
  }
149053
149254
  [ss]() {
149054
- import_fs31.default.lstat(this.absolute, (t, e) => {
149255
+ import_fs32.default.lstat(this.absolute, (t, e) => {
149055
149256
  if (t) return this.emit("error", t);
149056
149257
  this[si](e);
149057
149258
  });
@@ -149089,7 +149290,7 @@ var de = class extends A {
149089
149290
  this.path.slice(-1) !== "/" && (this.path += "/"), this.stat.size = 0, this[fe](), this.end();
149090
149291
  }
149091
149292
  [is]() {
149092
- import_fs31.default.readlink(this.absolute, (t, e) => {
149293
+ import_fs32.default.readlink(this.absolute, (t, e) => {
149093
149294
  if (t) return this.emit("error", t);
149094
149295
  this[ns](e);
149095
149296
  });
@@ -149099,7 +149300,7 @@ var de = class extends A {
149099
149300
  }
149100
149301
  [sr](t) {
149101
149302
  if (!this.stat) throw new Error("cannot create link entry without stat");
149102
- this.type = "Link", this.linkpath = f(import_path30.default.relative(this.cwd, t)), this.stat.size = 0, this[fe](), this.end();
149303
+ this.type = "Link", this.linkpath = f(import_path31.default.relative(this.cwd, t)), this.stat.size = 0, this[fe](), this.end();
149103
149304
  }
149104
149305
  [er]() {
149105
149306
  if (!this.stat) throw new Error("cannot create file entry without stat");
@@ -149112,7 +149313,7 @@ var de = class extends A {
149112
149313
  this[os]();
149113
149314
  }
149114
149315
  [os]() {
149115
- import_fs31.default.open(this.absolute, "r", (t, e) => {
149316
+ import_fs32.default.open(this.absolute, "r", (t, e) => {
149116
149317
  if (t) return this.emit("error", t);
149117
149318
  this[hs](e);
149118
149319
  });
@@ -149127,14 +149328,14 @@ var de = class extends A {
149127
149328
  [ii]() {
149128
149329
  let { fd: t, buf: e, offset: i, length: r, pos: n } = this;
149129
149330
  if (t === void 0 || e === void 0) throw new Error("cannot read file without first opening");
149130
- import_fs31.default.read(t, e, i, r, n, (o, h) => {
149331
+ import_fs32.default.read(t, e, i, r, n, (o, h) => {
149131
149332
  if (o) return this[pt](() => this.emit("error", o));
149132
149333
  this[rs](h);
149133
149334
  });
149134
149335
  }
149135
149336
  [pt](t = () => {
149136
149337
  }) {
149137
- this.fd !== void 0 && import_fs31.default.close(this.fd, t);
149338
+ this.fd !== void 0 && import_fs32.default.close(this.fd, t);
149138
149339
  }
149139
149340
  [rs](t) {
149140
149341
  if (t <= 0 && this.remain > 0) {
@@ -149169,20 +149370,20 @@ var de = class extends A {
149169
149370
  var ni = class extends de {
149170
149371
  sync = true;
149171
149372
  [ss]() {
149172
- this[si](import_fs31.default.lstatSync(this.absolute));
149373
+ this[si](import_fs32.default.lstatSync(this.absolute));
149173
149374
  }
149174
149375
  [is]() {
149175
- this[ns](import_fs31.default.readlinkSync(this.absolute));
149376
+ this[ns](import_fs32.default.readlinkSync(this.absolute));
149176
149377
  }
149177
149378
  [os]() {
149178
- this[hs](import_fs31.default.openSync(this.absolute, "r"));
149379
+ this[hs](import_fs32.default.openSync(this.absolute, "r"));
149179
149380
  }
149180
149381
  [ii]() {
149181
149382
  let t = true;
149182
149383
  try {
149183
149384
  let { fd: e, buf: i, offset: r, length: n, pos: o } = this;
149184
149385
  if (e === void 0 || i === void 0) throw new Error("fd and buf must be set in READ method");
149185
- let h = import_fs31.default.readSync(e, i, r, n, o);
149386
+ let h = import_fs32.default.readSync(e, i, r, n, o);
149186
149387
  this[rs](h), t = false;
149187
149388
  } finally {
149188
149389
  if (t) try {
@@ -149197,7 +149398,7 @@ var ni = class extends de {
149197
149398
  }
149198
149399
  [pt](t = () => {
149199
149400
  }) {
149200
- this.fd !== void 0 && import_fs31.default.closeSync(this.fd), t();
149401
+ this.fd !== void 0 && import_fs32.default.closeSync(this.fd), t();
149201
149402
  }
149202
149403
  };
149203
149404
  var oi = class extends A {
@@ -149513,7 +149714,7 @@ var wt = class extends A {
149513
149714
  return typeof t == "string" ? this[ci](t) : this[or](t), this.flowing;
149514
149715
  }
149515
149716
  [or](t) {
149516
- let e = f(import_path31.default.resolve(this.cwd, t.path));
149717
+ let e = f(import_path32.default.resolve(this.cwd, t.path));
149517
149718
  if (!this.filter(t.path, t)) t.resume();
149518
149719
  else {
149519
149720
  let i = new pi(t.path, e);
@@ -149522,13 +149723,13 @@ var wt = class extends A {
149522
149723
  this[Ft]();
149523
149724
  }
149524
149725
  [ci](t) {
149525
- let e = f(import_path31.default.resolve(this.cwd, t));
149726
+ let e = f(import_path32.default.resolve(this.cwd, t));
149526
149727
  this[W2].push(new pi(t, e)), this[Ft]();
149527
149728
  }
149528
149729
  [ds](t) {
149529
149730
  t.pending = true, this[G] += 1;
149530
149731
  let e = this.follow ? "stat" : "lstat";
149531
- import_fs30.default[e](t.absolute, (i, r) => {
149732
+ import_fs31.default[e](t.absolute, (i, r) => {
149532
149733
  t.pending = false, this[G] -= 1, i ? this.emit("error", i) : this[li](t, r);
149533
149734
  });
149534
149735
  }
@@ -149542,7 +149743,7 @@ var wt = class extends A {
149542
149743
  this[Ft]();
149543
149744
  }
149544
149745
  [ms](t) {
149545
- t.pending = true, this[G] += 1, import_fs30.default.readdir(t.absolute, (e, i) => {
149746
+ t.pending = true, this[G] += 1, import_fs31.default.readdir(t.absolute, (e, i) => {
149546
149747
  if (t.pending = false, this[G] -= 1, e) return this.emit("error", e);
149547
149748
  this[fi](t, i);
149548
149749
  });
@@ -149643,10 +149844,10 @@ var kt = class extends wt {
149643
149844
  }
149644
149845
  [ds](t) {
149645
149846
  let e = this.follow ? "statSync" : "lstatSync";
149646
- this[li](t, import_fs30.default[e](t.absolute));
149847
+ this[li](t, import_fs31.default[e](t.absolute));
149647
149848
  }
149648
149849
  [ms](t) {
149649
- this[fi](t, import_fs30.default.readdirSync(t.absolute));
149850
+ this[fi](t, import_fs31.default.readdirSync(t.absolute));
149650
149851
  }
149651
149852
  [di](t) {
149652
149853
  let e = t.entry, i = this.zip;
@@ -149697,8 +149898,8 @@ var Qn = K(Vn, $n, Xn, qn, (s3, t) => {
149697
149898
  });
149698
149899
  var Jn = process.env.__FAKE_PLATFORM__ || process.platform;
149699
149900
  var Er = Jn === "win32";
149700
- var { O_CREAT: wr, O_NOFOLLOW: mr, O_TRUNC: Sr, O_WRONLY: yr } = import_fs32.default.constants;
149701
- var Rr = Number(process.env.__FAKE_FS_O_FILENAME__) || import_fs32.default.constants.UV_FS_O_FILEMAP || 0;
149901
+ var { O_CREAT: wr, O_NOFOLLOW: mr, O_TRUNC: Sr, O_WRONLY: yr } = import_fs33.default.constants;
149902
+ var Rr = Number(process.env.__FAKE_FS_O_FILENAME__) || import_fs33.default.constants.UV_FS_O_FILEMAP || 0;
149702
149903
  var jn = Er && !!Rr;
149703
149904
  var to = 512 * 1024;
149704
149905
  var eo = Rr | Sr | wr | yr;
@@ -151038,8 +151239,8 @@ program2.command("cache").description("Manage the local SQLite conversation cach
151038
151239
  `${process.env.HOME}/.threadbase/cache`
151039
151240
  ).action((opts) => {
151040
151241
  const { rmSync: rmSync6, existsSync: existsSync15 } = require("fs");
151041
- const { join: join28 } = require("path");
151042
- const dbPath = join28(opts.cacheDir, "cache.db");
151242
+ const { join: join29 } = require("path");
151243
+ const dbPath = join29(opts.cacheDir, "cache.db");
151043
151244
  for (const suffix of ["", "-shm", "-wal"]) {
151044
151245
  const f2 = dbPath + suffix;
151045
151246
  if (existsSync15(f2)) {