@adhdev/daemon-core 0.9.39 → 0.9.41
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 +147 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +147 -68
- package/dist/index.mjs.map +1 -1
- package/dist/providers/acp-provider-instance.d.ts +2 -1
- package/dist/providers/cli-provider-instance.d.ts +2 -1
- package/dist/providers/extension-provider-instance.d.ts +2 -1
- package/dist/providers/ide-provider-instance.d.ts +2 -1
- package/dist/providers/provider-instance-manager.d.ts +4 -1
- package/dist/providers/provider-instance.d.ts +11 -0
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +0 -8
- package/src/cli-adapters/provider-cli-parse.ts +25 -15
- package/src/commands/chat-commands.ts +65 -56
- package/src/providers/acp-provider-instance.ts +14 -1
- package/src/providers/cli-provider-instance.ts +14 -1
- package/src/providers/extension-provider-instance.ts +11 -1
- package/src/providers/ide-provider-instance.ts +25 -1
- package/src/providers/provider-instance-manager.ts +27 -1
- package/src/providers/provider-instance.ts +13 -0
|
@@ -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) => ({
|
|
@@ -2277,7 +2283,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
2277
2283
|
}
|
|
2278
2284
|
getFreshParsedStatusCache() {
|
|
2279
2285
|
const cached = this.parsedStatusCache;
|
|
2280
|
-
if (cached && cached.committedMessagesRef === this.committedMessages && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.
|
|
2286
|
+
if (cached && cached.committedMessagesRef === this.committedMessages && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.screenText === this.lastScreenText && cached.currentStatus === this.currentStatus && cached.activeModal === this.activeModal && cached.cliName === this.cliName) {
|
|
2281
2287
|
return cached.result;
|
|
2282
2288
|
}
|
|
2283
2289
|
return null;
|
|
@@ -3525,7 +3531,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
3525
3531
|
getScriptParsedStatus() {
|
|
3526
3532
|
const screenText = this.readTerminalScreenText();
|
|
3527
3533
|
const cached = this.parsedStatusCache;
|
|
3528
|
-
if (cached && cached.committedMessagesRef === this.committedMessages && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.
|
|
3534
|
+
if (cached && cached.committedMessagesRef === this.committedMessages && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.screenText === screenText && cached.currentStatus === this.currentStatus && cached.activeModal === this.activeModal && cached.cliName === this.cliName) {
|
|
3529
3535
|
return cached.result;
|
|
3530
3536
|
}
|
|
3531
3537
|
const parsed = this.parseCurrentTranscript(
|
|
@@ -3644,12 +3650,10 @@ var init_provider_cli_adapter = __esm({
|
|
|
3644
3650
|
currentTurnScope: this.currentTurnScope,
|
|
3645
3651
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
3646
3652
|
accumulatedBuffer: this.accumulatedBuffer,
|
|
3647
|
-
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
3648
3653
|
screenText,
|
|
3649
3654
|
currentStatus: this.currentStatus,
|
|
3650
3655
|
activeModal: this.activeModal,
|
|
3651
3656
|
cliName: this.cliName,
|
|
3652
|
-
lastOutputAt: this.lastOutputAt,
|
|
3653
3657
|
result
|
|
3654
3658
|
};
|
|
3655
3659
|
return result;
|
|
@@ -8515,6 +8519,15 @@ var ExtensionProviderInstance = class {
|
|
|
8515
8519
|
pendingEvents: this.flushEvents()
|
|
8516
8520
|
};
|
|
8517
8521
|
}
|
|
8522
|
+
getSessionModalState(sessionId) {
|
|
8523
|
+
if (sessionId && sessionId !== this.instanceId) return null;
|
|
8524
|
+
return {
|
|
8525
|
+
id: this.instanceId,
|
|
8526
|
+
status: this.currentStatus,
|
|
8527
|
+
title: this.chatTitle || this.agentName || this.provider.name,
|
|
8528
|
+
activeModal: this.activeModal
|
|
8529
|
+
};
|
|
8530
|
+
}
|
|
8518
8531
|
onEvent(event, data) {
|
|
8519
8532
|
if (event === "stream_update") {
|
|
8520
8533
|
if (data?.streams) this.agentStreams = data.streams;
|
|
@@ -8981,6 +8994,23 @@ var IdeProviderInstance = class {
|
|
|
8981
8994
|
pendingEvents: this.flushEvents()
|
|
8982
8995
|
};
|
|
8983
8996
|
}
|
|
8997
|
+
getSessionModalState(sessionId) {
|
|
8998
|
+
if (sessionId && sessionId !== this.instanceId) {
|
|
8999
|
+
for (const ext of this.extensions.values()) {
|
|
9000
|
+
const projected = ext.getSessionModalState?.(sessionId);
|
|
9001
|
+
if (projected?.id === sessionId) return projected;
|
|
9002
|
+
}
|
|
9003
|
+
return null;
|
|
9004
|
+
}
|
|
9005
|
+
const autoApproveActive = (this.currentStatus === "waiting_approval" || this.cachedChat?.status === "waiting_approval") && this.canAutoApprove();
|
|
9006
|
+
const visibleStatus = autoApproveActive ? "generating" : this.currentStatus;
|
|
9007
|
+
return {
|
|
9008
|
+
id: this.instanceId,
|
|
9009
|
+
status: autoApproveActive && this.cachedChat?.status === "waiting_approval" ? "generating" : this.cachedChat?.status || visibleStatus,
|
|
9010
|
+
title: this.cachedChat?.title || this.type,
|
|
9011
|
+
activeModal: autoApproveActive ? null : this.cachedChat?.activeModal || null
|
|
9012
|
+
};
|
|
9013
|
+
}
|
|
8984
9014
|
onEvent(event, data) {
|
|
8985
9015
|
if (event === "cdp_connected") {
|
|
8986
9016
|
} else if (event === "cdp_disconnected") {
|
|
@@ -10623,68 +10653,66 @@ function normalizeReadChatMessages(payload) {
|
|
|
10623
10653
|
const messages = Array.isArray(payload.messages) ? payload.messages : [];
|
|
10624
10654
|
return normalizeChatMessages(messages);
|
|
10625
10655
|
}
|
|
10626
|
-
function
|
|
10627
|
-
|
|
10656
|
+
function normalizeReadChatReplayTextContent(content) {
|
|
10657
|
+
return flattenContent(content || "").replace(/\s+/g, " ").trim();
|
|
10658
|
+
}
|
|
10659
|
+
function getReadChatReplayCollapseInfo(message) {
|
|
10660
|
+
if (!message) return null;
|
|
10628
10661
|
const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
10629
10662
|
const kind = typeof message.kind === "string" ? message.kind.trim().toLowerCase() : "standard";
|
|
10630
10663
|
const senderName = typeof message.senderName === "string" ? message.senderName.trim().toLowerCase() : "";
|
|
10631
|
-
const
|
|
10632
|
-
return
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
|
|
10639
|
-
|
|
10640
|
-
|
|
10664
|
+
const collapsible = role === "assistant" || role === "system";
|
|
10665
|
+
if (!collapsible) return { role, kind, senderName, content: "", signature: "", collapsible };
|
|
10666
|
+
const content = normalizeReadChatReplayTextContent(message.content);
|
|
10667
|
+
return {
|
|
10668
|
+
role,
|
|
10669
|
+
kind,
|
|
10670
|
+
senderName,
|
|
10671
|
+
content,
|
|
10672
|
+
signature: `${role}:${kind}:${senderName}:${content}`,
|
|
10673
|
+
collapsible
|
|
10674
|
+
};
|
|
10641
10675
|
}
|
|
10642
|
-
function
|
|
10643
|
-
if (!
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
if (
|
|
10647
|
-
if (
|
|
10648
|
-
const content = normalizeReadChatReplayText(message);
|
|
10649
|
-
if (content.length < 160) return false;
|
|
10650
|
-
if (/^(bash|shell|terminal) command\b/i.test(content)) return false;
|
|
10676
|
+
function isStableReadChatAssistantAnswerInfo(info) {
|
|
10677
|
+
if (!info) return false;
|
|
10678
|
+
if (info.role !== "assistant") return false;
|
|
10679
|
+
if (info.kind && info.kind !== "standard") return false;
|
|
10680
|
+
if (info.content.length < 160) return false;
|
|
10681
|
+
if (/^(bash|shell|terminal) command\b/i.test(info.content)) return false;
|
|
10651
10682
|
return true;
|
|
10652
10683
|
}
|
|
10653
|
-
function
|
|
10654
|
-
if (!
|
|
10655
|
-
|
|
10656
|
-
|
|
10657
|
-
|
|
10658
|
-
if (kind && kind !== "standard") return false;
|
|
10659
|
-
const content = normalizeReadChatReplayText(message);
|
|
10660
|
-
const stableContent = normalizeReadChatReplayText(stableAnswer);
|
|
10684
|
+
function isReplayedAssistantAnswerAfterStableAnswerInfo(info, stableContent) {
|
|
10685
|
+
if (!info || !stableContent) return false;
|
|
10686
|
+
if (info.role !== "assistant") return false;
|
|
10687
|
+
if (info.kind && info.kind !== "standard") return false;
|
|
10688
|
+
const content = info.content;
|
|
10661
10689
|
if (content.length < 80 || stableContent.length < 80) return false;
|
|
10662
10690
|
return content === stableContent || content.startsWith(stableContent) || stableContent.startsWith(content);
|
|
10663
10691
|
}
|
|
10664
10692
|
function collapseReplayDuplicatesFromReadChat(messages) {
|
|
10665
10693
|
const collapsed = [];
|
|
10666
10694
|
const replaySignaturesInCurrentTurn = /* @__PURE__ */ new Set();
|
|
10667
|
-
let
|
|
10695
|
+
let stableAssistantAnswerContentInCurrentTurn = "";
|
|
10696
|
+
let previousReplaySignature = "";
|
|
10668
10697
|
for (const message of messages) {
|
|
10669
|
-
const
|
|
10670
|
-
if (role === "user") {
|
|
10698
|
+
const info = getReadChatReplayCollapseInfo(message);
|
|
10699
|
+
if (info?.role === "user") {
|
|
10671
10700
|
replaySignaturesInCurrentTurn.clear();
|
|
10672
|
-
|
|
10701
|
+
stableAssistantAnswerContentInCurrentTurn = "";
|
|
10702
|
+
previousReplaySignature = "";
|
|
10673
10703
|
}
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
if (previousSignature === signature) continue;
|
|
10679
|
-
if (replaySignaturesInCurrentTurn.has(signature)) continue;
|
|
10680
|
-
if (isReplayedAssistantAnswerAfterStableAnswer(message, stableAssistantAnswerInCurrentTurn)) continue;
|
|
10704
|
+
if (info?.collapsible && info.signature) {
|
|
10705
|
+
if (previousReplaySignature === info.signature) continue;
|
|
10706
|
+
if (replaySignaturesInCurrentTurn.has(info.signature)) continue;
|
|
10707
|
+
if (isReplayedAssistantAnswerAfterStableAnswerInfo(info, stableAssistantAnswerContentInCurrentTurn)) continue;
|
|
10681
10708
|
}
|
|
10682
10709
|
collapsed.push(message);
|
|
10683
|
-
|
|
10684
|
-
|
|
10710
|
+
previousReplaySignature = info?.collapsible ? info.signature : "";
|
|
10711
|
+
if (info?.collapsible && info.signature) {
|
|
10712
|
+
replaySignaturesInCurrentTurn.add(info.signature);
|
|
10685
10713
|
}
|
|
10686
|
-
if (
|
|
10687
|
-
|
|
10714
|
+
if (isStableReadChatAssistantAnswerInfo(info)) {
|
|
10715
|
+
stableAssistantAnswerContentInCurrentTurn = info?.content || "";
|
|
10688
10716
|
}
|
|
10689
10717
|
}
|
|
10690
10718
|
return collapsed;
|
|
@@ -10764,13 +10792,17 @@ function computeReadChatSync(messages, cursor) {
|
|
|
10764
10792
|
};
|
|
10765
10793
|
}
|
|
10766
10794
|
if (cursor.tailLimit > 0 && knownSignature === lastMessageSignature) {
|
|
10767
|
-
|
|
10768
|
-
|
|
10769
|
-
|
|
10770
|
-
|
|
10771
|
-
|
|
10772
|
-
|
|
10773
|
-
|
|
10795
|
+
const requestedTailCount = Math.min(totalMessages, cursor.tailLimit);
|
|
10796
|
+
if (knownMessageCount >= requestedTailCount) {
|
|
10797
|
+
return {
|
|
10798
|
+
syncMode: "noop",
|
|
10799
|
+
replaceFrom: totalMessages,
|
|
10800
|
+
messages: [],
|
|
10801
|
+
totalMessages,
|
|
10802
|
+
lastMessageSignature
|
|
10803
|
+
};
|
|
10804
|
+
}
|
|
10805
|
+
return buildBoundedTailSync(messages, cursor);
|
|
10774
10806
|
}
|
|
10775
10807
|
if (knownMessageCount < totalMessages) {
|
|
10776
10808
|
const anchorSignature = getChatMessageSignature(messages[knownMessageCount - 1]);
|
|
@@ -13643,6 +13675,18 @@ var CliProviderInstance = class {
|
|
|
13643
13675
|
runtimeRecoveryState: runtime?.recoveryState ?? null
|
|
13644
13676
|
};
|
|
13645
13677
|
}
|
|
13678
|
+
getSessionModalState() {
|
|
13679
|
+
const adapterStatus = this.adapter.getStatus({ allowParse: false });
|
|
13680
|
+
const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
|
|
13681
|
+
const visibleStatus = autoApproveActive ? "generating" : adapterStatus.status;
|
|
13682
|
+
const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
|
|
13683
|
+
return {
|
|
13684
|
+
id: this.instanceId,
|
|
13685
|
+
status: visibleStatus,
|
|
13686
|
+
title: dirName,
|
|
13687
|
+
activeModal: autoApproveActive ? null : adapterStatus.activeModal
|
|
13688
|
+
};
|
|
13689
|
+
}
|
|
13646
13690
|
updateSettings(newSettings) {
|
|
13647
13691
|
this.settings = { ...newSettings };
|
|
13648
13692
|
this.adapter.updateRuntimeSettings?.(this.settings);
|
|
@@ -14370,6 +14414,18 @@ var AcpProviderInstance = class {
|
|
|
14370
14414
|
this.detectStatusTransition();
|
|
14371
14415
|
}
|
|
14372
14416
|
}
|
|
14417
|
+
getSessionModalState() {
|
|
14418
|
+
const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
|
|
14419
|
+
return {
|
|
14420
|
+
id: this.instanceId,
|
|
14421
|
+
status: this.currentStatus,
|
|
14422
|
+
title: `${this.provider.name} \xB7 ${dirName}`,
|
|
14423
|
+
activeModal: this.currentStatus === "waiting_approval" ? {
|
|
14424
|
+
message: this.activeToolCalls.find((t) => t.status === "running")?.name || "Permission requested",
|
|
14425
|
+
buttons: ["Approve", "Reject"]
|
|
14426
|
+
} : null
|
|
14427
|
+
};
|
|
14428
|
+
}
|
|
14373
14429
|
getState() {
|
|
14374
14430
|
const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
|
|
14375
14431
|
const recentMessages = normalizeChatMessages(this.messages.map((m) => {
|
|
@@ -21252,6 +21308,29 @@ var ProviderInstanceManager = class {
|
|
|
21252
21308
|
}
|
|
21253
21309
|
return sessions;
|
|
21254
21310
|
}
|
|
21311
|
+
getSessionModalState(sessionId, options = {}) {
|
|
21312
|
+
if (!sessionId) return null;
|
|
21313
|
+
const candidates = [sessionId];
|
|
21314
|
+
if (options.instanceKey && options.instanceKey !== sessionId) {
|
|
21315
|
+
candidates.push(options.instanceKey);
|
|
21316
|
+
}
|
|
21317
|
+
for (const id of candidates) {
|
|
21318
|
+
const instance = this.instances.get(id);
|
|
21319
|
+
if (!instance?.getSessionModalState) continue;
|
|
21320
|
+
try {
|
|
21321
|
+
const projected = instance.getSessionModalState(sessionId);
|
|
21322
|
+
if (!projected?.id) continue;
|
|
21323
|
+
if (projected.id !== sessionId) {
|
|
21324
|
+
LOG.warn("InstanceMgr", `[InstanceManager] Ignoring mismatched session modal projection from ${id}: requested=${sessionId} projected=${projected.id}`);
|
|
21325
|
+
continue;
|
|
21326
|
+
}
|
|
21327
|
+
return projected;
|
|
21328
|
+
} catch (e) {
|
|
21329
|
+
LOG.warn("InstanceMgr", `[InstanceManager] Failed to project session modal metadata from ${id}: ${e.message}`);
|
|
21330
|
+
}
|
|
21331
|
+
}
|
|
21332
|
+
return null;
|
|
21333
|
+
}
|
|
21255
21334
|
/**
|
|
21256
21335
|
* Per-category status collect
|
|
21257
21336
|
*/
|