@adhdev/daemon-core 0.9.82-rc.83 → 0.9.82-rc.85
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 +24 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +31 -9
package/package.json
CHANGED
|
@@ -290,12 +290,13 @@ function buildCliMessageSourceProvenance(args: {
|
|
|
290
290
|
|
|
291
291
|
function buildNativeHistoryFallbackReason(args: {
|
|
292
292
|
providerType: string;
|
|
293
|
+
provider?: ProviderModule;
|
|
293
294
|
nativeSource?: string;
|
|
294
295
|
nativeMessageCount: number;
|
|
295
296
|
safeMapping: boolean;
|
|
296
297
|
freshEnough: boolean;
|
|
297
298
|
}): string {
|
|
298
|
-
if (!supportsCliNativeTranscript(args.providerType)) return 'provider_native_transcript_not_supported';
|
|
299
|
+
if (!supportsCliNativeTranscript(args.providerType, args.provider)) return 'provider_native_transcript_not_supported';
|
|
299
300
|
if (args.nativeSource === 'native-unavailable') return 'native_history_unavailable';
|
|
300
301
|
if (args.nativeSource && args.nativeSource !== 'provider-native') return `native_history_source_${args.nativeSource}`;
|
|
301
302
|
if (args.nativeMessageCount <= 0) return 'native_history_empty';
|
|
@@ -304,8 +305,9 @@ function buildNativeHistoryFallbackReason(args: {
|
|
|
304
305
|
return 'native_history_not_selected';
|
|
305
306
|
}
|
|
306
307
|
|
|
307
|
-
function supportsCliNativeTranscript(providerType: string): boolean {
|
|
308
|
-
|
|
308
|
+
function supportsCliNativeTranscript(providerType: string, provider?: ProviderModule): boolean {
|
|
309
|
+
if (CLI_NATIVE_TRANSCRIPT_PROVIDERS.has(providerType)) return true;
|
|
310
|
+
return provider?.category === 'cli' && (provider?.canonicalHistory as any)?.mode === 'native-source';
|
|
309
311
|
}
|
|
310
312
|
|
|
311
313
|
function hasSafeNativeHistoryMapping(args: {
|
|
@@ -417,6 +419,16 @@ function isGeneratingLikeStatus(status: unknown): boolean {
|
|
|
417
419
|
return status === 'generating' || status === 'streaming' || status === 'long_generating' || status === 'starting';
|
|
418
420
|
}
|
|
419
421
|
|
|
422
|
+
function hasVisibleAssistantMessage(messages: unknown[] | undefined): boolean {
|
|
423
|
+
if (!Array.isArray(messages)) return false;
|
|
424
|
+
return messages.some((message: any) => {
|
|
425
|
+
if (!message || message.role !== 'assistant') return false;
|
|
426
|
+
const kind = typeof message.kind === 'string' ? message.kind : 'standard';
|
|
427
|
+
if (kind !== 'standard') return false;
|
|
428
|
+
return String(message.content || '').trim().length > 0;
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
|
|
420
432
|
function shouldTrustCliAdapterTerminalStatus(parsedStatus: unknown, activeModal: unknown, adapter: CliAdapter, adapterStatus: any): boolean {
|
|
421
433
|
if (!isGeneratingLikeStatus(parsedStatus)) return false;
|
|
422
434
|
if (hasNonEmptyModalButtons(activeModal)) return false;
|
|
@@ -438,6 +450,14 @@ function normalizeCliReadChatStatus(parsedStatus: unknown, activeModal: unknown,
|
|
|
438
450
|
&& !(typeof adapter.isProcessing === 'function' && adapter.isProcessing())) {
|
|
439
451
|
return 'starting';
|
|
440
452
|
}
|
|
453
|
+
if (
|
|
454
|
+
isGeneratingLikeStatus(adapterRawStatus)
|
|
455
|
+
&& parsedStatus === 'idle'
|
|
456
|
+
&& !hasNonEmptyModalButtons(activeModal)
|
|
457
|
+
&& !hasVisibleAssistantMessage(parsedMessages)
|
|
458
|
+
) {
|
|
459
|
+
return adapterRawStatus;
|
|
460
|
+
}
|
|
441
461
|
if (shouldTrustCliAdapterTerminalStatus(parsedStatus, activeModal, adapter, adapterStatus)) return 'idle';
|
|
442
462
|
return typeof parsedStatus === 'string' && parsedStatus.trim() ? parsedStatus : 'idle';
|
|
443
463
|
}
|
|
@@ -1029,13 +1049,13 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
|
|
|
1029
1049
|
let messageSource = buildCliMessageSourceProvenance({
|
|
1030
1050
|
selected: 'pty-parser',
|
|
1031
1051
|
provider: adapter.cliType,
|
|
1032
|
-
fallbackReason: supportsCliNativeTranscript(providerType) ? 'native_history_not_checked' : 'provider_native_transcript_not_supported',
|
|
1052
|
+
fallbackReason: supportsCliNativeTranscript(providerType, provider) ? 'native_history_not_checked' : 'provider_native_transcript_not_supported',
|
|
1033
1053
|
ptyMessages: returnedMessages,
|
|
1034
1054
|
returnedMessages,
|
|
1035
1055
|
ptyStatusApprovalOnly: false,
|
|
1036
1056
|
});
|
|
1037
1057
|
|
|
1038
|
-
if (supportsCliNativeTranscript(providerType) && (provider?.canonicalHistory as any)?.mode === 'native-source') {
|
|
1058
|
+
if (supportsCliNativeTranscript(providerType, provider) && (provider?.canonicalHistory as any)?.mode === 'native-source') {
|
|
1039
1059
|
const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h, adapter.cliType);
|
|
1040
1060
|
const workspace = typeof args?.workspace === 'string'
|
|
1041
1061
|
? args.workspace
|
|
@@ -1114,6 +1134,7 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
|
|
|
1114
1134
|
} else {
|
|
1115
1135
|
const fallbackReason = buildNativeHistoryFallbackReason({
|
|
1116
1136
|
providerType,
|
|
1137
|
+
provider,
|
|
1117
1138
|
nativeSource: (nativeHistory as any).source,
|
|
1118
1139
|
nativeMessageCount: nativeMessages.length,
|
|
1119
1140
|
safeMapping,
|
|
@@ -1152,7 +1173,7 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
|
|
|
1152
1173
|
returnedStatus: String(returnedStatus || ''),
|
|
1153
1174
|
selectedMessageSource: (messageSource as any).selected,
|
|
1154
1175
|
messageSource,
|
|
1155
|
-
shouldPreferAdapterMessages: supportsCliNativeTranscript(providerType) && (messageSource as any).selected !== 'native-history',
|
|
1176
|
+
shouldPreferAdapterMessages: supportsCliNativeTranscript(providerType, provider) && (messageSource as any).selected !== 'native-history',
|
|
1156
1177
|
parsedMsgCount: parsedRecord.messages.length,
|
|
1157
1178
|
returnedMsgCount: selectedMessages.length,
|
|
1158
1179
|
},
|
|
@@ -1186,7 +1207,7 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
|
|
|
1186
1207
|
const historyMessages = Array.isArray((history as any)?.messages)
|
|
1187
1208
|
? normalizeChatMessages((history as any).messages as ChatMessage[])
|
|
1188
1209
|
: [];
|
|
1189
|
-
const safeMapping = supportsCliNativeTranscript(agentStr)
|
|
1210
|
+
const safeMapping = supportsCliNativeTranscript(agentStr, provider)
|
|
1190
1211
|
? hasSafeNativeHistoryMapping({
|
|
1191
1212
|
historySessionId,
|
|
1192
1213
|
providerSessionId: historyProviderSessionId,
|
|
@@ -1194,7 +1215,7 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
|
|
|
1194
1215
|
nativeMessages: historyMessages,
|
|
1195
1216
|
})
|
|
1196
1217
|
: false;
|
|
1197
|
-
const nativeSelected = supportsCliNativeTranscript(agentStr)
|
|
1218
|
+
const nativeSelected = supportsCliNativeTranscript(agentStr, provider)
|
|
1198
1219
|
&& (history as any).source === 'provider-native'
|
|
1199
1220
|
&& historyMessages.length > 0
|
|
1200
1221
|
&& safeMapping;
|
|
@@ -1206,6 +1227,7 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
|
|
|
1206
1227
|
? undefined
|
|
1207
1228
|
: buildNativeHistoryFallbackReason({
|
|
1208
1229
|
providerType: agentStr,
|
|
1230
|
+
provider,
|
|
1209
1231
|
nativeSource: (history as any).source,
|
|
1210
1232
|
nativeMessageCount: historyMessages.length,
|
|
1211
1233
|
safeMapping,
|
|
@@ -1220,7 +1242,7 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
|
|
|
1220
1242
|
freshEnough: true,
|
|
1221
1243
|
ptyStatusApprovalOnly: false,
|
|
1222
1244
|
});
|
|
1223
|
-
const requiresNativeSource = supportsCliNativeTranscript(agentStr)
|
|
1245
|
+
const requiresNativeSource = supportsCliNativeTranscript(agentStr, provider)
|
|
1224
1246
|
&& (provider?.canonicalHistory as any)?.mode === 'native-source';
|
|
1225
1247
|
if (requiresNativeSource && !nativeSelected) {
|
|
1226
1248
|
return {
|