@adhdev/daemon-core 0.9.82-rc.262 → 0.9.82-rc.264

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.
@@ -676,6 +676,25 @@ export class MeshRuntimeStore {
676
676
  this.db.prepare(`DELETE FROM mesh_direct_dispatches WHERE mesh_id = ?`).run(meshId);
677
677
  }
678
678
 
679
+ /**
680
+ * Delete specific direct dispatch rows by taskId for a mesh. Used by the staleDirect prune
681
+ * path to remove orphaned/terminal dispatch records whose node/session is no longer in the
682
+ * live mesh. Returns the number of rows actually deleted. No-op for an empty taskId list.
683
+ */
684
+ deleteDirectDispatchesByTaskId(meshId: string, taskIds: string[]): number {
685
+ const ids = (taskIds || []).map(id => typeof id === 'string' ? id.trim() : '').filter(Boolean);
686
+ if (!ids.length) return 0;
687
+ const stmt = this.db.prepare(`DELETE FROM mesh_direct_dispatches WHERE mesh_id = ? AND task_id = ?`);
688
+ let deleted = 0;
689
+ const run = this.db.transaction((rows: string[]) => {
690
+ for (const taskId of rows) {
691
+ deleted += stmt.run(meshId, taskId).changes;
692
+ }
693
+ });
694
+ run(ids);
695
+ return deleted;
696
+ }
697
+
679
698
  markStaleDirectDispatches(meshId: string, olderThanMs: number): void {
680
699
  const cutoff = new Date(Date.now() - olderThanMs).toISOString();
681
700
  const now = new Date().toISOString();
@@ -750,6 +750,19 @@ export function markStaleDirectDispatches(meshId: string, olderThanMs = 60 * 60_
750
750
  } catch { /* best-effort */ }
751
751
  }
752
752
 
753
+ /**
754
+ * Delete specific direct dispatch rows by taskId. Returns the number of rows deleted.
755
+ * Used by the staleDirect prune path to evict orphaned/terminal dispatch records from the
756
+ * active staleDirect surface while leaving the append-only mesh ledger (audit history) intact.
757
+ */
758
+ export function deleteDirectDispatchesByTaskId(meshId: string, taskIds: string[]): number {
759
+ try {
760
+ return MeshRuntimeStore.getInstance().deleteDirectDispatchesByTaskId(meshId, taskIds);
761
+ } catch {
762
+ return 0;
763
+ }
764
+ }
765
+
753
766
  export type MeshToolCallRateResult = { rateLimitExceeded: boolean; callsInWindow: number; advisory: string | null };
754
767
 
755
768
  /**