@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.
@@ -221,6 +221,7 @@ export declare class ProviderLoader {
221
221
  getMachineProviderConfig(type: string): MachineProviderConfig;
222
222
  setMachineProviderConfig(type: string, patch: Partial<MachineProviderConfig>): boolean;
223
223
  setMachineProviderEnabled(type: string, enabled: boolean): boolean;
224
+ private getEffectiveProviderAvailability;
224
225
  getMachineProviderStatus(type: string): ProviderMachineStatus;
225
226
  getSpawnArgs(type: string, fallback?: string[]): string[];
226
227
  private parseArgsSetting;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/session-host-core",
3
- "version": "0.9.32",
3
+ "version": "0.9.33",
4
4
  "description": "ADHDev local session host core \u2014 session registry, protocol, buffers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.32",
3
+ "version": "0.9.33",
4
4
  "description": "ADHDev daemon core \u2014 CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -297,6 +297,36 @@ function toHistoryPersistedMessages(messages: ChatMessage[]): Array<{
297
297
  }));
298
298
  }
299
299
 
300
+ function findLastMessageIndexBySignature(messages: ChatMessage[], signature: string): number {
301
+ if (!signature) return -1;
302
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
303
+ if (getChatMessageSignature(messages[index]) === signature) {
304
+ return index;
305
+ }
306
+ }
307
+ return -1;
308
+ }
309
+
310
+ function buildBoundedTailSync(messages: ChatMessage[], cursor: Required<ReadChatCursor>): {
311
+ syncMode: ReadChatSyncMode;
312
+ replaceFrom: number;
313
+ messages: ChatMessage[];
314
+ totalMessages: number;
315
+ lastMessageSignature: string;
316
+ } {
317
+ const totalMessages = messages.length;
318
+ const tailMessages = cursor.tailLimit > 0 && totalMessages > cursor.tailLimit
319
+ ? messages.slice(-cursor.tailLimit)
320
+ : messages;
321
+ return {
322
+ syncMode: 'full',
323
+ replaceFrom: 0,
324
+ messages: tailMessages,
325
+ totalMessages,
326
+ lastMessageSignature: getChatMessageSignature(messages[totalMessages - 1]),
327
+ };
328
+ }
329
+
300
330
  function computeReadChatSync(messages: ChatMessage[], cursor: Required<ReadChatCursor>): {
301
331
  syncMode: ReadChatSyncMode;
302
332
  replaceFrom: number;
@@ -338,6 +368,16 @@ function computeReadChatSync(messages: ChatMessage[], cursor: Required<ReadChatC
338
368
  };
339
369
  }
340
370
 
371
+ if (cursor.tailLimit > 0 && knownSignature === lastMessageSignature) {
372
+ return {
373
+ syncMode: 'noop',
374
+ replaceFrom: totalMessages,
375
+ messages: [],
376
+ totalMessages,
377
+ lastMessageSignature,
378
+ };
379
+ }
380
+
341
381
  if (knownMessageCount < totalMessages) {
342
382
  const anchorSignature = getChatMessageSignature(messages[knownMessageCount - 1]);
343
383
  if (anchorSignature === knownSignature) {
@@ -349,6 +389,20 @@ function computeReadChatSync(messages: ChatMessage[], cursor: Required<ReadChatC
349
389
  lastMessageSignature,
350
390
  };
351
391
  }
392
+
393
+ if (cursor.tailLimit > 0) {
394
+ const signatureIndex = findLastMessageIndexBySignature(messages, knownSignature);
395
+ if (signatureIndex >= 0) {
396
+ return {
397
+ syncMode: 'append',
398
+ replaceFrom: knownMessageCount,
399
+ messages: messages.slice(signatureIndex + 1),
400
+ totalMessages,
401
+ lastMessageSignature,
402
+ };
403
+ }
404
+ return buildBoundedTailSync(messages, cursor);
405
+ }
352
406
  }
353
407
 
354
408
  const replaceFrom = Math.max(0, Math.min(knownMessageCount - 1, totalMessages));
@@ -653,10 +653,26 @@ export class ProviderLoader {
653
653
  return this.setMachineProviderConfig(type, { enabled });
654
654
  }
655
655
 
656
+ private getEffectiveProviderAvailability(type: string): ProviderAvailabilityState | undefined {
657
+ const providerType = this.resolveAlias(type);
658
+ const availability = this.providerAvailability.get(providerType);
659
+ if (availability) return availability;
660
+
661
+ const machineConfig = this.getMachineProviderConfig(providerType);
662
+ const lastDetection = machineConfig.lastDetection;
663
+ if (!lastDetection) return undefined;
664
+ return {
665
+ installed: lastDetection.ok === true,
666
+ detectedPath: typeof lastDetection.path === 'string' && lastDetection.path.trim()
667
+ ? lastDetection.path.trim()
668
+ : null,
669
+ };
670
+ }
671
+
656
672
  getMachineProviderStatus(type: string): ProviderMachineStatus {
657
673
  const providerType = this.resolveAlias(type);
658
674
  if (!this.isMachineProviderEnabled(providerType)) return 'disabled';
659
- const availability = this.providerAvailability.get(providerType);
675
+ const availability = this.getEffectiveProviderAvailability(providerType);
660
676
  if (!availability) return 'enabled_unchecked';
661
677
  return availability.installed ? 'detected' : 'not_detected';
662
678
  }
@@ -792,7 +808,7 @@ export class ProviderLoader {
792
808
 
793
809
  getAvailableProviderInfos(): Array<ProviderModule & { installed?: boolean; detectedPath?: string | null; enabled: boolean; machineStatus: ProviderMachineStatus; lastDetection?: MachineProviderCheckResult; lastVerification?: MachineProviderCheckResult }> {
794
810
  return this.getAll().map((provider) => {
795
- const availability = this.providerAvailability.get(provider.type);
811
+ const availability = this.getEffectiveProviderAvailability(provider.type);
796
812
  const enabled = this.isMachineProviderEnabled(provider.type);
797
813
  const machineConfig = this.getMachineProviderConfig(provider.type);
798
814
  return {