@adhdev/daemon-core 0.9.76-rc.17 → 0.9.76-rc.19
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 +31 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +38 -3
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,9 +12516,10 @@ 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
|
|
12519
|
+
const returnedStatus = normalizeCliReadChatStatus(parsedRecord.status, activeModal, adapter, adapterStatus);
|
|
12492
12520
|
const runtimeMessageMerger = getTargetInstance(h, args);
|
|
12493
|
-
const
|
|
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;
|
|
12494
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}`);
|
|
12495
12524
|
return buildReadChatCommandResult({
|
|
12496
12525
|
messages: returnedMessages,
|