@adhdev/daemon-core 0.9.32 → 0.9.33

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 CHANGED
@@ -10509,6 +10509,26 @@ function toHistoryPersistedMessages(messages) {
10509
10509
  historyDedupKey: deriveHistoryDedupKey(message)
10510
10510
  }));
10511
10511
  }
10512
+ function findLastMessageIndexBySignature(messages, signature) {
10513
+ if (!signature) return -1;
10514
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
10515
+ if (getChatMessageSignature(messages[index]) === signature) {
10516
+ return index;
10517
+ }
10518
+ }
10519
+ return -1;
10520
+ }
10521
+ function buildBoundedTailSync(messages, cursor) {
10522
+ const totalMessages = messages.length;
10523
+ const tailMessages = cursor.tailLimit > 0 && totalMessages > cursor.tailLimit ? messages.slice(-cursor.tailLimit) : messages;
10524
+ return {
10525
+ syncMode: "full",
10526
+ replaceFrom: 0,
10527
+ messages: tailMessages,
10528
+ totalMessages,
10529
+ lastMessageSignature: getChatMessageSignature(messages[totalMessages - 1])
10530
+ };
10531
+ }
10512
10532
  function computeReadChatSync(messages, cursor) {
10513
10533
  const totalMessages = messages.length;
10514
10534
  const lastMessageSignature = getChatMessageSignature(messages[totalMessages - 1]);
@@ -10540,6 +10560,15 @@ function computeReadChatSync(messages, cursor) {
10540
10560
  lastMessageSignature
10541
10561
  };
10542
10562
  }
10563
+ if (cursor.tailLimit > 0 && knownSignature === lastMessageSignature) {
10564
+ return {
10565
+ syncMode: "noop",
10566
+ replaceFrom: totalMessages,
10567
+ messages: [],
10568
+ totalMessages,
10569
+ lastMessageSignature
10570
+ };
10571
+ }
10543
10572
  if (knownMessageCount < totalMessages) {
10544
10573
  const anchorSignature = getChatMessageSignature(messages[knownMessageCount - 1]);
10545
10574
  if (anchorSignature === knownSignature) {
@@ -10551,6 +10580,19 @@ function computeReadChatSync(messages, cursor) {
10551
10580
  lastMessageSignature
10552
10581
  };
10553
10582
  }
10583
+ if (cursor.tailLimit > 0) {
10584
+ const signatureIndex = findLastMessageIndexBySignature(messages, knownSignature);
10585
+ if (signatureIndex >= 0) {
10586
+ return {
10587
+ syncMode: "append",
10588
+ replaceFrom: knownMessageCount,
10589
+ messages: messages.slice(signatureIndex + 1),
10590
+ totalMessages,
10591
+ lastMessageSignature
10592
+ };
10593
+ }
10594
+ return buildBoundedTailSync(messages, cursor);
10595
+ }
10554
10596
  }
10555
10597
  const replaceFrom = Math.max(0, Math.min(knownMessageCount - 1, totalMessages));
10556
10598
  return {
@@ -16551,10 +16593,22 @@ var ProviderLoader = class _ProviderLoader {
16551
16593
  setMachineProviderEnabled(type, enabled) {
16552
16594
  return this.setMachineProviderConfig(type, { enabled });
16553
16595
  }
16596
+ getEffectiveProviderAvailability(type) {
16597
+ const providerType = this.resolveAlias(type);
16598
+ const availability = this.providerAvailability.get(providerType);
16599
+ if (availability) return availability;
16600
+ const machineConfig = this.getMachineProviderConfig(providerType);
16601
+ const lastDetection = machineConfig.lastDetection;
16602
+ if (!lastDetection) return void 0;
16603
+ return {
16604
+ installed: lastDetection.ok === true,
16605
+ detectedPath: typeof lastDetection.path === "string" && lastDetection.path.trim() ? lastDetection.path.trim() : null
16606
+ };
16607
+ }
16554
16608
  getMachineProviderStatus(type) {
16555
16609
  const providerType = this.resolveAlias(type);
16556
16610
  if (!this.isMachineProviderEnabled(providerType)) return "disabled";
16557
- const availability = this.providerAvailability.get(providerType);
16611
+ const availability = this.getEffectiveProviderAvailability(providerType);
16558
16612
  if (!availability) return "enabled_unchecked";
16559
16613
  return availability.installed ? "detected" : "not_detected";
16560
16614
  }
@@ -16682,7 +16736,7 @@ var ProviderLoader = class _ProviderLoader {
16682
16736
  }
16683
16737
  getAvailableProviderInfos() {
16684
16738
  return this.getAll().map((provider) => {
16685
- const availability = this.providerAvailability.get(provider.type);
16739
+ const availability = this.getEffectiveProviderAvailability(provider.type);
16686
16740
  const enabled = this.isMachineProviderEnabled(provider.type);
16687
16741
  const machineConfig = this.getMachineProviderConfig(provider.type);
16688
16742
  return {