@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.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,10 +12319,13 @@ 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
|
|
12295
|
-
|
|
12322
|
+
const returnedStatus = normalizeCliReadChatStatus(parsedRecord.status, activeModal, adapter, adapterStatus);
|
|
12323
|
+
const runtimeMessageMerger = getTargetInstance(h, args);
|
|
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;
|
|
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}`);
|
|
12296
12327
|
return buildReadChatCommandResult({
|
|
12297
|
-
messages:
|
|
12328
|
+
messages: returnedMessages,
|
|
12298
12329
|
status: returnedStatus,
|
|
12299
12330
|
activeModal,
|
|
12300
12331
|
debugReadChat: {
|
|
@@ -12305,7 +12336,7 @@ async function handleReadChat(h, args) {
|
|
|
12305
12336
|
returnedStatus: String(returnedStatus || ""),
|
|
12306
12337
|
shouldPreferAdapterMessages: false,
|
|
12307
12338
|
parsedMsgCount: parsedRecord.messages.length,
|
|
12308
|
-
returnedMsgCount:
|
|
12339
|
+
returnedMsgCount: returnedMessages.length
|
|
12309
12340
|
},
|
|
12310
12341
|
...title ? { title } : {},
|
|
12311
12342
|
...providerSessionId ? { providerSessionId } : {},
|
|
@@ -15432,6 +15463,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
15432
15463
|
);
|
|
15433
15464
|
}
|
|
15434
15465
|
}
|
|
15466
|
+
mergeRuntimeChatMessages(parsedMessages) {
|
|
15467
|
+
return this.mergeConversationMessages(parsedMessages);
|
|
15468
|
+
}
|
|
15435
15469
|
mergeConversationMessages(parsedMessages) {
|
|
15436
15470
|
if (this.runtimeMessages.length === 0) return normalizeChatMessages(parsedMessages);
|
|
15437
15471
|
return normalizeChatMessages([...parsedMessages, ...this.runtimeMessages.map((entry) => entry.message)].map((message, index) => ({ message, index })).sort((a, b) => {
|