@adhdev/daemon-core 0.9.82-rc.266 → 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 +99 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/commands/chat-commands.ts +9 -2
- package/src/config/chat-history.ts +134 -0
- package/src/providers/cli-provider-instance.ts +8 -0
- package/src/providers/types/interactive-prompt.ts +23 -2
package/dist/index.mjs
CHANGED
|
@@ -260,10 +260,10 @@ function readInjected(value) {
|
|
|
260
260
|
}
|
|
261
261
|
function getDaemonBuildInfo() {
|
|
262
262
|
if (cached) return cached;
|
|
263
|
-
const commit = readInjected(true ? "
|
|
264
|
-
const commitShort = readInjected(true ? "
|
|
265
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
266
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
263
|
+
const commit = readInjected(true ? "9da2b92afe11e5b813734c9f389479542e25a41f" : void 0) ?? "unknown";
|
|
264
|
+
const commitShort = readInjected(true ? "9da2b92a" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
265
|
+
const version = readInjected(true ? "0.9.82-rc.268" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
266
|
+
const builtAt = readInjected(true ? "2026-06-14T21:47:03.827Z" : void 0);
|
|
267
267
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
268
268
|
return cached;
|
|
269
269
|
}
|
|
@@ -14716,11 +14716,22 @@ function buildClaudeInteractiveTuiAnswerSteps(prompt, response) {
|
|
|
14716
14716
|
if (response.promptId !== prompt.promptId) throw new Error("Interactive prompt response does not match active prompt");
|
|
14717
14717
|
const steps = [];
|
|
14718
14718
|
for (const question of prompt.questions) {
|
|
14719
|
-
if (question.multiSelect) throw new Error("Claude TUI multi-select prompts are not supported yet");
|
|
14720
14719
|
const answer = response.answers[question.questionId];
|
|
14721
14720
|
if (!answer) throw new Error(`Missing answer for ${question.questionId}`);
|
|
14722
14721
|
const freeformText = answer.freeformText?.trim() ?? "";
|
|
14723
|
-
if (
|
|
14722
|
+
if (question.multiSelect) {
|
|
14723
|
+
const labels = answer.selectedLabels;
|
|
14724
|
+
if (labels.length === 0) {
|
|
14725
|
+
throw new Error(`Expected at least one selected label for ${question.questionId}`);
|
|
14726
|
+
}
|
|
14727
|
+
for (const label of labels) {
|
|
14728
|
+
const selectedIndex = question.options.findIndex((option) => option.label === label);
|
|
14729
|
+
if (selectedIndex < 0) throw new Error(`Unknown option for ${question.questionId}: ${label}`);
|
|
14730
|
+
steps.push(String(selectedIndex + 1));
|
|
14731
|
+
steps.push(" ");
|
|
14732
|
+
}
|
|
14733
|
+
steps.push("\r");
|
|
14734
|
+
} else if (freeformText) {
|
|
14724
14735
|
const typeOptionIndex = question.options.findIndex((o) => /^Type something\.?$/i.test(o.label));
|
|
14725
14736
|
const optionNumber = typeOptionIndex >= 0 ? typeOptionIndex + 1 : question.options.length;
|
|
14726
14737
|
steps.push(String(optionNumber));
|
|
@@ -19897,6 +19908,24 @@ var savedHistorySessionCache = /* @__PURE__ */ new Map();
|
|
|
19897
19908
|
var savedHistoryFileSummaryCache = /* @__PURE__ */ new Map();
|
|
19898
19909
|
var savedHistoryBackgroundRefresh = /* @__PURE__ */ new Set();
|
|
19899
19910
|
var savedHistoryRollupInFlight = /* @__PURE__ */ new Set();
|
|
19911
|
+
var BOUNDED_TAIL_CACHE_MAX_ENTRIES = 64;
|
|
19912
|
+
var boundedTailReadCache = /* @__PURE__ */ new Map();
|
|
19913
|
+
function readBoundedTailCache(key, signature) {
|
|
19914
|
+
const cached2 = boundedTailReadCache.get(key);
|
|
19915
|
+
if (!cached2 || cached2.signature !== signature) return null;
|
|
19916
|
+
boundedTailReadCache.delete(key);
|
|
19917
|
+
boundedTailReadCache.set(key, cached2);
|
|
19918
|
+
return cached2.result;
|
|
19919
|
+
}
|
|
19920
|
+
function writeBoundedTailCache(key, signature, result) {
|
|
19921
|
+
boundedTailReadCache.delete(key);
|
|
19922
|
+
boundedTailReadCache.set(key, { signature, result });
|
|
19923
|
+
while (boundedTailReadCache.size > BOUNDED_TAIL_CACHE_MAX_ENTRIES) {
|
|
19924
|
+
const oldest = boundedTailReadCache.keys().next().value;
|
|
19925
|
+
if (oldest === void 0) break;
|
|
19926
|
+
boundedTailReadCache.delete(oldest);
|
|
19927
|
+
}
|
|
19928
|
+
}
|
|
19900
19929
|
function normalizeHistoryComparable(text) {
|
|
19901
19930
|
return String(text || "").replace(/\s+/g, " ").trim();
|
|
19902
19931
|
}
|
|
@@ -20781,12 +20810,73 @@ function pageHistoryRecords(agentType, records, offset = 0, limit = 30, excludeR
|
|
|
20781
20810
|
const sliced = collapsed.slice(startInclusive, endExclusive);
|
|
20782
20811
|
return { messages: sliced, hasMore: startInclusive > 0 };
|
|
20783
20812
|
}
|
|
20813
|
+
var BOUNDED_TAIL_MAX_LIMIT = 5e3;
|
|
20814
|
+
var BOUNDED_TAIL_SLACK = 50;
|
|
20815
|
+
function isBoundedTailRequest(limit, offset, excludeRecentCount) {
|
|
20816
|
+
const numericLimit = Number(limit);
|
|
20817
|
+
if (!Number.isFinite(numericLimit) || numericLimit <= 0) return false;
|
|
20818
|
+
if (numericLimit > BOUNDED_TAIL_MAX_LIMIT) return false;
|
|
20819
|
+
const numericOffset = Number(offset);
|
|
20820
|
+
const numericExclude = Number(excludeRecentCount);
|
|
20821
|
+
if (!Number.isFinite(numericOffset) || !Number.isFinite(numericExclude)) return false;
|
|
20822
|
+
return true;
|
|
20823
|
+
}
|
|
20824
|
+
function readBoundedTailRecords(agentType, dir, files, needed) {
|
|
20825
|
+
const collected = [];
|
|
20826
|
+
const seen = /* @__PURE__ */ new Set();
|
|
20827
|
+
let readAllFiles = true;
|
|
20828
|
+
for (let f = 0; f < files.length; f++) {
|
|
20829
|
+
const filePath = path12.join(dir, files[f]);
|
|
20830
|
+
let content;
|
|
20831
|
+
try {
|
|
20832
|
+
content = fs5.readFileSync(filePath, "utf-8");
|
|
20833
|
+
} catch {
|
|
20834
|
+
continue;
|
|
20835
|
+
}
|
|
20836
|
+
const lines = content.trim().split("\n").filter(Boolean);
|
|
20837
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
20838
|
+
try {
|
|
20839
|
+
const parsed = JSON.parse(lines[i]);
|
|
20840
|
+
const sanitizedMessage = sanitizeHistoryMessage(agentType, parsed);
|
|
20841
|
+
if (!sanitizedMessage) continue;
|
|
20842
|
+
const hash = buildHistoryMessageHash(agentType, sanitizedMessage);
|
|
20843
|
+
if (seen.has(hash)) continue;
|
|
20844
|
+
seen.add(hash);
|
|
20845
|
+
collected.push(sanitizedMessage);
|
|
20846
|
+
} catch {
|
|
20847
|
+
}
|
|
20848
|
+
}
|
|
20849
|
+
if (collected.length >= needed && f < files.length - 1) {
|
|
20850
|
+
readAllFiles = false;
|
|
20851
|
+
break;
|
|
20852
|
+
}
|
|
20853
|
+
}
|
|
20854
|
+
collected.reverse();
|
|
20855
|
+
return { records: collected, readAllFiles };
|
|
20856
|
+
}
|
|
20784
20857
|
function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, excludeRecentCount = 0, historyBehavior) {
|
|
20785
20858
|
try {
|
|
20786
20859
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
20787
20860
|
const dir = path12.join(HISTORY_DIR, sanitized);
|
|
20788
20861
|
if (!fs5.existsSync(dir)) return { messages: [], hasMore: false };
|
|
20789
20862
|
const files = listHistoryFiles(dir, historySessionId);
|
|
20863
|
+
const bounded = isBoundedTailRequest(limit, offset, excludeRecentCount);
|
|
20864
|
+
if (bounded) {
|
|
20865
|
+
const fileSignatures = buildSavedHistoryFileSignatureMap(dir, files);
|
|
20866
|
+
const cacheKey = `${sanitized}\0${historySessionId || ""}\0${offset}\0${limit}\0${excludeRecentCount}\0${historyBehavior?.collapseConsecutiveAssistantTurns ? "1" : "0"}`;
|
|
20867
|
+
const signature = buildSavedHistoryCacheSignature(files, fileSignatures);
|
|
20868
|
+
const cached2 = readBoundedTailCache(cacheKey, signature);
|
|
20869
|
+
if (cached2) return cached2;
|
|
20870
|
+
const numericLimit = Math.max(1, Number(limit));
|
|
20871
|
+
const numericOffset = Math.max(0, Number(offset));
|
|
20872
|
+
const numericExclude = Math.max(0, Number(excludeRecentCount));
|
|
20873
|
+
const needed = numericLimit + numericOffset + numericExclude + Math.max(BOUNDED_TAIL_SLACK, numericLimit);
|
|
20874
|
+
const { records, readAllFiles } = readBoundedTailRecords(agentType, dir, files, needed);
|
|
20875
|
+
const result = pageHistoryRecords(agentType, records, offset, limit, excludeRecentCount, historyBehavior);
|
|
20876
|
+
const boundedResult = readAllFiles ? result : { messages: result.messages, hasMore: true };
|
|
20877
|
+
writeBoundedTailCache(cacheKey, signature, boundedResult);
|
|
20878
|
+
return boundedResult;
|
|
20879
|
+
}
|
|
20790
20880
|
const allMessages = [];
|
|
20791
20881
|
const seen = /* @__PURE__ */ new Set();
|
|
20792
20882
|
for (const file of files) {
|
|
@@ -23996,6 +24086,7 @@ var CHAT_SOURCE_REGISTRY = new ChatSourceRegistry();
|
|
|
23996
24086
|
// src/commands/chat-commands.ts
|
|
23997
24087
|
var RECENT_SEND_WINDOW_MS = 1200;
|
|
23998
24088
|
var READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
|
|
24089
|
+
var HOT_TAIL_MIN_LIMIT = 60;
|
|
23999
24090
|
var HERMES_CLI_STARTING_SEND_SETTLE_MS = 2e3;
|
|
24000
24091
|
var CLI_NATIVE_TRANSCRIPT_PROVIDERS = /* @__PURE__ */ new Set(["codex-cli", "claude-cli", "hermes-cli", "antigravity-cli"]);
|
|
24001
24092
|
var warnedLegacyNativeAllowlistHits = /* @__PURE__ */ new Set();
|
|
@@ -24538,7 +24629,7 @@ function readExactRuntimeMirrorMessages(args) {
|
|
|
24538
24629
|
const history = readChatHistory(
|
|
24539
24630
|
args.providerType,
|
|
24540
24631
|
0,
|
|
24541
|
-
Math.max(args.tailLimit || 0,
|
|
24632
|
+
Math.max(args.tailLimit || 0, HOT_TAIL_MIN_LIMIT),
|
|
24542
24633
|
targetSessionId,
|
|
24543
24634
|
0,
|
|
24544
24635
|
args.historyBehavior
|
|
@@ -25431,7 +25522,7 @@ async function handleReadChat(h, args) {
|
|
|
25431
25522
|
const nativeHistoryLimit = Math.max(
|
|
25432
25523
|
normalizeReadChatTailLimit(args) || 0,
|
|
25433
25524
|
returnedMessages.length,
|
|
25434
|
-
|
|
25525
|
+
HOT_TAIL_MIN_LIMIT
|
|
25435
25526
|
);
|
|
25436
25527
|
const nativeHistorySessionId = supportsNative ? resolveCliNativeHistorySessionId(args, historySessionId, providerSessionId) : void 0;
|
|
25437
25528
|
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|