@adhdev/daemon-core 0.9.38 → 0.9.40
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/commands/chat-commands.d.ts +2 -0
- package/dist/index.js +83 -67
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -67
- package/dist/index.mjs.map +1 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +11 -0
- package/src/cli-adapters/provider-cli-parse.ts +25 -15
- package/src/commands/chat-commands.ts +65 -56
- package/src/providers/cli-provider-instance.ts +6 -3
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* setMode, changeModel, setThoughtLevel, resolveAction, chatHistory
|
|
4
4
|
*/
|
|
5
5
|
import type { CommandResult, CommandHelpers } from './handler.js';
|
|
6
|
+
import type { ChatMessage } from '../types.js';
|
|
6
7
|
export declare const READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25000;
|
|
8
|
+
export declare function collapseReplayDuplicatesFromReadChat(messages: ChatMessage[]): ChatMessage[];
|
|
7
9
|
export declare function handleChatHistory(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
8
10
|
export declare function handleReadChat(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
9
11
|
export declare function handleSendChat(h: CommandHelpers, args: any): Promise<CommandResult>;
|
package/dist/index.js
CHANGED
|
@@ -1792,9 +1792,7 @@ function hydrateCliParsedMessages(parsedMessages, options) {
|
|
|
1792
1792
|
};
|
|
1793
1793
|
});
|
|
1794
1794
|
}
|
|
1795
|
-
function chooseMoreComparableCliMessage(left, right) {
|
|
1796
|
-
const leftComparable = normalizeComparableMessageContent(left.content || "");
|
|
1797
|
-
const rightComparable = normalizeComparableMessageContent(right.content || "");
|
|
1795
|
+
function chooseMoreComparableCliMessage(left, right, leftComparable = normalizeComparableMessageContent(left.content || ""), rightComparable = normalizeComparableMessageContent(right.content || "")) {
|
|
1798
1796
|
if (leftComparable && leftComparable === rightComparable) {
|
|
1799
1797
|
const leftNewlines = String(left.content || "").split(/\r\n|\n|\r/g).length - 1;
|
|
1800
1798
|
const rightNewlines = String(right.content || "").split(/\r\n|\n|\r/g).length - 1;
|
|
@@ -1809,24 +1807,32 @@ function dedupeConsecutiveComparableCliMessages(messages) {
|
|
|
1809
1807
|
...message,
|
|
1810
1808
|
content: typeof message.content === "string" ? message.content : String(message.content || "")
|
|
1811
1809
|
};
|
|
1810
|
+
const currentComparable = normalizeComparableMessageContent(current.content || "");
|
|
1812
1811
|
const previous = deduped[deduped.length - 1];
|
|
1813
1812
|
if (!previous) {
|
|
1814
|
-
deduped.push(current);
|
|
1813
|
+
deduped.push({ message: current, comparable: currentComparable });
|
|
1815
1814
|
continue;
|
|
1816
1815
|
}
|
|
1817
|
-
const
|
|
1818
|
-
const
|
|
1819
|
-
const
|
|
1820
|
-
const
|
|
1821
|
-
const sameSender = (previous.senderName || "") === (current.senderName || "");
|
|
1822
|
-
const comparableMatch = previousComparable && previousComparable === currentComparable;
|
|
1816
|
+
const sameRole = previous.message.role === current.role;
|
|
1817
|
+
const sameKind = (previous.message.kind || "standard") === (current.kind || "standard");
|
|
1818
|
+
const sameSender = (previous.message.senderName || "") === (current.senderName || "");
|
|
1819
|
+
const comparableMatch = previous.comparable && previous.comparable === currentComparable;
|
|
1823
1820
|
if (sameRole && sameKind && sameSender && comparableMatch) {
|
|
1824
|
-
|
|
1821
|
+
const selected = chooseMoreComparableCliMessage(
|
|
1822
|
+
previous.message,
|
|
1823
|
+
current,
|
|
1824
|
+
previous.comparable,
|
|
1825
|
+
currentComparable
|
|
1826
|
+
);
|
|
1827
|
+
deduped[deduped.length - 1] = {
|
|
1828
|
+
message: selected,
|
|
1829
|
+
comparable: selected === current ? currentComparable : previous.comparable
|
|
1830
|
+
};
|
|
1825
1831
|
continue;
|
|
1826
1832
|
}
|
|
1827
|
-
deduped.push(current);
|
|
1833
|
+
deduped.push({ message: current, comparable: currentComparable });
|
|
1828
1834
|
}
|
|
1829
|
-
return deduped;
|
|
1835
|
+
return deduped.map((entry) => entry.message);
|
|
1830
1836
|
}
|
|
1831
1837
|
function normalizeCliParsedMessages(parsedMessages, options) {
|
|
1832
1838
|
return dedupeConsecutiveComparableCliMessages(hydrateCliParsedMessages(parsedMessages, options).map((message) => ({
|
|
@@ -2851,6 +2857,14 @@ var init_provider_cli_adapter = __esm({
|
|
|
2851
2857
|
}
|
|
2852
2858
|
this.resolveStartupState("settled");
|
|
2853
2859
|
if (this.startupParseGate) return;
|
|
2860
|
+
if (!this.isWaitingForResponse && !this.currentTurnScope && !this.activeModal && !this.parseErrorMessage) {
|
|
2861
|
+
const tail = this.settledBuffer || this.recentOutputBuffer;
|
|
2862
|
+
const modal2 = this.runParseApproval(tail);
|
|
2863
|
+
const lightweightStatus = this.cliScripts?.detectStatus ? this.runDetectStatus(tail) : null;
|
|
2864
|
+
if (!modal2 && lightweightStatus === "idle" && this.currentStatus === "idle") {
|
|
2865
|
+
return;
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2854
2868
|
const session = this.runParseSession();
|
|
2855
2869
|
if (!session) return;
|
|
2856
2870
|
const { status, messages, modal, parsedStatus } = session;
|
|
@@ -10615,68 +10629,66 @@ function normalizeReadChatMessages(payload) {
|
|
|
10615
10629
|
const messages = Array.isArray(payload.messages) ? payload.messages : [];
|
|
10616
10630
|
return normalizeChatMessages(messages);
|
|
10617
10631
|
}
|
|
10618
|
-
function
|
|
10619
|
-
|
|
10632
|
+
function normalizeReadChatReplayTextContent(content) {
|
|
10633
|
+
return flattenContent(content || "").replace(/\s+/g, " ").trim();
|
|
10634
|
+
}
|
|
10635
|
+
function getReadChatReplayCollapseInfo(message) {
|
|
10636
|
+
if (!message) return null;
|
|
10620
10637
|
const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
10621
10638
|
const kind = typeof message.kind === "string" ? message.kind.trim().toLowerCase() : "standard";
|
|
10622
10639
|
const senderName = typeof message.senderName === "string" ? message.senderName.trim().toLowerCase() : "";
|
|
10623
|
-
const
|
|
10624
|
-
return
|
|
10625
|
-
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
|
|
10640
|
+
const collapsible = role === "assistant" || role === "system";
|
|
10641
|
+
if (!collapsible) return { role, kind, senderName, content: "", signature: "", collapsible };
|
|
10642
|
+
const content = normalizeReadChatReplayTextContent(message.content);
|
|
10643
|
+
return {
|
|
10644
|
+
role,
|
|
10645
|
+
kind,
|
|
10646
|
+
senderName,
|
|
10647
|
+
content,
|
|
10648
|
+
signature: `${role}:${kind}:${senderName}:${content}`,
|
|
10649
|
+
collapsible
|
|
10650
|
+
};
|
|
10633
10651
|
}
|
|
10634
|
-
function
|
|
10635
|
-
if (!
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
if (
|
|
10639
|
-
if (
|
|
10640
|
-
const content = normalizeReadChatReplayText(message);
|
|
10641
|
-
if (content.length < 160) return false;
|
|
10642
|
-
if (/^(bash|shell|terminal) command\b/i.test(content)) return false;
|
|
10652
|
+
function isStableReadChatAssistantAnswerInfo(info) {
|
|
10653
|
+
if (!info) return false;
|
|
10654
|
+
if (info.role !== "assistant") return false;
|
|
10655
|
+
if (info.kind && info.kind !== "standard") return false;
|
|
10656
|
+
if (info.content.length < 160) return false;
|
|
10657
|
+
if (/^(bash|shell|terminal) command\b/i.test(info.content)) return false;
|
|
10643
10658
|
return true;
|
|
10644
10659
|
}
|
|
10645
|
-
function
|
|
10646
|
-
if (!
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
if (kind && kind !== "standard") return false;
|
|
10651
|
-
const content = normalizeReadChatReplayText(message);
|
|
10652
|
-
const stableContent = normalizeReadChatReplayText(stableAnswer);
|
|
10660
|
+
function isReplayedAssistantAnswerAfterStableAnswerInfo(info, stableContent) {
|
|
10661
|
+
if (!info || !stableContent) return false;
|
|
10662
|
+
if (info.role !== "assistant") return false;
|
|
10663
|
+
if (info.kind && info.kind !== "standard") return false;
|
|
10664
|
+
const content = info.content;
|
|
10653
10665
|
if (content.length < 80 || stableContent.length < 80) return false;
|
|
10654
10666
|
return content === stableContent || content.startsWith(stableContent) || stableContent.startsWith(content);
|
|
10655
10667
|
}
|
|
10656
10668
|
function collapseReplayDuplicatesFromReadChat(messages) {
|
|
10657
10669
|
const collapsed = [];
|
|
10658
10670
|
const replaySignaturesInCurrentTurn = /* @__PURE__ */ new Set();
|
|
10659
|
-
let
|
|
10671
|
+
let stableAssistantAnswerContentInCurrentTurn = "";
|
|
10672
|
+
let previousReplaySignature = "";
|
|
10660
10673
|
for (const message of messages) {
|
|
10661
|
-
const
|
|
10662
|
-
if (role === "user") {
|
|
10674
|
+
const info = getReadChatReplayCollapseInfo(message);
|
|
10675
|
+
if (info?.role === "user") {
|
|
10663
10676
|
replaySignaturesInCurrentTurn.clear();
|
|
10664
|
-
|
|
10677
|
+
stableAssistantAnswerContentInCurrentTurn = "";
|
|
10678
|
+
previousReplaySignature = "";
|
|
10665
10679
|
}
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
|
|
10669
|
-
|
|
10670
|
-
if (previousSignature === signature) continue;
|
|
10671
|
-
if (replaySignaturesInCurrentTurn.has(signature)) continue;
|
|
10672
|
-
if (isReplayedAssistantAnswerAfterStableAnswer(message, stableAssistantAnswerInCurrentTurn)) continue;
|
|
10680
|
+
if (info?.collapsible && info.signature) {
|
|
10681
|
+
if (previousReplaySignature === info.signature) continue;
|
|
10682
|
+
if (replaySignaturesInCurrentTurn.has(info.signature)) continue;
|
|
10683
|
+
if (isReplayedAssistantAnswerAfterStableAnswerInfo(info, stableAssistantAnswerContentInCurrentTurn)) continue;
|
|
10673
10684
|
}
|
|
10674
10685
|
collapsed.push(message);
|
|
10675
|
-
|
|
10676
|
-
|
|
10686
|
+
previousReplaySignature = info?.collapsible ? info.signature : "";
|
|
10687
|
+
if (info?.collapsible && info.signature) {
|
|
10688
|
+
replaySignaturesInCurrentTurn.add(info.signature);
|
|
10677
10689
|
}
|
|
10678
|
-
if (
|
|
10679
|
-
|
|
10690
|
+
if (isStableReadChatAssistantAnswerInfo(info)) {
|
|
10691
|
+
stableAssistantAnswerContentInCurrentTurn = info?.content || "";
|
|
10680
10692
|
}
|
|
10681
10693
|
}
|
|
10682
10694
|
return collapsed;
|
|
@@ -10756,13 +10768,17 @@ function computeReadChatSync(messages, cursor) {
|
|
|
10756
10768
|
};
|
|
10757
10769
|
}
|
|
10758
10770
|
if (cursor.tailLimit > 0 && knownSignature === lastMessageSignature) {
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
|
-
|
|
10771
|
+
const requestedTailCount = Math.min(totalMessages, cursor.tailLimit);
|
|
10772
|
+
if (knownMessageCount >= requestedTailCount) {
|
|
10773
|
+
return {
|
|
10774
|
+
syncMode: "noop",
|
|
10775
|
+
replaceFrom: totalMessages,
|
|
10776
|
+
messages: [],
|
|
10777
|
+
totalMessages,
|
|
10778
|
+
lastMessageSignature
|
|
10779
|
+
};
|
|
10780
|
+
}
|
|
10781
|
+
return buildBoundedTailSync(messages, cursor);
|
|
10766
10782
|
}
|
|
10767
10783
|
if (knownMessageCount < totalMessages) {
|
|
10768
10784
|
const anchorSignature = getChatMessageSignature(messages[knownMessageCount - 1]);
|
|
@@ -13696,8 +13712,8 @@ var CliProviderInstance = class {
|
|
|
13696
13712
|
}
|
|
13697
13713
|
detectStatusTransition() {
|
|
13698
13714
|
const now = Date.now();
|
|
13699
|
-
const adapterStatus = this.adapter.getStatus();
|
|
13700
|
-
const parsedStatus =
|
|
13715
|
+
const adapterStatus = this.adapter.getStatus({ allowParse: false });
|
|
13716
|
+
const parsedStatus = null;
|
|
13701
13717
|
const rawStatus = adapterStatus.status;
|
|
13702
13718
|
const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
|
|
13703
13719
|
if (autoApproveActive && !this.autoApproveBusy) {
|
|
@@ -13790,7 +13806,7 @@ var CliProviderInstance = class {
|
|
|
13790
13806
|
this.completedDebouncePending = { chatTitle, duration, timestamp: now };
|
|
13791
13807
|
this.completedDebounceTimer = setTimeout(() => {
|
|
13792
13808
|
if (this.completedDebouncePending) {
|
|
13793
|
-
const latestStatus = this.adapter.getStatus();
|
|
13809
|
+
const latestStatus = this.adapter.getStatus({ allowParse: false });
|
|
13794
13810
|
const latestAutoApproveActive = latestStatus.status === "waiting_approval" && this.shouldAutoApprove();
|
|
13795
13811
|
const latestVisibleStatus = latestAutoApproveActive ? "generating" : latestStatus.status;
|
|
13796
13812
|
if (latestVisibleStatus !== "idle") {
|