@adhdev/daemon-standalone 0.9.82-rc.267 → 0.9.82-rc.268

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -29973,10 +29973,10 @@ var require_dist3 = __commonJS({
29973
29973
  }
29974
29974
  function getDaemonBuildInfo() {
29975
29975
  if (cached2) return cached2;
29976
- const commit = readInjected(true ? "bf805cc2b4d63e722d2e330fa10a9890db3b4668" : void 0) ?? "unknown";
29977
- const commitShort = readInjected(true ? "bf805cc2" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
29978
- const version2 = readInjected(true ? "0.9.82-rc.267" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
29979
- const builtAt = readInjected(true ? "2026-06-14T20:02:11.633Z" : void 0);
29976
+ const commit = readInjected(true ? "9da2b92afe11e5b813734c9f389479542e25a41f" : void 0) ?? "unknown";
29977
+ const commitShort = readInjected(true ? "9da2b92a" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
29978
+ const version2 = readInjected(true ? "0.9.82-rc.268" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
29979
+ const builtAt = readInjected(true ? "2026-06-14T21:47:30.810Z" : void 0);
29980
29980
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
29981
29981
  return cached2;
29982
29982
  }
@@ -44827,11 +44827,22 @@ ${lastSnapshot}`;
44827
44827
  if (response.promptId !== prompt.promptId) throw new Error("Interactive prompt response does not match active prompt");
44828
44828
  const steps = [];
44829
44829
  for (const question of prompt.questions) {
44830
- if (question.multiSelect) throw new Error("Claude TUI multi-select prompts are not supported yet");
44831
44830
  const answer = response.answers[question.questionId];
44832
44831
  if (!answer) throw new Error(`Missing answer for ${question.questionId}`);
44833
44832
  const freeformText = answer.freeformText?.trim() ?? "";
44834
- if (freeformText) {
44833
+ if (question.multiSelect) {
44834
+ const labels = answer.selectedLabels;
44835
+ if (labels.length === 0) {
44836
+ throw new Error(`Expected at least one selected label for ${question.questionId}`);
44837
+ }
44838
+ for (const label of labels) {
44839
+ const selectedIndex = question.options.findIndex((option) => option.label === label);
44840
+ if (selectedIndex < 0) throw new Error(`Unknown option for ${question.questionId}: ${label}`);
44841
+ steps.push(String(selectedIndex + 1));
44842
+ steps.push(" ");
44843
+ }
44844
+ steps.push("\r");
44845
+ } else if (freeformText) {
44835
44846
  const typeOptionIndex = question.options.findIndex((o) => /^Type something\.?$/i.test(o.label));
44836
44847
  const optionNumber = typeOptionIndex >= 0 ? typeOptionIndex + 1 : question.options.length;
44837
44848
  steps.push(String(optionNumber));
@@ -49926,6 +49937,24 @@ ${cleanBody}`;
49926
49937
  var savedHistoryFileSummaryCache = /* @__PURE__ */ new Map();
49927
49938
  var savedHistoryBackgroundRefresh = /* @__PURE__ */ new Set();
49928
49939
  var savedHistoryRollupInFlight = /* @__PURE__ */ new Set();
49940
+ var BOUNDED_TAIL_CACHE_MAX_ENTRIES = 64;
49941
+ var boundedTailReadCache = /* @__PURE__ */ new Map();
49942
+ function readBoundedTailCache(key, signature) {
49943
+ const cached22 = boundedTailReadCache.get(key);
49944
+ if (!cached22 || cached22.signature !== signature) return null;
49945
+ boundedTailReadCache.delete(key);
49946
+ boundedTailReadCache.set(key, cached22);
49947
+ return cached22.result;
49948
+ }
49949
+ function writeBoundedTailCache(key, signature, result) {
49950
+ boundedTailReadCache.delete(key);
49951
+ boundedTailReadCache.set(key, { signature, result });
49952
+ while (boundedTailReadCache.size > BOUNDED_TAIL_CACHE_MAX_ENTRIES) {
49953
+ const oldest = boundedTailReadCache.keys().next().value;
49954
+ if (oldest === void 0) break;
49955
+ boundedTailReadCache.delete(oldest);
49956
+ }
49957
+ }
49929
49958
  function normalizeHistoryComparable(text) {
49930
49959
  return String(text || "").replace(/\s+/g, " ").trim();
49931
49960
  }
@@ -50810,12 +50839,73 @@ ${cleanBody}`;
50810
50839
  const sliced = collapsed.slice(startInclusive, endExclusive);
50811
50840
  return { messages: sliced, hasMore: startInclusive > 0 };
50812
50841
  }
50842
+ var BOUNDED_TAIL_MAX_LIMIT = 5e3;
50843
+ var BOUNDED_TAIL_SLACK = 50;
50844
+ function isBoundedTailRequest(limit, offset, excludeRecentCount) {
50845
+ const numericLimit = Number(limit);
50846
+ if (!Number.isFinite(numericLimit) || numericLimit <= 0) return false;
50847
+ if (numericLimit > BOUNDED_TAIL_MAX_LIMIT) return false;
50848
+ const numericOffset = Number(offset);
50849
+ const numericExclude = Number(excludeRecentCount);
50850
+ if (!Number.isFinite(numericOffset) || !Number.isFinite(numericExclude)) return false;
50851
+ return true;
50852
+ }
50853
+ function readBoundedTailRecords(agentType, dir, files, needed) {
50854
+ const collected = [];
50855
+ const seen = /* @__PURE__ */ new Set();
50856
+ let readAllFiles = true;
50857
+ for (let f = 0; f < files.length; f++) {
50858
+ const filePath = path12.join(dir, files[f]);
50859
+ let content;
50860
+ try {
50861
+ content = fs52.readFileSync(filePath, "utf-8");
50862
+ } catch {
50863
+ continue;
50864
+ }
50865
+ const lines = content.trim().split("\n").filter(Boolean);
50866
+ for (let i = lines.length - 1; i >= 0; i--) {
50867
+ try {
50868
+ const parsed = JSON.parse(lines[i]);
50869
+ const sanitizedMessage = sanitizeHistoryMessage(agentType, parsed);
50870
+ if (!sanitizedMessage) continue;
50871
+ const hash2 = buildHistoryMessageHash(agentType, sanitizedMessage);
50872
+ if (seen.has(hash2)) continue;
50873
+ seen.add(hash2);
50874
+ collected.push(sanitizedMessage);
50875
+ } catch {
50876
+ }
50877
+ }
50878
+ if (collected.length >= needed && f < files.length - 1) {
50879
+ readAllFiles = false;
50880
+ break;
50881
+ }
50882
+ }
50883
+ collected.reverse();
50884
+ return { records: collected, readAllFiles };
50885
+ }
50813
50886
  function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, excludeRecentCount = 0, historyBehavior) {
50814
50887
  try {
50815
50888
  const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
50816
50889
  const dir = path12.join(HISTORY_DIR, sanitized);
50817
50890
  if (!fs52.existsSync(dir)) return { messages: [], hasMore: false };
50818
50891
  const files = listHistoryFiles(dir, historySessionId);
50892
+ const bounded = isBoundedTailRequest(limit, offset, excludeRecentCount);
50893
+ if (bounded) {
50894
+ const fileSignatures = buildSavedHistoryFileSignatureMap(dir, files);
50895
+ const cacheKey = `${sanitized}\0${historySessionId || ""}\0${offset}\0${limit}\0${excludeRecentCount}\0${historyBehavior?.collapseConsecutiveAssistantTurns ? "1" : "0"}`;
50896
+ const signature = buildSavedHistoryCacheSignature(files, fileSignatures);
50897
+ const cached22 = readBoundedTailCache(cacheKey, signature);
50898
+ if (cached22) return cached22;
50899
+ const numericLimit = Math.max(1, Number(limit));
50900
+ const numericOffset = Math.max(0, Number(offset));
50901
+ const numericExclude = Math.max(0, Number(excludeRecentCount));
50902
+ const needed = numericLimit + numericOffset + numericExclude + Math.max(BOUNDED_TAIL_SLACK, numericLimit);
50903
+ const { records, readAllFiles } = readBoundedTailRecords(agentType, dir, files, needed);
50904
+ const result = pageHistoryRecords(agentType, records, offset, limit, excludeRecentCount, historyBehavior);
50905
+ const boundedResult = readAllFiles ? result : { messages: result.messages, hasMore: true };
50906
+ writeBoundedTailCache(cacheKey, signature, boundedResult);
50907
+ return boundedResult;
50908
+ }
50819
50909
  const allMessages = [];
50820
50910
  const seen = /* @__PURE__ */ new Set();
50821
50911
  for (const file2 of files) {
@@ -53973,6 +54063,7 @@ ${effect.notification.body || ""}`.trim();
53973
54063
  var CHAT_SOURCE_REGISTRY = new ChatSourceRegistry();
53974
54064
  var RECENT_SEND_WINDOW_MS = 1200;
53975
54065
  var READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
54066
+ var HOT_TAIL_MIN_LIMIT = 60;
53976
54067
  var HERMES_CLI_STARTING_SEND_SETTLE_MS = 2e3;
53977
54068
  var CLI_NATIVE_TRANSCRIPT_PROVIDERS = /* @__PURE__ */ new Set(["codex-cli", "claude-cli", "hermes-cli", "antigravity-cli"]);
53978
54069
  var warnedLegacyNativeAllowlistHits = /* @__PURE__ */ new Set();
@@ -54515,7 +54606,7 @@ ${effect.notification.body || ""}`.trim();
54515
54606
  const history = readChatHistory(
54516
54607
  args.providerType,
54517
54608
  0,
54518
- Math.max(args.tailLimit || 0, 200),
54609
+ Math.max(args.tailLimit || 0, HOT_TAIL_MIN_LIMIT),
54519
54610
  targetSessionId,
54520
54611
  0,
54521
54612
  args.historyBehavior
@@ -55408,7 +55499,7 @@ ${effect.notification.body || ""}`.trim();
55408
55499
  const nativeHistoryLimit = Math.max(
55409
55500
  normalizeReadChatTailLimit(args) || 0,
55410
55501
  returnedMessages.length,
55411
- 200
55502
+ HOT_TAIL_MIN_LIMIT
55412
55503
  );
55413
55504
  const nativeHistorySessionId = supportsNative ? resolveCliNativeHistorySessionId(args, historySessionId, providerSessionId) : void 0;
55414
55505
  const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";