@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.mjs CHANGED
@@ -15877,7 +15877,7 @@ function buildCliMessageSourceProvenance(args) {
15877
15877
  };
15878
15878
  }
15879
15879
  function buildNativeHistoryFallbackReason(args) {
15880
- if (!supportsCliNativeTranscript(args.providerType)) return "provider_native_transcript_not_supported";
15880
+ if (!supportsCliNativeTranscript(args.providerType, args.provider)) return "provider_native_transcript_not_supported";
15881
15881
  if (args.nativeSource === "native-unavailable") return "native_history_unavailable";
15882
15882
  if (args.nativeSource && args.nativeSource !== "provider-native") return `native_history_source_${args.nativeSource}`;
15883
15883
  if (args.nativeMessageCount <= 0) return "native_history_empty";
@@ -15885,8 +15885,9 @@ function buildNativeHistoryFallbackReason(args) {
15885
15885
  if (!args.freshEnough) return "native_history_stale";
15886
15886
  return "native_history_not_selected";
15887
15887
  }
15888
- function supportsCliNativeTranscript(providerType) {
15889
- return CLI_NATIVE_TRANSCRIPT_PROVIDERS.has(providerType);
15888
+ function supportsCliNativeTranscript(providerType, provider) {
15889
+ if (CLI_NATIVE_TRANSCRIPT_PROVIDERS.has(providerType)) return true;
15890
+ return provider?.category === "cli" && provider?.canonicalHistory?.mode === "native-source";
15890
15891
  }
15891
15892
  function hasSafeNativeHistoryMapping(args) {
15892
15893
  const explicitSessionId = String(args.historySessionId || args.providerSessionId || "").trim();
@@ -15965,6 +15966,15 @@ function normalizeReadChatCommandStatus(status, activeModal) {
15965
15966
  function isGeneratingLikeStatus(status) {
15966
15967
  return status === "generating" || status === "streaming" || status === "long_generating" || status === "starting";
15967
15968
  }
15969
+ function hasVisibleAssistantMessage(messages) {
15970
+ if (!Array.isArray(messages)) return false;
15971
+ return messages.some((message) => {
15972
+ if (!message || message.role !== "assistant") return false;
15973
+ const kind = typeof message.kind === "string" ? message.kind : "standard";
15974
+ if (kind !== "standard") return false;
15975
+ return String(message.content || "").trim().length > 0;
15976
+ });
15977
+ }
15968
15978
  function shouldTrustCliAdapterTerminalStatus(parsedStatus, activeModal, adapter, adapterStatus) {
15969
15979
  if (!isGeneratingLikeStatus(parsedStatus)) return false;
15970
15980
  if (hasNonEmptyModalButtons(activeModal)) return false;
@@ -15978,6 +15988,9 @@ function normalizeCliReadChatStatus(parsedStatus, activeModal, adapter, adapterS
15978
15988
  if (adapterRawStatus === "starting" && isGeneratingLikeStatus(parsedStatus) && !hasNonEmptyModalButtons(activeModal) && Array.isArray(parsedMessages) && parsedMessages.length === 0 && Array.isArray(adapterStatus?.messages) && adapterStatus.messages.length === 0 && !(typeof adapter.isProcessing === "function" && adapter.isProcessing())) {
15979
15989
  return "starting";
15980
15990
  }
15991
+ if (isGeneratingLikeStatus(adapterRawStatus) && parsedStatus === "idle" && !hasNonEmptyModalButtons(activeModal) && !hasVisibleAssistantMessage(parsedMessages)) {
15992
+ return adapterRawStatus;
15993
+ }
15981
15994
  if (shouldTrustCliAdapterTerminalStatus(parsedStatus, activeModal, adapter, adapterStatus)) return "idle";
15982
15995
  return typeof parsedStatus === "string" && parsedStatus.trim() ? parsedStatus : "idle";
15983
15996
  }
@@ -16481,12 +16494,12 @@ async function handleReadChat(h, args) {
16481
16494
  let messageSource = buildCliMessageSourceProvenance({
16482
16495
  selected: "pty-parser",
16483
16496
  provider: adapter.cliType,
16484
- fallbackReason: supportsCliNativeTranscript(providerType) ? "native_history_not_checked" : "provider_native_transcript_not_supported",
16497
+ fallbackReason: supportsCliNativeTranscript(providerType, provider) ? "native_history_not_checked" : "provider_native_transcript_not_supported",
16485
16498
  ptyMessages: returnedMessages,
16486
16499
  returnedMessages,
16487
16500
  ptyStatusApprovalOnly: false
16488
16501
  });
16489
- if (supportsCliNativeTranscript(providerType) && provider?.canonicalHistory?.mode === "native-source") {
16502
+ if (supportsCliNativeTranscript(providerType, provider) && provider?.canonicalHistory?.mode === "native-source") {
16490
16503
  const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h, adapter.cliType);
16491
16504
  const workspace = typeof args?.workspace === "string" ? args.workspace : typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : typeof adapter.workingDir === "string" ? adapter.workingDir : void 0;
16492
16505
  const nativeHistoryLimit = Math.max(
@@ -16554,6 +16567,7 @@ async function handleReadChat(h, args) {
16554
16567
  } else {
16555
16568
  const fallbackReason = buildNativeHistoryFallbackReason({
16556
16569
  providerType,
16570
+ provider,
16557
16571
  nativeSource: nativeHistory.source,
16558
16572
  nativeMessageCount: nativeMessages.length,
16559
16573
  safeMapping,
@@ -16592,7 +16606,7 @@ async function handleReadChat(h, args) {
16592
16606
  returnedStatus: String(returnedStatus || ""),
16593
16607
  selectedMessageSource: messageSource.selected,
16594
16608
  messageSource,
16595
- shouldPreferAdapterMessages: supportsCliNativeTranscript(providerType) && messageSource.selected !== "native-history",
16609
+ shouldPreferAdapterMessages: supportsCliNativeTranscript(providerType, provider) && messageSource.selected !== "native-history",
16596
16610
  parsedMsgCount: parsedRecord.messages.length,
16597
16611
  returnedMsgCount: selectedMessages.length
16598
16612
  },
@@ -16618,19 +16632,20 @@ async function handleReadChat(h, args) {
16618
16632
  });
16619
16633
  const historyProviderSessionId = typeof history?.providerSessionId === "string" ? history.providerSessionId : historySessionId;
16620
16634
  const historyMessages = Array.isArray(history?.messages) ? normalizeChatMessages(history.messages) : [];
16621
- const safeMapping = supportsCliNativeTranscript(agentStr) ? hasSafeNativeHistoryMapping({
16635
+ const safeMapping = supportsCliNativeTranscript(agentStr, provider) ? hasSafeNativeHistoryMapping({
16622
16636
  historySessionId,
16623
16637
  providerSessionId: historyProviderSessionId,
16624
16638
  workspace,
16625
16639
  nativeMessages: historyMessages
16626
16640
  }) : false;
16627
- const nativeSelected = supportsCliNativeTranscript(agentStr) && history.source === "provider-native" && historyMessages.length > 0 && safeMapping;
16641
+ const nativeSelected = supportsCliNativeTranscript(agentStr, provider) && history.source === "provider-native" && historyMessages.length > 0 && safeMapping;
16628
16642
  const messageSource = buildCliMessageSourceProvenance({
16629
16643
  selected: nativeSelected ? "native-history" : "pty-parser",
16630
16644
  provider: agentStr,
16631
16645
  nativeHandle: historyProviderSessionId || historySessionId,
16632
16646
  fallbackReason: nativeSelected ? void 0 : buildNativeHistoryFallbackReason({
16633
16647
  providerType: agentStr,
16648
+ provider,
16634
16649
  nativeSource: history.source,
16635
16650
  nativeMessageCount: historyMessages.length,
16636
16651
  safeMapping,
@@ -16645,7 +16660,7 @@ async function handleReadChat(h, args) {
16645
16660
  freshEnough: true,
16646
16661
  ptyStatusApprovalOnly: false
16647
16662
  });
16648
- const requiresNativeSource = supportsCliNativeTranscript(agentStr) && provider?.canonicalHistory?.mode === "native-source";
16663
+ const requiresNativeSource = supportsCliNativeTranscript(agentStr, provider) && provider?.canonicalHistory?.mode === "native-source";
16649
16664
  if (requiresNativeSource && !nativeSelected) {
16650
16665
  return {
16651
16666
  success: false,