adhdev 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
@@ -7461,6 +7461,26 @@ function toHistoryPersistedMessages(messages) {
7461
7461
  historyDedupKey: deriveHistoryDedupKey(message)
7462
7462
  }));
7463
7463
  }
7464
+ function findLastMessageIndexBySignature(messages, signature) {
7465
+ if (!signature) return -1;
7466
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
7467
+ if (getChatMessageSignature(messages[index]) === signature) {
7468
+ return index;
7469
+ }
7470
+ }
7471
+ return -1;
7472
+ }
7473
+ function buildBoundedTailSync(messages, cursor) {
7474
+ const totalMessages = messages.length;
7475
+ const tailMessages = cursor.tailLimit > 0 && totalMessages > cursor.tailLimit ? messages.slice(-cursor.tailLimit) : messages;
7476
+ return {
7477
+ syncMode: "full",
7478
+ replaceFrom: 0,
7479
+ messages: tailMessages,
7480
+ totalMessages,
7481
+ lastMessageSignature: getChatMessageSignature(messages[totalMessages - 1])
7482
+ };
7483
+ }
7464
7484
  function computeReadChatSync(messages, cursor) {
7465
7485
  const totalMessages = messages.length;
7466
7486
  const lastMessageSignature = getChatMessageSignature(messages[totalMessages - 1]);
@@ -7492,6 +7512,15 @@ function computeReadChatSync(messages, cursor) {
7492
7512
  lastMessageSignature
7493
7513
  };
7494
7514
  }
7515
+ if (cursor.tailLimit > 0 && knownSignature === lastMessageSignature) {
7516
+ return {
7517
+ syncMode: "noop",
7518
+ replaceFrom: totalMessages,
7519
+ messages: [],
7520
+ totalMessages,
7521
+ lastMessageSignature
7522
+ };
7523
+ }
7495
7524
  if (knownMessageCount < totalMessages) {
7496
7525
  const anchorSignature = getChatMessageSignature(messages[knownMessageCount - 1]);
7497
7526
  if (anchorSignature === knownSignature) {
@@ -7503,6 +7532,19 @@ function computeReadChatSync(messages, cursor) {
7503
7532
  lastMessageSignature
7504
7533
  };
7505
7534
  }
7535
+ if (cursor.tailLimit > 0) {
7536
+ const signatureIndex = findLastMessageIndexBySignature(messages, knownSignature);
7537
+ if (signatureIndex >= 0) {
7538
+ return {
7539
+ syncMode: "append",
7540
+ replaceFrom: knownMessageCount,
7541
+ messages: messages.slice(signatureIndex + 1),
7542
+ totalMessages,
7543
+ lastMessageSignature
7544
+ };
7545
+ }
7546
+ return buildBoundedTailSync(messages, cursor);
7547
+ }
7506
7548
  }
7507
7549
  const replaceFrom = Math.max(0, Math.min(knownMessageCount - 1, totalMessages));
7508
7550
  return {
@@ -35469,10 +35511,22 @@ var init_provider_loader = __esm({
35469
35511
  setMachineProviderEnabled(type, enabled) {
35470
35512
  return this.setMachineProviderConfig(type, { enabled });
35471
35513
  }
35514
+ getEffectiveProviderAvailability(type) {
35515
+ const providerType = this.resolveAlias(type);
35516
+ const availability = this.providerAvailability.get(providerType);
35517
+ if (availability) return availability;
35518
+ const machineConfig = this.getMachineProviderConfig(providerType);
35519
+ const lastDetection = machineConfig.lastDetection;
35520
+ if (!lastDetection) return void 0;
35521
+ return {
35522
+ installed: lastDetection.ok === true,
35523
+ detectedPath: typeof lastDetection.path === "string" && lastDetection.path.trim() ? lastDetection.path.trim() : null
35524
+ };
35525
+ }
35472
35526
  getMachineProviderStatus(type) {
35473
35527
  const providerType = this.resolveAlias(type);
35474
35528
  if (!this.isMachineProviderEnabled(providerType)) return "disabled";
35475
- const availability = this.providerAvailability.get(providerType);
35529
+ const availability = this.getEffectiveProviderAvailability(providerType);
35476
35530
  if (!availability) return "enabled_unchecked";
35477
35531
  return availability.installed ? "detected" : "not_detected";
35478
35532
  }
@@ -35600,7 +35654,7 @@ var init_provider_loader = __esm({
35600
35654
  }
35601
35655
  getAvailableProviderInfos() {
35602
35656
  return this.getAll().map((provider) => {
35603
- const availability = this.providerAvailability.get(provider.type);
35657
+ const availability = this.getEffectiveProviderAvailability(provider.type);
35604
35658
  const enabled = this.isMachineProviderEnabled(provider.type);
35605
35659
  const machineConfig = this.getMachineProviderConfig(provider.type);
35606
35660
  return {
@@ -56119,7 +56173,7 @@ var init_adhdev_daemon = __esm({
56119
56173
  init_version();
56120
56174
  init_src();
56121
56175
  init_runtime_defaults();
56122
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.32" });
56176
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.33" });
56123
56177
  AdhdevDaemon = class _AdhdevDaemon {
56124
56178
  localHttpServer = null;
56125
56179
  localWss = null;