@equationalapplications/core-llm-wiki 9.18.0 → 9.18.1

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
@@ -6810,6 +6810,14 @@ var DEFAULT_MAX_TOTAL_CHARS = 5e6;
6810
6810
  function limitOr(value, fallback) {
6811
6811
  return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.floor(value) : fallback;
6812
6812
  }
6813
+ function listStoredSourcesSql(prefix) {
6814
+ return `SELECT d.source_ref, d.source_hash, d.char_count, d.created_at,
6815
+ (SELECT COUNT(*) FROM ${prefix}source_passages p
6816
+ WHERE p.document_id = d.id AND +p.entity_id = d.entity_id) AS passage_count
6817
+ FROM ${prefix}source_documents d
6818
+ WHERE d.entity_id = ?
6819
+ ORDER BY d.source_ref COLLATE BINARY`;
6820
+ }
6813
6821
  var SourceStoreService = class {
6814
6822
  constructor(db, prefix, options, jobManager) {
6815
6823
  this.db = db;
@@ -6888,15 +6896,7 @@ var SourceStoreService = class {
6888
6896
  }
6889
6897
  /** Spec §4/§7: full store listing, including sources stored with no ingest. */
6890
6898
  async listStoredSources(entityId) {
6891
- const rows = await this.db.getAllAsync(
6892
- `SELECT d.source_ref, d.source_hash, d.char_count, d.created_at,
6893
- (SELECT COUNT(*) FROM ${this.prefix}source_passages p
6894
- WHERE p.entity_id = d.entity_id AND p.document_id = d.id) AS passage_count
6895
- FROM ${this.prefix}source_documents d
6896
- WHERE d.entity_id = ?
6897
- ORDER BY d.source_ref COLLATE BINARY`,
6898
- [entityId]
6899
- );
6899
+ const rows = await this.db.getAllAsync(listStoredSourcesSql(this.prefix), [entityId]);
6900
6900
  return rows.map((r) => ({
6901
6901
  sourceRef: r.source_ref,
6902
6902
  sourceHash: r.source_hash,