@adhdev/daemon-standalone 0.9.35 → 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 +161 -35
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/{index-B8qTNoOd.js → index-GPf9-iir.js} +17 -17
- package/public/index.html +1 -1
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 {
|
|
@@ -30094,7 +30153,16 @@ var require_dist2 = __commonJS({
|
|
|
30094
30153
|
if (baseMessages.length <= _ProviderCliAdapter.PARSE_MESSAGE_TAIL_LIMIT) return baseMessages;
|
|
30095
30154
|
return baseMessages.slice(-_ProviderCliAdapter.PARSE_MESSAGE_TAIL_LIMIT);
|
|
30096
30155
|
}
|
|
30156
|
+
messagesShareStableIdentity(left, right) {
|
|
30157
|
+
if (left === right) return true;
|
|
30158
|
+
if (!left || !right) return false;
|
|
30159
|
+
if ((left.role || "") !== (right.role || "")) return false;
|
|
30160
|
+
if (left.id && right.id && String(left.id) === String(right.id)) return true;
|
|
30161
|
+
if (typeof left.index === "number" && typeof right.index === "number" && left.index === right.index) return true;
|
|
30162
|
+
return false;
|
|
30163
|
+
}
|
|
30097
30164
|
messagesComparable(left, right) {
|
|
30165
|
+
if (this.messagesShareStableIdentity(left, right)) return true;
|
|
30098
30166
|
if (!left || !right) return false;
|
|
30099
30167
|
if ((left.role || "") !== (right.role || "")) return false;
|
|
30100
30168
|
const leftText = normalizeComparableTranscriptText(left.content);
|
|
@@ -31199,11 +31267,12 @@ var require_dist2 = __commonJS({
|
|
|
31199
31267
|
};
|
|
31200
31268
|
}
|
|
31201
31269
|
// ─── Public API (CliAdapter) ───────────────────
|
|
31202
|
-
getStatus() {
|
|
31203
|
-
const
|
|
31270
|
+
getStatus(options = {}) {
|
|
31271
|
+
const allowParse = options.allowParse !== false;
|
|
31272
|
+
const startupModal = allowParse && this.startupParseGate ? this.runParseApproval(this.recentOutputBuffer) : null;
|
|
31204
31273
|
let effectiveStatus = this.projectEffectiveStatus(startupModal);
|
|
31205
31274
|
let effectiveModal = startupModal || this.activeModal;
|
|
31206
|
-
if (!startupModal && !effectiveModal && typeof this.cliScripts?.parseOutput === "function") {
|
|
31275
|
+
if (allowParse && !startupModal && !effectiveModal && typeof this.cliScripts?.parseOutput === "function") {
|
|
31207
31276
|
let parsed = this.getFreshParsedStatusCache();
|
|
31208
31277
|
if (!parsed && effectiveStatus !== "idle") {
|
|
31209
31278
|
const now = Date.now();
|
|
@@ -31245,6 +31314,69 @@ var require_dist2 = __commonJS({
|
|
|
31245
31314
|
this.committedMessages = normalized;
|
|
31246
31315
|
this.syncMessageViews();
|
|
31247
31316
|
}
|
|
31317
|
+
getSharedCommittedPrefixLength(parsedMessages) {
|
|
31318
|
+
const committedMessages = this.committedMessages;
|
|
31319
|
+
const max = Math.min(parsedMessages.length, committedMessages.length);
|
|
31320
|
+
let index = 0;
|
|
31321
|
+
while (index < max && this.messagesShareStableIdentity(parsedMessages[index], committedMessages[index])) {
|
|
31322
|
+
index += 1;
|
|
31323
|
+
}
|
|
31324
|
+
return index;
|
|
31325
|
+
}
|
|
31326
|
+
hydrateCommittedPrefixForParsedStatus(parsedMessages) {
|
|
31327
|
+
const sharedPrefixLength = this.getSharedCommittedPrefixLength(parsedMessages);
|
|
31328
|
+
if (sharedPrefixLength !== this.committedMessages.length) return null;
|
|
31329
|
+
const committedHydratedMessages = this.committedMessages.map((message, index) => {
|
|
31330
|
+
const timestamp = typeof message.timestamp === "number" && Number.isFinite(message.timestamp) ? message.timestamp : this.lastOutputAt || this.currentTurnScope?.startedAt || Date.now();
|
|
31331
|
+
const contentValue = message.content;
|
|
31332
|
+
return {
|
|
31333
|
+
role: message.role,
|
|
31334
|
+
content: typeof contentValue === "string" ? contentValue : String(contentValue || ""),
|
|
31335
|
+
timestamp,
|
|
31336
|
+
receivedAt: typeof message.receivedAt === "number" && Number.isFinite(message.receivedAt) ? message.receivedAt : timestamp,
|
|
31337
|
+
kind: message.kind,
|
|
31338
|
+
id: message.id || `msg_${index}`,
|
|
31339
|
+
index: typeof message.index === "number" ? message.index : index,
|
|
31340
|
+
meta: message.meta,
|
|
31341
|
+
senderName: message.senderName
|
|
31342
|
+
};
|
|
31343
|
+
});
|
|
31344
|
+
const extraMessages = parsedMessages.slice(sharedPrefixLength);
|
|
31345
|
+
if (extraMessages.length === 0) return committedHydratedMessages;
|
|
31346
|
+
const extraHydratedMessages = hydrateCliParsedMessages(extraMessages, {
|
|
31347
|
+
committedMessages: [],
|
|
31348
|
+
scope: this.currentTurnScope,
|
|
31349
|
+
lastOutputAt: this.lastOutputAt
|
|
31350
|
+
}).map((message, offset) => ({
|
|
31351
|
+
...message,
|
|
31352
|
+
id: message.id || `msg_${sharedPrefixLength + offset}`,
|
|
31353
|
+
index: typeof message.index === "number" ? message.index : sharedPrefixLength + offset
|
|
31354
|
+
}));
|
|
31355
|
+
return [...committedHydratedMessages, ...extraHydratedMessages];
|
|
31356
|
+
}
|
|
31357
|
+
hydrateParsedMessagesForStatus(parsedMessages) {
|
|
31358
|
+
return this.hydrateCommittedPrefixForParsedStatus(parsedMessages) || hydrateCliParsedMessages(parsedMessages, {
|
|
31359
|
+
committedMessages: this.committedMessages,
|
|
31360
|
+
scope: this.currentTurnScope,
|
|
31361
|
+
lastOutputAt: this.lastOutputAt
|
|
31362
|
+
});
|
|
31363
|
+
}
|
|
31364
|
+
buildCommittedChatMessages() {
|
|
31365
|
+
return this.committedMessages.map((message, index) => {
|
|
31366
|
+
const contentValue = message.content;
|
|
31367
|
+
return buildChatMessage({
|
|
31368
|
+
role: message.role,
|
|
31369
|
+
content: typeof contentValue === "string" ? contentValue : String(contentValue || ""),
|
|
31370
|
+
timestamp: message.timestamp,
|
|
31371
|
+
kind: message.kind,
|
|
31372
|
+
meta: message.meta,
|
|
31373
|
+
senderName: message.senderName,
|
|
31374
|
+
id: message.id || `msg_${index}`,
|
|
31375
|
+
index: typeof message.index === "number" ? message.index : index,
|
|
31376
|
+
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
31377
|
+
});
|
|
31378
|
+
});
|
|
31379
|
+
}
|
|
31248
31380
|
/**
|
|
31249
31381
|
* Script-based full parse — returns ReadChatResult.
|
|
31250
31382
|
* Called by command handler / dashboard for rich content rendering.
|
|
@@ -31270,7 +31402,7 @@ var require_dist2 = __commonJS({
|
|
|
31270
31402
|
this.onStatusChange?.();
|
|
31271
31403
|
}
|
|
31272
31404
|
}
|
|
31273
|
-
if (parsed && Array.isArray(parsed.messages)) {
|
|
31405
|
+
if (parsed && Array.isArray(parsed.messages) && this.provider.allowInputDuringGeneration === true) {
|
|
31274
31406
|
const hydratedForCommit = normalizeCliParsedMessages(parsed.messages, {
|
|
31275
31407
|
committedMessages: this.committedMessages,
|
|
31276
31408
|
scope: this.currentTurnScope,
|
|
@@ -31289,21 +31421,21 @@ var require_dist2 = __commonJS({
|
|
|
31289
31421
|
const shouldPreferCommittedMessages = !this.currentTurnScope && !this.activeModal && this.currentStatus === "idle";
|
|
31290
31422
|
let result;
|
|
31291
31423
|
if (parsed && Array.isArray(parsed.messages)) {
|
|
31292
|
-
const parsedHydratedMessages =
|
|
31293
|
-
committedMessages: this.committedMessages,
|
|
31294
|
-
scope: this.currentTurnScope,
|
|
31295
|
-
lastOutputAt: this.lastOutputAt
|
|
31296
|
-
});
|
|
31297
|
-
const committedHydratedMessages = this.committedMessages.map((message, index) => buildChatMessage({
|
|
31298
|
-
...message,
|
|
31299
|
-
id: message.id || `msg_${index}`,
|
|
31300
|
-
index: typeof message.index === "number" ? message.index : index,
|
|
31301
|
-
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
31302
|
-
}));
|
|
31424
|
+
const parsedHydratedMessages = this.hydrateParsedMessagesForStatus(parsed.messages);
|
|
31303
31425
|
const parsedLastAssistant = [...parsedHydratedMessages].reverse().find((message) => message.role === "assistant" && typeof message.content === "string" && message.content.trim());
|
|
31304
|
-
const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && !!parsedLastAssistant && parsedTranscriptIsRicherThanCommitted(parsedHydratedMessages,
|
|
31426
|
+
const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && !!parsedLastAssistant && parsedTranscriptIsRicherThanCommitted(parsedHydratedMessages, this.committedMessages) && (this.currentStatus === "idle" || this.currentStatus === "generating" && this.isWaitingForResponse && parsed.status === "idle" && this.runDetectStatus(this.recentOutputBuffer) === "idle");
|
|
31305
31427
|
if (shouldAdoptParsedIdleReplay) {
|
|
31306
|
-
this.committedMessages =
|
|
31428
|
+
this.committedMessages = this.getSharedCommittedPrefixLength(parsed.messages) === this.committedMessages.length ? parsedHydratedMessages.map((message) => ({
|
|
31429
|
+
role: message.role,
|
|
31430
|
+
content: typeof message.content === "string" ? message.content : String(message.content || ""),
|
|
31431
|
+
timestamp: message.timestamp,
|
|
31432
|
+
receivedAt: message.receivedAt,
|
|
31433
|
+
kind: message.kind,
|
|
31434
|
+
id: message.id,
|
|
31435
|
+
index: message.index,
|
|
31436
|
+
meta: message.meta,
|
|
31437
|
+
senderName: message.senderName
|
|
31438
|
+
})) : normalizeCliParsedMessages(parsed.messages, {
|
|
31307
31439
|
committedMessages: this.committedMessages,
|
|
31308
31440
|
scope: this.currentTurnScope,
|
|
31309
31441
|
lastOutputAt: this.lastOutputAt
|
|
@@ -31322,15 +31454,9 @@ var require_dist2 = __commonJS({
|
|
|
31322
31454
|
this.onStatusChange?.();
|
|
31323
31455
|
}
|
|
31324
31456
|
}
|
|
31325
|
-
const
|
|
31326
|
-
...message,
|
|
31327
|
-
id: message.id || `msg_${index}`,
|
|
31328
|
-
index: typeof message.index === "number" ? message.index : index,
|
|
31329
|
-
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
31330
|
-
})) : committedHydratedMessages;
|
|
31331
|
-
const shouldPreferCommittedHistoryReplay = !this.currentTurnScope && !this.activeModal && effectiveCommittedHydratedMessages.length > parsedHydratedMessages.length;
|
|
31457
|
+
const shouldPreferCommittedHistoryReplay = !this.currentTurnScope && !this.activeModal && this.committedMessages.length > parsedHydratedMessages.length;
|
|
31332
31458
|
const shouldPreferCommittedIdleReplay = shouldPreferCommittedMessages && !shouldAdoptParsedIdleReplay;
|
|
31333
|
-
const hydratedMessages = shouldPreferCommittedIdleReplay || shouldPreferCommittedHistoryReplay ?
|
|
31459
|
+
const hydratedMessages = shouldPreferCommittedIdleReplay || shouldPreferCommittedHistoryReplay ? this.buildCommittedChatMessages() : parsedHydratedMessages;
|
|
31334
31460
|
result = {
|
|
31335
31461
|
id: parsed.id || "cli_session",
|
|
31336
31462
|
status: parsed.status || this.currentStatus,
|
|
@@ -41246,7 +41372,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
41246
41372
|
return this.presentationMode;
|
|
41247
41373
|
}
|
|
41248
41374
|
getHotChatSessionState() {
|
|
41249
|
-
const adapterStatus = this.adapter.getStatus();
|
|
41375
|
+
const adapterStatus = this.adapter.getStatus({ allowParse: false });
|
|
41250
41376
|
const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
|
|
41251
41377
|
const visibleStatus = autoApproveActive ? "generating" : adapterStatus.status;
|
|
41252
41378
|
const runtime = this.adapter.getRuntimeMetadata();
|