@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.mjs
CHANGED
|
@@ -11853,6 +11853,34 @@ function normalizeReadChatCommandStatus(status, activeModal) {
|
|
|
11853
11853
|
return raw;
|
|
11854
11854
|
}
|
|
11855
11855
|
}
|
|
11856
|
+
function isGeneratingLikeStatus(status) {
|
|
11857
|
+
return status === "generating" || status === "streaming" || status === "long_generating" || status === "starting";
|
|
11858
|
+
}
|
|
11859
|
+
function shouldTrustCliAdapterTerminalStatus(parsedStatus, activeModal, adapter, adapterStatus) {
|
|
11860
|
+
if (!isGeneratingLikeStatus(parsedStatus)) return false;
|
|
11861
|
+
if (hasNonEmptyModalButtons(activeModal)) return false;
|
|
11862
|
+
const adapterRawStatus = typeof adapterStatus?.status === "string" ? adapterStatus.status.trim() : "";
|
|
11863
|
+
if (adapterRawStatus !== "idle") return false;
|
|
11864
|
+
if (typeof adapter.isProcessing === "function" && adapter.isProcessing()) return false;
|
|
11865
|
+
return true;
|
|
11866
|
+
}
|
|
11867
|
+
function normalizeCliReadChatStatus(parsedStatus, activeModal, adapter, adapterStatus) {
|
|
11868
|
+
if (shouldTrustCliAdapterTerminalStatus(parsedStatus, activeModal, adapter, adapterStatus)) return "idle";
|
|
11869
|
+
return typeof parsedStatus === "string" && parsedStatus.trim() ? parsedStatus : "idle";
|
|
11870
|
+
}
|
|
11871
|
+
function finalizeStreamingMessagesWhenIdle(messages, status) {
|
|
11872
|
+
if (status !== "idle") return messages;
|
|
11873
|
+
return messages.map((message) => {
|
|
11874
|
+
const meta = message.meta && typeof message.meta === "object" ? message.meta : void 0;
|
|
11875
|
+
const hasStreamingMeta = meta?.streaming === true;
|
|
11876
|
+
if (message.bubbleState !== "streaming" && !hasStreamingMeta) return message;
|
|
11877
|
+
return {
|
|
11878
|
+
...message,
|
|
11879
|
+
...message.bubbleState === "streaming" ? { bubbleState: "final" } : {},
|
|
11880
|
+
...hasStreamingMeta ? { meta: { ...meta, streaming: false } } : {}
|
|
11881
|
+
};
|
|
11882
|
+
});
|
|
11883
|
+
}
|
|
11856
11884
|
function buildReadChatCommandResult(payload, args) {
|
|
11857
11885
|
let validatedPayload;
|
|
11858
11886
|
const debugReadChat = payload?.debugReadChat && typeof payload.debugReadChat === "object" ? payload.debugReadChat : void 0;
|
|
@@ -12291,9 +12319,10 @@ async function handleReadChat(h, args) {
|
|
|
12291
12319
|
const transcriptAuthority = parsedRecord.transcriptAuthority === "provider" || parsedRecord.transcriptAuthority === "daemon" ? parsedRecord.transcriptAuthority : void 0;
|
|
12292
12320
|
const coverage = parsedRecord.coverage === "full" || parsedRecord.coverage === "tail" || parsedRecord.coverage === "current-turn" ? parsedRecord.coverage : void 0;
|
|
12293
12321
|
const activeModal = parsedRecord.activeModal ?? parsedRecord.modal ?? null;
|
|
12294
|
-
const returnedStatus = parsedRecord.status
|
|
12322
|
+
const returnedStatus = normalizeCliReadChatStatus(parsedRecord.status, activeModal, adapter, adapterStatus);
|
|
12295
12323
|
const runtimeMessageMerger = getTargetInstance(h, args);
|
|
12296
|
-
const
|
|
12324
|
+
const parsedMessages = finalizeStreamingMessagesWhenIdle(parsedRecord.messages, returnedStatus);
|
|
12325
|
+
const returnedMessages = runtimeMessageMerger?.category === "cli" && runtimeMessageMerger.type === adapter.cliType && typeof runtimeMessageMerger.mergeRuntimeChatMessages === "function" ? runtimeMessageMerger.mergeRuntimeChatMessages(parsedMessages) : parsedMessages;
|
|
12297
12326
|
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}`);
|
|
12298
12327
|
return buildReadChatCommandResult({
|
|
12299
12328
|
messages: returnedMessages,
|