@adhdev/daemon-standalone 0.9.36 → 0.9.37
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
|
@@ -29560,27 +29560,86 @@ var require_dist2 = __commonJS({
|
|
|
29560
29560
|
function hydrateCliParsedMessages(parsedMessages, options) {
|
|
29561
29561
|
const { committedMessages, scope, lastOutputAt } = options;
|
|
29562
29562
|
const referenceMessages = [...committedMessages];
|
|
29563
|
-
const referenceComparables = referenceMessages.
|
|
29563
|
+
const referenceComparables = new Array(referenceMessages.length);
|
|
29564
29564
|
const usedReferenceIndexes = /* @__PURE__ */ new Set();
|
|
29565
29565
|
const now = options.now ?? Date.now();
|
|
29566
|
-
|
|
29566
|
+
let exactReferenceIndexesByKey = null;
|
|
29567
|
+
const exactReferenceCursorByKey = /* @__PURE__ */ new Map();
|
|
29568
|
+
const hasFiniteTimestamp = (message) => typeof message?.timestamp === "number" && Number.isFinite(message.timestamp);
|
|
29569
|
+
const getReferenceComparable = (index) => {
|
|
29570
|
+
if (typeof referenceComparables[index] === "string") return referenceComparables[index] || "";
|
|
29571
|
+
const comparable = normalizeComparableMessageContent(referenceMessages[index]?.content || "");
|
|
29572
|
+
referenceComparables[index] = comparable;
|
|
29573
|
+
return comparable;
|
|
29574
|
+
};
|
|
29575
|
+
const messagesShareStableIdentity = (parsed, reference) => {
|
|
29576
|
+
if (!parsed || !reference) return false;
|
|
29577
|
+
const parsedId = typeof parsed.id === "string" ? parsed.id.trim() : "";
|
|
29578
|
+
const referenceId = typeof reference.id === "string" ? reference.id.trim() : "";
|
|
29579
|
+
if (parsedId && referenceId && parsedId === referenceId) return true;
|
|
29580
|
+
return typeof parsed.index === "number" && Number.isFinite(parsed.index) && typeof reference.index === "number" && Number.isFinite(reference.index) && parsed.index === reference.index;
|
|
29581
|
+
};
|
|
29582
|
+
const exactReferenceKey = (role, comparable) => `${role}\0${comparable}`;
|
|
29583
|
+
const ensureExactReferenceIndex = () => {
|
|
29584
|
+
if (exactReferenceIndexesByKey) return exactReferenceIndexesByKey;
|
|
29585
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
29586
|
+
for (let i = 0; i < referenceMessages.length; i++) {
|
|
29587
|
+
const candidate = referenceMessages[i];
|
|
29588
|
+
if (!candidate || candidate.role !== "user" && candidate.role !== "assistant" || !hasFiniteTimestamp(candidate)) continue;
|
|
29589
|
+
const comparable = getReferenceComparable(i);
|
|
29590
|
+
if (!comparable) continue;
|
|
29591
|
+
const key = exactReferenceKey(candidate.role, comparable);
|
|
29592
|
+
const indexes = byKey.get(key);
|
|
29593
|
+
if (indexes) {
|
|
29594
|
+
indexes.push(i);
|
|
29595
|
+
} else {
|
|
29596
|
+
byKey.set(key, [i]);
|
|
29597
|
+
}
|
|
29598
|
+
}
|
|
29599
|
+
exactReferenceIndexesByKey = byKey;
|
|
29600
|
+
return byKey;
|
|
29601
|
+
};
|
|
29602
|
+
const takeExactReferenceTimestamp = (role, normalizedContent) => {
|
|
29603
|
+
const key = exactReferenceKey(role, normalizedContent);
|
|
29604
|
+
const indexes = ensureExactReferenceIndex().get(key);
|
|
29605
|
+
if (!indexes) return void 0;
|
|
29606
|
+
let cursor = exactReferenceCursorByKey.get(key) || 0;
|
|
29607
|
+
while (cursor < indexes.length) {
|
|
29608
|
+
const candidateIndex = indexes[cursor];
|
|
29609
|
+
cursor += 1;
|
|
29610
|
+
if (usedReferenceIndexes.has(candidateIndex)) continue;
|
|
29611
|
+
const candidate = referenceMessages[candidateIndex];
|
|
29612
|
+
if (!candidate || candidate.role !== role || !hasFiniteTimestamp(candidate)) continue;
|
|
29613
|
+
usedReferenceIndexes.add(candidateIndex);
|
|
29614
|
+
exactReferenceCursorByKey.set(key, cursor);
|
|
29615
|
+
return candidate.timestamp;
|
|
29616
|
+
}
|
|
29617
|
+
exactReferenceCursorByKey.set(key, cursor);
|
|
29618
|
+
return void 0;
|
|
29619
|
+
};
|
|
29620
|
+
const findReferenceTimestamp = (message, role, content, parsedIndex) => {
|
|
29621
|
+
const sameIndex = referenceMessages[parsedIndex];
|
|
29622
|
+
if (sameIndex && !usedReferenceIndexes.has(parsedIndex) && sameIndex.role === role && hasFiniteTimestamp(sameIndex) && messagesShareStableIdentity(message, sameIndex)) {
|
|
29623
|
+
usedReferenceIndexes.add(parsedIndex);
|
|
29624
|
+
return sameIndex.timestamp;
|
|
29625
|
+
}
|
|
29567
29626
|
const normalizedContent = normalizeComparableMessageContent(content);
|
|
29568
29627
|
if (!normalizedContent) return void 0;
|
|
29569
|
-
|
|
29570
|
-
if (sameIndex && !usedReferenceIndexes.has(parsedIndex) && sameIndex.role === role && referenceComparables[parsedIndex] === normalizedContent && typeof sameIndex.timestamp === "number" && Number.isFinite(sameIndex.timestamp)) {
|
|
29628
|
+
if (sameIndex && !usedReferenceIndexes.has(parsedIndex) && sameIndex.role === role && getReferenceComparable(parsedIndex) === normalizedContent && hasFiniteTimestamp(sameIndex)) {
|
|
29571
29629
|
usedReferenceIndexes.add(parsedIndex);
|
|
29572
29630
|
return sameIndex.timestamp;
|
|
29573
29631
|
}
|
|
29632
|
+
const exactTimestamp = takeExactReferenceTimestamp(role, normalizedContent);
|
|
29633
|
+
if (typeof exactTimestamp === "number") return exactTimestamp;
|
|
29574
29634
|
for (let i = 0; i < referenceMessages.length; i++) {
|
|
29575
29635
|
if (usedReferenceIndexes.has(i)) continue;
|
|
29576
29636
|
const candidate = referenceMessages[i];
|
|
29577
29637
|
if (!candidate || candidate.role !== role) continue;
|
|
29578
|
-
const candidateContent =
|
|
29638
|
+
const candidateContent = getReferenceComparable(i);
|
|
29579
29639
|
if (!candidateContent) continue;
|
|
29580
|
-
const exactMatch = candidateContent === normalizedContent;
|
|
29581
29640
|
const fuzzyMatch = candidateContent.includes(normalizedContent) || normalizedContent.includes(candidateContent);
|
|
29582
|
-
if (!
|
|
29583
|
-
if (
|
|
29641
|
+
if (!fuzzyMatch) continue;
|
|
29642
|
+
if (hasFiniteTimestamp(candidate)) {
|
|
29584
29643
|
usedReferenceIndexes.add(i);
|
|
29585
29644
|
return candidate.timestamp;
|
|
29586
29645
|
}
|
|
@@ -29591,7 +29650,7 @@ var require_dist2 = __commonJS({
|
|
|
29591
29650
|
const role = message.role;
|
|
29592
29651
|
const content = typeof message.content === "string" ? message.content : String(message.content || "");
|
|
29593
29652
|
const parsedTimestamp = typeof message.timestamp === "number" && Number.isFinite(message.timestamp) ? message.timestamp : void 0;
|
|
29594
|
-
const referenceTimestamp = parsedTimestamp ?? findReferenceTimestamp(role, content, index);
|
|
29653
|
+
const referenceTimestamp = parsedTimestamp ?? findReferenceTimestamp(message, role, content, index);
|
|
29595
29654
|
const fallbackTimestamp = role === "user" ? scope?.startedAt || now : lastOutputAt || scope?.startedAt || now;
|
|
29596
29655
|
const timestamp = referenceTimestamp ?? fallbackTimestamp;
|
|
29597
29656
|
return {
|
|
@@ -31208,11 +31267,12 @@ var require_dist2 = __commonJS({
|
|
|
31208
31267
|
};
|
|
31209
31268
|
}
|
|
31210
31269
|
// ─── Public API (CliAdapter) ───────────────────
|
|
31211
|
-
getStatus() {
|
|
31212
|
-
const
|
|
31270
|
+
getStatus(options = {}) {
|
|
31271
|
+
const allowParse = options.allowParse !== false;
|
|
31272
|
+
const startupModal = allowParse && this.startupParseGate ? this.runParseApproval(this.recentOutputBuffer) : null;
|
|
31213
31273
|
let effectiveStatus = this.projectEffectiveStatus(startupModal);
|
|
31214
31274
|
let effectiveModal = startupModal || this.activeModal;
|
|
31215
|
-
if (!startupModal && !effectiveModal && typeof this.cliScripts?.parseOutput === "function") {
|
|
31275
|
+
if (allowParse && !startupModal && !effectiveModal && typeof this.cliScripts?.parseOutput === "function") {
|
|
31216
31276
|
let parsed = this.getFreshParsedStatusCache();
|
|
31217
31277
|
if (!parsed && effectiveStatus !== "idle") {
|
|
31218
31278
|
const now = Date.now();
|
|
@@ -41312,7 +41372,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
41312
41372
|
return this.presentationMode;
|
|
41313
41373
|
}
|
|
41314
41374
|
getHotChatSessionState() {
|
|
41315
|
-
const adapterStatus = this.adapter.getStatus();
|
|
41375
|
+
const adapterStatus = this.adapter.getStatus({ allowParse: false });
|
|
41316
41376
|
const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
|
|
41317
41377
|
const visibleStatus = autoApproveActive ? "generating" : adapterStatus.status;
|
|
41318
41378
|
const runtime = this.adapter.getRuntimeMetadata();
|