@adhdev/daemon-core 0.9.76-rc.16 → 0.9.76-rc.18
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 +38 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -4
- package/dist/index.mjs.map +1 -1
- package/dist/providers/cli-provider-instance.d.ts +2 -0
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +49 -4
- package/src/providers/cli-provider-instance.d.ts +2 -0
- package/src/providers/cli-provider-instance.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -12050,6 +12050,34 @@ function normalizeReadChatCommandStatus(status, activeModal) {
|
|
|
12050
12050
|
return raw;
|
|
12051
12051
|
}
|
|
12052
12052
|
}
|
|
12053
|
+
function isGeneratingLikeStatus(status) {
|
|
12054
|
+
return status === "generating" || status === "streaming" || status === "long_generating" || status === "starting";
|
|
12055
|
+
}
|
|
12056
|
+
function shouldTrustCliAdapterTerminalStatus(parsedStatus, activeModal, adapter, adapterStatus) {
|
|
12057
|
+
if (!isGeneratingLikeStatus(parsedStatus)) return false;
|
|
12058
|
+
if (hasNonEmptyModalButtons(activeModal)) return false;
|
|
12059
|
+
const adapterRawStatus = typeof adapterStatus?.status === "string" ? adapterStatus.status.trim() : "";
|
|
12060
|
+
if (adapterRawStatus !== "idle") return false;
|
|
12061
|
+
if (typeof adapter.isProcessing === "function" && adapter.isProcessing()) return false;
|
|
12062
|
+
return true;
|
|
12063
|
+
}
|
|
12064
|
+
function normalizeCliReadChatStatus(parsedStatus, activeModal, adapter, adapterStatus) {
|
|
12065
|
+
if (shouldTrustCliAdapterTerminalStatus(parsedStatus, activeModal, adapter, adapterStatus)) return "idle";
|
|
12066
|
+
return typeof parsedStatus === "string" && parsedStatus.trim() ? parsedStatus : "idle";
|
|
12067
|
+
}
|
|
12068
|
+
function finalizeStreamingMessagesWhenIdle(messages, status) {
|
|
12069
|
+
if (status !== "idle") return messages;
|
|
12070
|
+
return messages.map((message) => {
|
|
12071
|
+
const meta = message.meta && typeof message.meta === "object" ? message.meta : void 0;
|
|
12072
|
+
const hasStreamingMeta = meta?.streaming === true;
|
|
12073
|
+
if (message.bubbleState !== "streaming" && !hasStreamingMeta) return message;
|
|
12074
|
+
return {
|
|
12075
|
+
...message,
|
|
12076
|
+
...message.bubbleState === "streaming" ? { bubbleState: "final" } : {},
|
|
12077
|
+
...hasStreamingMeta ? { meta: { ...meta, streaming: false } } : {}
|
|
12078
|
+
};
|
|
12079
|
+
});
|
|
12080
|
+
}
|
|
12053
12081
|
function buildReadChatCommandResult(payload, args) {
|
|
12054
12082
|
let validatedPayload;
|
|
12055
12083
|
const debugReadChat = payload?.debugReadChat && typeof payload.debugReadChat === "object" ? payload.debugReadChat : void 0;
|
|
@@ -12488,10 +12516,13 @@ async function handleReadChat(h, args) {
|
|
|
12488
12516
|
const transcriptAuthority = parsedRecord.transcriptAuthority === "provider" || parsedRecord.transcriptAuthority === "daemon" ? parsedRecord.transcriptAuthority : void 0;
|
|
12489
12517
|
const coverage = parsedRecord.coverage === "full" || parsedRecord.coverage === "tail" || parsedRecord.coverage === "current-turn" ? parsedRecord.coverage : void 0;
|
|
12490
12518
|
const activeModal = parsedRecord.activeModal ?? parsedRecord.modal ?? null;
|
|
12491
|
-
const returnedStatus = parsedRecord.status
|
|
12492
|
-
|
|
12519
|
+
const returnedStatus = normalizeCliReadChatStatus(parsedRecord.status, activeModal, adapter, adapterStatus);
|
|
12520
|
+
const runtimeMessageMerger = getTargetInstance(h, args);
|
|
12521
|
+
const parsedMessages = finalizeStreamingMessagesWhenIdle(parsedRecord.messages, returnedStatus);
|
|
12522
|
+
const returnedMessages = runtimeMessageMerger?.category === "cli" && runtimeMessageMerger.type === adapter.cliType && typeof runtimeMessageMerger.mergeRuntimeChatMessages === "function" ? runtimeMessageMerger.mergeRuntimeChatMessages(parsedMessages) : parsedMessages;
|
|
12523
|
+
LOG.debug("Command", `[read_chat] cli-like parsed provider=${adapter.cliType} target=${String(args?.targetSessionId || "")} adapterStatus=${String(adapterStatus.status || "")} parsedStatus=${String(parsedRecord.status || "")} parsedMsgCount=${parsedRecord.messages.length} returnedMsgCount=${returnedMessages.length}`);
|
|
12493
12524
|
return buildReadChatCommandResult({
|
|
12494
|
-
messages:
|
|
12525
|
+
messages: returnedMessages,
|
|
12495
12526
|
status: returnedStatus,
|
|
12496
12527
|
activeModal,
|
|
12497
12528
|
debugReadChat: {
|
|
@@ -12502,7 +12533,7 @@ async function handleReadChat(h, args) {
|
|
|
12502
12533
|
returnedStatus: String(returnedStatus || ""),
|
|
12503
12534
|
shouldPreferAdapterMessages: false,
|
|
12504
12535
|
parsedMsgCount: parsedRecord.messages.length,
|
|
12505
|
-
returnedMsgCount:
|
|
12536
|
+
returnedMsgCount: returnedMessages.length
|
|
12506
12537
|
},
|
|
12507
12538
|
...title ? { title } : {},
|
|
12508
12539
|
...providerSessionId ? { providerSessionId } : {},
|
|
@@ -15629,6 +15660,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
15629
15660
|
);
|
|
15630
15661
|
}
|
|
15631
15662
|
}
|
|
15663
|
+
mergeRuntimeChatMessages(parsedMessages) {
|
|
15664
|
+
return this.mergeConversationMessages(parsedMessages);
|
|
15665
|
+
}
|
|
15632
15666
|
mergeConversationMessages(parsedMessages) {
|
|
15633
15667
|
if (this.runtimeMessages.length === 0) return normalizeChatMessages(parsedMessages);
|
|
15634
15668
|
return normalizeChatMessages([...parsedMessages, ...this.runtimeMessages.map((entry) => entry.message)].map((message, index) => ({ message, index })).sort((a, b) => {
|