@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/package.json
CHANGED
|
@@ -254,6 +254,40 @@ function normalizeReadChatCommandStatus(status: unknown, activeModal: unknown):
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
+
function isGeneratingLikeStatus(status: unknown): boolean {
|
|
258
|
+
return status === 'generating' || status === 'streaming' || status === 'long_generating' || status === 'starting';
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function shouldTrustCliAdapterTerminalStatus(parsedStatus: unknown, activeModal: unknown, adapter: CliAdapter, adapterStatus: any): boolean {
|
|
262
|
+
if (!isGeneratingLikeStatus(parsedStatus)) return false;
|
|
263
|
+
if (hasNonEmptyModalButtons(activeModal)) return false;
|
|
264
|
+
const adapterRawStatus = typeof adapterStatus?.status === 'string' ? adapterStatus.status.trim() : '';
|
|
265
|
+
if (adapterRawStatus !== 'idle') return false;
|
|
266
|
+
if (typeof adapter.isProcessing === 'function' && adapter.isProcessing()) return false;
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function normalizeCliReadChatStatus(parsedStatus: unknown, activeModal: unknown, adapter: CliAdapter, adapterStatus: any): string {
|
|
271
|
+
if (shouldTrustCliAdapterTerminalStatus(parsedStatus, activeModal, adapter, adapterStatus)) return 'idle';
|
|
272
|
+
return typeof parsedStatus === 'string' && parsedStatus.trim() ? parsedStatus : 'idle';
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function finalizeStreamingMessagesWhenIdle(messages: ChatMessage[], status: string): ChatMessage[] {
|
|
276
|
+
if (status !== 'idle') return messages;
|
|
277
|
+
return messages.map((message) => {
|
|
278
|
+
const meta = message.meta && typeof message.meta === 'object'
|
|
279
|
+
? message.meta as Record<string, unknown>
|
|
280
|
+
: undefined;
|
|
281
|
+
const hasStreamingMeta = meta?.streaming === true;
|
|
282
|
+
if (message.bubbleState !== 'streaming' && !hasStreamingMeta) return message;
|
|
283
|
+
return {
|
|
284
|
+
...message,
|
|
285
|
+
...(message.bubbleState === 'streaming' ? { bubbleState: 'final' as const } : {}),
|
|
286
|
+
...(hasStreamingMeta ? { meta: { ...meta, streaming: false } } : {}),
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
257
291
|
function buildReadChatCommandResult(payload: Record<string, any>, args: any): CommandResult {
|
|
258
292
|
let validatedPayload: Record<string, any>;
|
|
259
293
|
const debugReadChat = payload?.debugReadChat && typeof payload.debugReadChat === 'object'
|
|
@@ -764,13 +798,14 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
|
|
|
764
798
|
? parsedRecord.coverage
|
|
765
799
|
: undefined;
|
|
766
800
|
const activeModal = parsedRecord.activeModal ?? parsedRecord.modal ?? null;
|
|
767
|
-
const returnedStatus = parsedRecord.status
|
|
801
|
+
const returnedStatus = normalizeCliReadChatStatus(parsedRecord.status, activeModal, adapter, adapterStatus);
|
|
768
802
|
const runtimeMessageMerger = getTargetInstance(h, args) as RuntimeChatMessageMerger | null;
|
|
803
|
+
const parsedMessages = finalizeStreamingMessagesWhenIdle(parsedRecord.messages as ChatMessage[], returnedStatus);
|
|
769
804
|
const returnedMessages = runtimeMessageMerger?.category === 'cli'
|
|
770
805
|
&& runtimeMessageMerger.type === adapter.cliType
|
|
771
806
|
&& typeof runtimeMessageMerger.mergeRuntimeChatMessages === 'function'
|
|
772
|
-
? runtimeMessageMerger.mergeRuntimeChatMessages(
|
|
773
|
-
:
|
|
807
|
+
? runtimeMessageMerger.mergeRuntimeChatMessages(parsedMessages)
|
|
808
|
+
: parsedMessages;
|
|
774
809
|
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}`);
|
|
775
810
|
return buildReadChatCommandResult({
|
|
776
811
|
messages: returnedMessages,
|