@edihasaj/recall 0.8.13 → 0.8.16

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.
Files changed (51) hide show
  1. package/dist/{chunk-JPHSGWSI.js → chunk-6I5U6KS3.js} +10 -10
  2. package/dist/{chunk-6CSJD45G.js → chunk-74MS4JSV.js} +15 -15
  3. package/dist/{chunk-FIWV6K57.js → chunk-C6YBSU6B.js} +15 -15
  4. package/dist/{chunk-CQZVFS3P.js → chunk-K6AFGQWR.js} +2 -2
  5. package/dist/{chunk-GLQOAY5O.js → chunk-KG7YFARS.js} +6 -6
  6. package/dist/{chunk-R4G62MKZ.js → chunk-M7OKBKKU.js} +8 -2
  7. package/dist/{chunk-R4G62MKZ.js.map → chunk-M7OKBKKU.js.map} +1 -1
  8. package/dist/{chunk-MIRCNPUN.js → chunk-NAYZL5XI.js} +8 -8
  9. package/dist/{chunk-TPCWQS6Q.js → chunk-O4KCMCJG.js} +326 -3
  10. package/dist/chunk-O4KCMCJG.js.map +1 -0
  11. package/dist/{chunk-XRM6FCWH.js → chunk-SRRPUFXI.js} +14 -14
  12. package/dist/{chunk-33KM4YYX.js → chunk-ZBIJDXA7.js} +7 -7
  13. package/dist/{cleanup-6OK2DCUA.js → cleanup-HWQCVPY4.js} +6 -5
  14. package/dist/cli.js +33 -27
  15. package/dist/cli.js.map +1 -1
  16. package/dist/daemon.js +97 -41
  17. package/dist/daemon.js.map +1 -1
  18. package/dist/{dispatcher-2Z27VP5Q.js → dispatcher-RU25CZK3.js} +6 -5
  19. package/dist/{embeddings-5ARZAEM5.js → embeddings-LNMNKWB7.js} +3 -3
  20. package/dist/{ingest-55ISNXYX.js → ingest-QSOE5XJZ.js} +5 -6
  21. package/dist/mcp.js +10 -10
  22. package/dist/{memory-value-56GK4AC6.js → memory-value-GH67CBQP.js} +6 -5
  23. package/dist/{quality-IXRBBLYF.js → quality-PZ36JND4.js} +7 -6
  24. package/dist/retrieval-HIE5MASN.js +13 -0
  25. package/dist/{store-QLWSC7S4.js → store-OPRTGS73.js} +4 -2
  26. package/dist/{tasks-OZ3IRHL5.js → tasks-LOZ7XWON.js} +6 -5
  27. package/dist/webui/assets/{index-CiEPavoy.js → index-BaaGKdcd.js} +242 -242
  28. package/dist/webui/assets/{index-CiEPavoy.js.map → index-BaaGKdcd.js.map} +1 -1
  29. package/dist/webui/index.html +1 -1
  30. package/package.json +1 -1
  31. package/dist/chunk-FKZ7IDIY.js +0 -235
  32. package/dist/chunk-FKZ7IDIY.js.map +0 -1
  33. package/dist/chunk-TPCWQS6Q.js.map +0 -1
  34. package/dist/retrieval-M566ZUK5.js +0 -13
  35. /package/dist/{chunk-JPHSGWSI.js.map → chunk-6I5U6KS3.js.map} +0 -0
  36. /package/dist/{chunk-6CSJD45G.js.map → chunk-74MS4JSV.js.map} +0 -0
  37. /package/dist/{chunk-FIWV6K57.js.map → chunk-C6YBSU6B.js.map} +0 -0
  38. /package/dist/{chunk-CQZVFS3P.js.map → chunk-K6AFGQWR.js.map} +0 -0
  39. /package/dist/{chunk-GLQOAY5O.js.map → chunk-KG7YFARS.js.map} +0 -0
  40. /package/dist/{chunk-MIRCNPUN.js.map → chunk-NAYZL5XI.js.map} +0 -0
  41. /package/dist/{chunk-XRM6FCWH.js.map → chunk-SRRPUFXI.js.map} +0 -0
  42. /package/dist/{chunk-33KM4YYX.js.map → chunk-ZBIJDXA7.js.map} +0 -0
  43. /package/dist/{cleanup-6OK2DCUA.js.map → cleanup-HWQCVPY4.js.map} +0 -0
  44. /package/dist/{dispatcher-2Z27VP5Q.js.map → dispatcher-RU25CZK3.js.map} +0 -0
  45. /package/dist/{embeddings-5ARZAEM5.js.map → embeddings-LNMNKWB7.js.map} +0 -0
  46. /package/dist/{ingest-55ISNXYX.js.map → ingest-QSOE5XJZ.js.map} +0 -0
  47. /package/dist/{memory-value-56GK4AC6.js.map → memory-value-GH67CBQP.js.map} +0 -0
  48. /package/dist/{quality-IXRBBLYF.js.map → quality-PZ36JND4.js.map} +0 -0
  49. /package/dist/{retrieval-M566ZUK5.js.map → retrieval-HIE5MASN.js.map} +0 -0
  50. /package/dist/{store-QLWSC7S4.js.map → store-OPRTGS73.js.map} +0 -0
  51. /package/dist/{tasks-OZ3IRHL5.js.map → tasks-LOZ7XWON.js.map} +0 -0
@@ -1,3 +1,6 @@
1
+ import {
2
+ desc
3
+ } from "./chunk-VT5VAEHY.js";
1
4
  import {
2
5
  appendEvidence,
3
6
  countDistinctCorrectionSessions,
@@ -12,10 +15,7 @@ import {
12
15
  promoteMemory,
13
16
  queryMemories,
14
17
  updateMemoryCaptureContext
15
- } from "./chunk-TPCWQS6Q.js";
16
- import {
17
- desc
18
- } from "./chunk-VT5VAEHY.js";
18
+ } from "./chunk-O4KCMCJG.js";
19
19
  import {
20
20
  CONFIDENCE,
21
21
  LlmCredentialError,
@@ -24,7 +24,11 @@ import {
24
24
  findSimilarRejectedExemplar,
25
25
  loadEmbeddingConfigFromEnv,
26
26
  queueMemoryEmbeddingSync
27
- } from "./chunk-GLQOAY5O.js";
27
+ } from "./chunk-KG7YFARS.js";
28
+ import {
29
+ hasProviderConfigured,
30
+ init_keychain
31
+ } from "./chunk-DNFKAHS6.js";
28
32
  import {
29
33
  activityEvents,
30
34
  and,
@@ -46,10 +50,6 @@ import {
46
50
  or,
47
51
  sql
48
52
  } from "./chunk-55KCGAOX.js";
49
- import {
50
- hasProviderConfigured,
51
- init_keychain
52
- } from "./chunk-DNFKAHS6.js";
53
53
 
54
54
  // src/maintenance/tasks.ts
55
55
  import { randomUUID as randomUUID5 } from "crypto";
@@ -3856,4 +3856,4 @@ export {
3856
3856
  processCorrection,
3857
3857
  processReviewFeedback
3858
3858
  };
3859
- //# sourceMappingURL=chunk-JPHSGWSI.js.map
3859
+ //# sourceMappingURL=chunk-6I5U6KS3.js.map
@@ -1,12 +1,6 @@
1
1
  import {
2
2
  graphQuery
3
- } from "./chunk-MIRCNPUN.js";
4
- import {
5
- getEntity,
6
- listEntities,
7
- listMemoryIdsForEntity,
8
- neighborsOf
9
- } from "./chunk-R4G62MKZ.js";
3
+ } from "./chunk-NAYZL5XI.js";
10
4
  import {
11
5
  captureCorrectionFallback,
12
6
  compileContext,
@@ -32,10 +26,7 @@ import {
32
26
  scanAndStore,
33
27
  sessionEndFallback,
34
28
  signalOutcomeFallback
35
- } from "./chunk-FIWV6K57.js";
36
- import {
37
- recordCompletionUseValueEventsSemantic
38
- } from "./chunk-33KM4YYX.js";
29
+ } from "./chunk-C6YBSU6B.js";
39
30
  import {
40
31
  DEFAULT_LEASE_SECONDS,
41
32
  TaskClaimConflictError,
@@ -56,18 +47,27 @@ import {
56
47
  releaseTask,
57
48
  rollbackMemory,
58
49
  submitTask
59
- } from "./chunk-JPHSGWSI.js";
50
+ } from "./chunk-6I5U6KS3.js";
51
+ import {
52
+ recordCompletionUseValueEventsSemantic
53
+ } from "./chunk-ZBIJDXA7.js";
60
54
  import {
61
55
  confirmMemory,
62
56
  demoteGlobalMemory,
63
57
  getMemory,
64
58
  queryMemories,
65
59
  rejectMemory
66
- } from "./chunk-TPCWQS6Q.js";
60
+ } from "./chunk-O4KCMCJG.js";
67
61
  import {
68
62
  loadEmbeddingConfigFromEnv,
69
63
  tagActivitySource
70
- } from "./chunk-GLQOAY5O.js";
64
+ } from "./chunk-KG7YFARS.js";
65
+ import {
66
+ getEntity,
67
+ listEntities,
68
+ listMemoryIdsForEntity,
69
+ neighborsOf
70
+ } from "./chunk-M7OKBKKU.js";
71
71
 
72
72
  // src/mcp/factory.ts
73
73
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -1197,4 +1197,4 @@ function createRecallMcpServer(db = initDb()) {
1197
1197
  export {
1198
1198
  createRecallMcpServer
1199
1199
  };
1200
- //# sourceMappingURL=chunk-6CSJD45G.js.map
1200
+ //# sourceMappingURL=chunk-74MS4JSV.js.map
@@ -1,10 +1,3 @@
1
- import {
2
- recordInjectionValueEvents,
3
- recordMemoryInjections,
4
- recordOutcomeValueEvent,
5
- resolveMemoryInjectionOutcome,
6
- textMatchScore
7
- } from "./chunk-33KM4YYX.js";
8
1
  import {
9
2
  computeHealthScore,
10
3
  evaluateScannedMemory,
@@ -13,7 +6,18 @@ import {
13
6
  recordAudit,
14
7
  redactSensitiveValue,
15
8
  seedScannedConfidence
16
- } from "./chunk-JPHSGWSI.js";
9
+ } from "./chunk-6I5U6KS3.js";
10
+ import {
11
+ recordInjectionValueEvents,
12
+ recordMemoryInjections,
13
+ recordOutcomeValueEvent,
14
+ resolveMemoryInjectionOutcome,
15
+ textMatchScore
16
+ } from "./chunk-ZBIJDXA7.js";
17
+ import {
18
+ asc,
19
+ desc
20
+ } from "./chunk-VT5VAEHY.js";
17
21
  import {
18
22
  activityEventDedupeKey,
19
23
  confirmMemory,
@@ -28,11 +32,7 @@ import {
28
32
  recordFeedback,
29
33
  rejectMemory,
30
34
  statusFromConfidence
31
- } from "./chunk-TPCWQS6Q.js";
32
- import {
33
- asc,
34
- desc
35
- } from "./chunk-VT5VAEHY.js";
35
+ } from "./chunk-O4KCMCJG.js";
36
36
  import {
37
37
  CONFIDENCE,
38
38
  RetrievalEvalCase,
@@ -48,7 +48,7 @@ import {
48
48
  queueMemoryEmbeddingSync,
49
49
  resolveProvider,
50
50
  tagActivitySource
51
- } from "./chunk-GLQOAY5O.js";
51
+ } from "./chunk-KG7YFARS.js";
52
52
  import {
53
53
  Column,
54
54
  Columns,
@@ -6500,4 +6500,4 @@ export {
6500
6500
  pruneMemories,
6501
6501
  formatPruneReport
6502
6502
  };
6503
- //# sourceMappingURL=chunk-FIWV6K57.js.map
6503
+ //# sourceMappingURL=chunk-C6YBSU6B.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  computeMemoryValueReport
3
- } from "./chunk-33KM4YYX.js";
3
+ } from "./chunk-ZBIJDXA7.js";
4
4
  import {
5
5
  desc
6
6
  } from "./chunk-VT5VAEHY.js";
@@ -180,4 +180,4 @@ export {
180
180
  diffQualitySnapshots,
181
181
  formatQualityReport
182
182
  };
183
- //# sourceMappingURL=chunk-CQZVFS3P.js.map
183
+ //# sourceMappingURL=chunk-K6AFGQWR.js.map
@@ -1,14 +1,14 @@
1
+ import {
2
+ getProviderConfig,
3
+ hasProviderConfigured,
4
+ init_keychain
5
+ } from "./chunk-DNFKAHS6.js";
1
6
  import {
2
7
  eq,
3
8
  llmUsage,
4
9
  memories,
5
10
  memoryEmbeddings
6
11
  } from "./chunk-55KCGAOX.js";
7
- import {
8
- getProviderConfig,
9
- hasProviderConfigured,
10
- init_keychain
11
- } from "./chunk-DNFKAHS6.js";
12
12
 
13
13
  // src/embeddings/embeddings.ts
14
14
  import { createHash as createHash2 } from "crypto";
@@ -2344,4 +2344,4 @@ export {
2344
2344
  findSemanticDuplicates,
2345
2345
  findSimilarRejectedExemplar
2346
2346
  };
2347
- //# sourceMappingURL=chunk-GLQOAY5O.js.map
2347
+ //# sourceMappingURL=chunk-KG7YFARS.js.map
@@ -263,6 +263,11 @@ function countRelations(db) {
263
263
  const row = db.select({ c: sql`count(*)` }).from(entityRelations).get();
264
264
  return Number(row?.c ?? 0);
265
265
  }
266
+ function clearGraph(db) {
267
+ db.delete(memoryEntities).run();
268
+ db.delete(entityRelations).run();
269
+ db.delete(entities).run();
270
+ }
266
271
 
267
272
  export {
268
273
  isPlausibleEntityName,
@@ -277,6 +282,7 @@ export {
277
282
  neighborsOf,
278
283
  listAllRelations,
279
284
  countEntities,
280
- countRelations
285
+ countRelations,
286
+ clearGraph
281
287
  };
282
- //# sourceMappingURL=chunk-R4G62MKZ.js.map
288
+ //# sourceMappingURL=chunk-M7OKBKKU.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graph/store.ts","../src/graph/normalize.ts"],"sourcesContent":["/**\n * Read/write layer for the knowledge graph tables. Pure DB operations —\n * no LLM calls, no business logic — so they're safe to call from any\n * code path (capture hook, dispatcher, scan, MCP tool).\n */\nimport { randomUUID } from \"node:crypto\";\nimport { and, eq, inArray, like, or, sql } from \"drizzle-orm\";\nimport type { RecallDb } from \"../db/client.js\";\nimport { entities, entityRelations, memoryEntities } from \"../db/schema.js\";\nimport { normalizeName, type EntityKind } from \"./normalize.js\";\n\nexport type RelationType =\n | \"uses\"\n | \"replaces\"\n | \"conflicts_with\"\n | \"tested_by\"\n | \"depends_on\"\n | \"references\"\n | \"part_of\";\n\nexport interface EntityRow {\n id: string;\n kind: EntityKind;\n name: string;\n normalized_name: string;\n repo: string | null;\n description: string | null;\n mention_count: number;\n first_seen_memory_id: string | null;\n created_at: string;\n updated_at: string;\n}\n\nexport interface EntityRelationRow {\n id: string;\n source_entity_id: string;\n target_entity_id: string;\n relation_type: RelationType;\n source_memory_id: string | null;\n confidence: number;\n created_at: string;\n}\n\nexport interface UpsertEntityInput {\n kind: EntityKind;\n name: string;\n repo?: string | null;\n description?: string | null;\n first_seen_memory_id?: string | null;\n}\n\n/**\n * Insert or look up an entity by (kind, normalized_name, repo). Returns the\n * canonical row. Increments mention_count on every call so we can rank\n * entities by how often the codebase mentions them.\n */\nexport function upsertEntity(db: RecallDb, input: UpsertEntityInput): EntityRow {\n const normalized = normalizeName(input.kind, input.name);\n const repo = input.repo ?? null;\n const now = new Date().toISOString();\n\n const existing = findEntityByNormalized(db, input.kind, normalized, repo);\n if (existing) {\n db.update(entities)\n .set({\n mention_count: existing.mention_count + 1,\n updated_at: now,\n // Backfill description / first_seen if not previously set.\n description: existing.description ?? input.description ?? null,\n first_seen_memory_id: existing.first_seen_memory_id ?? input.first_seen_memory_id ?? null,\n })\n .where(eq(entities.id, existing.id))\n .run();\n return {\n ...existing,\n mention_count: existing.mention_count + 1,\n updated_at: now,\n description: existing.description ?? input.description ?? null,\n first_seen_memory_id: existing.first_seen_memory_id ?? input.first_seen_memory_id ?? null,\n };\n }\n\n const id = randomUUID();\n db.insert(entities)\n .values({\n id,\n kind: input.kind,\n name: input.name.trim(),\n normalized_name: normalized,\n repo,\n description: input.description ?? null,\n first_seen_memory_id: input.first_seen_memory_id ?? null,\n mention_count: 1,\n created_at: now,\n updated_at: now,\n })\n .run();\n return {\n id,\n kind: input.kind,\n name: input.name.trim(),\n normalized_name: normalized,\n repo,\n description: input.description ?? null,\n mention_count: 1,\n first_seen_memory_id: input.first_seen_memory_id ?? null,\n created_at: now,\n updated_at: now,\n };\n}\n\nexport function findEntityByNormalized(\n db: RecallDb,\n kind: EntityKind,\n normalized: string,\n repo: string | null,\n): EntityRow | null {\n const row = db\n .select()\n .from(entities)\n .where(\n and(\n eq(entities.kind, kind),\n eq(entities.normalized_name, normalized),\n repo === null\n ? sql`${entities.repo} IS NULL`\n : eq(entities.repo, repo),\n ),\n )\n .get();\n return (row as EntityRow | undefined) ?? null;\n}\n\nexport function getEntity(db: RecallDb, id: string): EntityRow | null {\n const row = db.select().from(entities).where(eq(entities.id, id)).get();\n return (row as EntityRow | undefined) ?? null;\n}\n\nexport interface ListEntitiesOptions {\n repo?: string;\n kind?: EntityKind;\n search?: string;\n limit?: number;\n offset?: number;\n}\n\nexport function listEntities(db: RecallDb, opts: ListEntitiesOptions = {}): EntityRow[] {\n const conditions = [] as Array<ReturnType<typeof eq> | ReturnType<typeof or>>;\n if (opts.repo) conditions.push(eq(entities.repo, opts.repo));\n if (opts.kind) conditions.push(eq(entities.kind, opts.kind));\n if (opts.search) {\n // Push the contains-match into SQL so LIMIT applies post-filter; the\n // previous in-memory filter only saw the top-N by mention_count and\n // missed long-tail matches entirely.\n const needle = `%${opts.search.toLowerCase()}%`;\n conditions.push(\n or(\n like(entities.normalized_name, needle),\n like(sql`lower(${entities.name})`, needle),\n )!,\n );\n }\n const where = conditions.length === 1 ? conditions[0] : conditions.length > 1 ? and(...conditions) : undefined;\n const builder = where\n ? db.select().from(entities).where(where)\n : db.select().from(entities);\n return builder\n .orderBy(sql`${entities.mention_count} DESC`)\n .limit(opts.limit ?? 200)\n .offset(opts.offset ?? 0)\n .all() as EntityRow[];\n}\n\nexport interface LinkMemoryEntityInput {\n memory_id: string;\n entity_id: string;\n source: \"heuristic\" | \"llm\" | \"manual\";\n weight?: number;\n}\n\n/** Idempotent: links a memory to an entity, no-op if the edge already exists. */\nexport function linkMemoryToEntity(db: RecallDb, input: LinkMemoryEntityInput): void {\n const existing = db\n .select({ id: memoryEntities.id })\n .from(memoryEntities)\n .where(\n and(\n eq(memoryEntities.memory_id, input.memory_id),\n eq(memoryEntities.entity_id, input.entity_id),\n ),\n )\n .get();\n if (existing) return;\n db.insert(memoryEntities)\n .values({\n id: randomUUID(),\n memory_id: input.memory_id,\n entity_id: input.entity_id,\n source: input.source,\n weight: input.weight ?? 1,\n created_at: new Date().toISOString(),\n })\n .run();\n}\n\nexport function listEntitiesForMemory(db: RecallDb, memoryId: string): EntityRow[] {\n return db\n .select({\n id: entities.id,\n kind: entities.kind,\n name: entities.name,\n normalized_name: entities.normalized_name,\n repo: entities.repo,\n description: entities.description,\n mention_count: entities.mention_count,\n first_seen_memory_id: entities.first_seen_memory_id,\n created_at: entities.created_at,\n updated_at: entities.updated_at,\n })\n .from(memoryEntities)\n .innerJoin(entities, eq(entities.id, memoryEntities.entity_id))\n .where(eq(memoryEntities.memory_id, memoryId))\n .all() as EntityRow[];\n}\n\nexport function listMemoryIdsForEntity(db: RecallDb, entityId: string): string[] {\n const rows = db\n .select({ memory_id: memoryEntities.memory_id })\n .from(memoryEntities)\n .where(eq(memoryEntities.entity_id, entityId))\n .all();\n return rows.map((r) => r.memory_id);\n}\n\nexport interface UpsertRelationInput {\n source_entity_id: string;\n target_entity_id: string;\n relation_type: RelationType;\n source_memory_id?: string | null;\n confidence?: number;\n}\n\n/** Idempotent on (source, target, relation_type, source_memory_id). */\nexport function upsertRelation(db: RecallDb, input: UpsertRelationInput): EntityRelationRow {\n const sourceMem = input.source_memory_id ?? null;\n const existing = db\n .select()\n .from(entityRelations)\n .where(\n and(\n eq(entityRelations.source_entity_id, input.source_entity_id),\n eq(entityRelations.target_entity_id, input.target_entity_id),\n eq(entityRelations.relation_type, input.relation_type),\n sourceMem === null\n ? sql`${entityRelations.source_memory_id} IS NULL`\n : eq(entityRelations.source_memory_id, sourceMem),\n ),\n )\n .get() as EntityRelationRow | undefined;\n if (existing) {\n if (input.confidence !== undefined && input.confidence > existing.confidence) {\n db.update(entityRelations)\n .set({ confidence: input.confidence })\n .where(eq(entityRelations.id, existing.id))\n .run();\n return { ...existing, confidence: input.confidence };\n }\n return existing;\n }\n const id = randomUUID();\n const now = new Date().toISOString();\n db.insert(entityRelations)\n .values({\n id,\n source_entity_id: input.source_entity_id,\n target_entity_id: input.target_entity_id,\n relation_type: input.relation_type,\n source_memory_id: sourceMem,\n confidence: input.confidence ?? 0.6,\n created_at: now,\n })\n .run();\n return {\n id,\n source_entity_id: input.source_entity_id,\n target_entity_id: input.target_entity_id,\n relation_type: input.relation_type,\n source_memory_id: sourceMem,\n confidence: input.confidence ?? 0.6,\n created_at: now,\n };\n}\n\nexport function neighborsOf(\n db: RecallDb,\n entityId: string,\n options: { hops?: number; relationTypes?: RelationType[] } = {},\n): { entities: EntityRow[]; relations: EntityRelationRow[] } {\n const maxHops = Math.max(1, Math.min(5, options.hops ?? 1));\n const visited = new Set<string>([entityId]);\n let frontier = [entityId];\n const collectedRelations = new Map<string, EntityRelationRow>();\n\n for (let hop = 0; hop < maxHops; hop++) {\n if (frontier.length === 0) break;\n const next: string[] = [];\n const relationFilter = options.relationTypes;\n const outgoing = db\n .select()\n .from(entityRelations)\n .where(\n relationFilter && relationFilter.length > 0\n ? and(\n inArray(entityRelations.source_entity_id, frontier),\n inArray(entityRelations.relation_type, relationFilter),\n )\n : inArray(entityRelations.source_entity_id, frontier),\n )\n .all() as EntityRelationRow[];\n const incoming = db\n .select()\n .from(entityRelations)\n .where(\n relationFilter && relationFilter.length > 0\n ? and(\n inArray(entityRelations.target_entity_id, frontier),\n inArray(entityRelations.relation_type, relationFilter),\n )\n : inArray(entityRelations.target_entity_id, frontier),\n )\n .all() as EntityRelationRow[];\n\n for (const rel of [...outgoing, ...incoming]) {\n collectedRelations.set(rel.id, rel);\n for (const candidate of [rel.source_entity_id, rel.target_entity_id]) {\n if (!visited.has(candidate)) {\n visited.add(candidate);\n next.push(candidate);\n }\n }\n }\n frontier = next;\n }\n\n const entityRows = visited.size === 0\n ? []\n : (db\n .select()\n .from(entities)\n .where(inArray(entities.id, Array.from(visited)))\n .all() as EntityRow[]);\n\n return {\n entities: entityRows,\n relations: Array.from(collectedRelations.values()),\n };\n}\n\n/**\n * List every relation in the graph, optionally restricted to relations\n * whose source AND target entities both belong to the given repo. Used by\n * the WebUI to render the whole graph at once (no seed required).\n */\nexport function listAllRelations(\n db: RecallDb,\n opts: { repo?: string; limit?: number } = {},\n): EntityRelationRow[] {\n const limit = Math.min(Math.max(opts.limit ?? 2000, 1), 10_000);\n if (!opts.repo) {\n return db\n .select()\n .from(entityRelations)\n .limit(limit)\n .all() as EntityRelationRow[];\n }\n // Filter both endpoints to entities in the repo. Two-step: collect ids,\n // then pick relations whose endpoints are both inside that set.\n const repoEntityIds = db\n .select({ id: entities.id })\n .from(entities)\n .where(eq(entities.repo, opts.repo))\n .all()\n .map((r) => r.id);\n if (repoEntityIds.length === 0) return [];\n const idSet = new Set(repoEntityIds);\n const all = db\n .select()\n .from(entityRelations)\n .where(\n and(\n inArray(entityRelations.source_entity_id, repoEntityIds),\n inArray(entityRelations.target_entity_id, repoEntityIds),\n ),\n )\n .limit(limit)\n .all() as EntityRelationRow[];\n return all.filter(\n (r) => idSet.has(r.source_entity_id) && idSet.has(r.target_entity_id),\n );\n}\n\nexport function countEntities(db: RecallDb): number {\n const row = db\n .select({ c: sql<number>`count(*)` })\n .from(entities)\n .get();\n return Number(row?.c ?? 0);\n}\n\nexport function countRelations(db: RecallDb): number {\n const row = db\n .select({ c: sql<number>`count(*)` })\n .from(entityRelations)\n .get();\n return Number(row?.c ?? 0);\n}\n","/**\n * Canonical-form helpers for entity dedup. Two entities with the same\n * (kind, normalizedName, repo) collapse into one node.\n *\n * Normalization rules are conservative on purpose — we'd rather have a\n * duplicate than merge two semantically distinct things. Aggressive\n * merging belongs in a maintenance pass that can be reviewed.\n */\n\nexport type EntityKind =\n | \"file\"\n | \"function\"\n | \"library\"\n | \"tool\"\n | \"concept\"\n | \"repo_path\"\n | \"command\"\n | \"url\";\n\nexport function normalizeName(kind: EntityKind, raw: string): string {\n const trimmed = raw.trim();\n switch (kind) {\n case \"file\":\n case \"repo_path\":\n // Posix-style paths, no leading slash, no trailing slash.\n return trimmed\n .replace(/\\\\/g, \"/\")\n .replace(/^[./]+/, \"\")\n .replace(/\\/+$/, \"\")\n .toLowerCase();\n case \"function\":\n // foo() / Class.method / obj.method — keep the dotted form, drop parens/args.\n return trimmed\n .replace(/\\(.*\\)/, \"\")\n .replace(/\\s+/g, \"\")\n .toLowerCase();\n case \"library\":\n case \"tool\":\n case \"command\":\n // package names / CLI names: lowercase, strip @scope leading-only if present\n // but keep `@scope/name` distinct from `name`.\n return trimmed.toLowerCase();\n case \"url\":\n try {\n const u = new URL(trimmed);\n return `${u.hostname.toLowerCase()}${u.pathname.replace(/\\/+$/, \"\")}`;\n } catch {\n return trimmed.toLowerCase();\n }\n case \"concept\":\n default:\n return trimmed.toLowerCase().replace(/\\s+/g, \" \");\n }\n}\n\nexport function isPlausibleEntityName(kind: EntityKind, name: string): boolean {\n const n = name.trim();\n if (n.length === 0 || n.length > 200) return false;\n // Filter common false positives that look like identifiers but aren't.\n if (/^[0-9]+$/.test(n)) return false;\n if (kind === \"concept\" && n.split(/\\s+/).length > 8) return false;\n // Single-letter \"library\" tokens are almost always noise.\n if ((kind === \"library\" || kind === \"tool\") && n.length < 2) return false;\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;AAKA,SAAS,kBAAkB;;;ACcpB,SAAS,cAAc,MAAkB,KAAqB;AACnE,QAAM,UAAU,IAAI,KAAK;AACzB,UAAQ,MAAM;AAAA,IACZ,KAAK;AAAA,IACL,KAAK;AAEH,aAAO,QACJ,QAAQ,OAAO,GAAG,EAClB,QAAQ,UAAU,EAAE,EACp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J,IAAI,CAAC,MAAM,EAAE,EAAE;AAClB,MAAI,cAAc,WAAW,EAAG,QAAO,CAAC;AACxC,QAAM,QAAQ,IAAI,IAAI,aAAa;AACnC,QAAM,MAAM,GACT,OAAO,EACP,KAAK,eAAe,EACpB;AAAA,IACC;AAAA,MACE,QAAQ,gBAAgB,kBAAkB,aAAa;AAAA,MACvD,QAAQ,gBAAgB,kBAAkB,aAAa;AAAA,IACzD;AAAA,EACF,EACC,MAAM,KAAK,EACX,IAAI;AACP,SAAO,IAAI;AAAA,IACT,CAAC,MAAM,MAAM,IAAI,EAAE,gBAAgB,KAAK,MAAM,IAAI,EAAE,gBAAgB;AAAA,EACtE;AACF;AAEO,SAAS,cAAc,IAAsB;AAClD,QAAM,MAAM,GACT,OAAO,EAAE,GAAG,cAAsB,CAAC,EACnC,KAAK,QAAQ,EACb,IAAI;AACP,SAAO,OAAO,KAAK,KAAK,CAAC;AAC3B;AAEO,SAAS,eAAe,IAAsB;AACnD,QAAM,MAAM,GACT,OAAO,EAAE,GAAG,cAAsB,CAAC,EACnC,KAAK,eAAe,EACpB,IAAI;AACP,SAAO,OAAO,KAAK,KAAK,CAAC;AAC3B;","names":[]}
1
+ {"version":3,"sources":["../src/graph/store.ts","../src/graph/normalize.ts"],"sourcesContent":["/**\n * Read/write layer for the knowledge graph tables. Pure DB operations —\n * no LLM calls, no business logic — so they're safe to call from any\n * code path (capture hook, dispatcher, scan, MCP tool).\n */\nimport { randomUUID } from \"node:crypto\";\nimport { and, eq, inArray, like, or, sql } from \"drizzle-orm\";\nimport type { RecallDb } from \"../db/client.js\";\nimport { entities, entityRelations, memoryEntities } from \"../db/schema.js\";\nimport { normalizeName, type EntityKind } from \"./normalize.js\";\n\nexport type RelationType =\n | \"uses\"\n | \"replaces\"\n | \"conflicts_with\"\n | \"tested_by\"\n | \"depends_on\"\n | \"references\"\n | \"part_of\";\n\nexport interface EntityRow {\n id: string;\n kind: EntityKind;\n name: string;\n normalized_name: string;\n repo: string | null;\n description: string | null;\n mention_count: number;\n first_seen_memory_id: string | null;\n created_at: string;\n updated_at: string;\n}\n\nexport interface EntityRelationRow {\n id: string;\n source_entity_id: string;\n target_entity_id: string;\n relation_type: RelationType;\n source_memory_id: string | null;\n confidence: number;\n created_at: string;\n}\n\nexport interface UpsertEntityInput {\n kind: EntityKind;\n name: string;\n repo?: string | null;\n description?: string | null;\n first_seen_memory_id?: string | null;\n}\n\n/**\n * Insert or look up an entity by (kind, normalized_name, repo). Returns the\n * canonical row. Increments mention_count on every call so we can rank\n * entities by how often the codebase mentions them.\n */\nexport function upsertEntity(db: RecallDb, input: UpsertEntityInput): EntityRow {\n const normalized = normalizeName(input.kind, input.name);\n const repo = input.repo ?? null;\n const now = new Date().toISOString();\n\n const existing = findEntityByNormalized(db, input.kind, normalized, repo);\n if (existing) {\n db.update(entities)\n .set({\n mention_count: existing.mention_count + 1,\n updated_at: now,\n // Backfill description / first_seen if not previously set.\n description: existing.description ?? input.description ?? null,\n first_seen_memory_id: existing.first_seen_memory_id ?? input.first_seen_memory_id ?? null,\n })\n .where(eq(entities.id, existing.id))\n .run();\n return {\n ...existing,\n mention_count: existing.mention_count + 1,\n updated_at: now,\n description: existing.description ?? input.description ?? null,\n first_seen_memory_id: existing.first_seen_memory_id ?? input.first_seen_memory_id ?? null,\n };\n }\n\n const id = randomUUID();\n db.insert(entities)\n .values({\n id,\n kind: input.kind,\n name: input.name.trim(),\n normalized_name: normalized,\n repo,\n description: input.description ?? null,\n first_seen_memory_id: input.first_seen_memory_id ?? null,\n mention_count: 1,\n created_at: now,\n updated_at: now,\n })\n .run();\n return {\n id,\n kind: input.kind,\n name: input.name.trim(),\n normalized_name: normalized,\n repo,\n description: input.description ?? null,\n mention_count: 1,\n first_seen_memory_id: input.first_seen_memory_id ?? null,\n created_at: now,\n updated_at: now,\n };\n}\n\nexport function findEntityByNormalized(\n db: RecallDb,\n kind: EntityKind,\n normalized: string,\n repo: string | null,\n): EntityRow | null {\n const row = db\n .select()\n .from(entities)\n .where(\n and(\n eq(entities.kind, kind),\n eq(entities.normalized_name, normalized),\n repo === null\n ? sql`${entities.repo} IS NULL`\n : eq(entities.repo, repo),\n ),\n )\n .get();\n return (row as EntityRow | undefined) ?? null;\n}\n\nexport function getEntity(db: RecallDb, id: string): EntityRow | null {\n const row = db.select().from(entities).where(eq(entities.id, id)).get();\n return (row as EntityRow | undefined) ?? null;\n}\n\nexport interface ListEntitiesOptions {\n repo?: string;\n kind?: EntityKind;\n search?: string;\n limit?: number;\n offset?: number;\n}\n\nexport function listEntities(db: RecallDb, opts: ListEntitiesOptions = {}): EntityRow[] {\n const conditions = [] as Array<ReturnType<typeof eq> | ReturnType<typeof or>>;\n if (opts.repo) conditions.push(eq(entities.repo, opts.repo));\n if (opts.kind) conditions.push(eq(entities.kind, opts.kind));\n if (opts.search) {\n // Push the contains-match into SQL so LIMIT applies post-filter; the\n // previous in-memory filter only saw the top-N by mention_count and\n // missed long-tail matches entirely.\n const needle = `%${opts.search.toLowerCase()}%`;\n conditions.push(\n or(\n like(entities.normalized_name, needle),\n like(sql`lower(${entities.name})`, needle),\n )!,\n );\n }\n const where = conditions.length === 1 ? conditions[0] : conditions.length > 1 ? and(...conditions) : undefined;\n const builder = where\n ? db.select().from(entities).where(where)\n : db.select().from(entities);\n return builder\n .orderBy(sql`${entities.mention_count} DESC`)\n .limit(opts.limit ?? 200)\n .offset(opts.offset ?? 0)\n .all() as EntityRow[];\n}\n\nexport interface LinkMemoryEntityInput {\n memory_id: string;\n entity_id: string;\n source: \"heuristic\" | \"llm\" | \"manual\";\n weight?: number;\n}\n\n/** Idempotent: links a memory to an entity, no-op if the edge already exists. */\nexport function linkMemoryToEntity(db: RecallDb, input: LinkMemoryEntityInput): void {\n const existing = db\n .select({ id: memoryEntities.id })\n .from(memoryEntities)\n .where(\n and(\n eq(memoryEntities.memory_id, input.memory_id),\n eq(memoryEntities.entity_id, input.entity_id),\n ),\n )\n .get();\n if (existing) return;\n db.insert(memoryEntities)\n .values({\n id: randomUUID(),\n memory_id: input.memory_id,\n entity_id: input.entity_id,\n source: input.source,\n weight: input.weight ?? 1,\n created_at: new Date().toISOString(),\n })\n .run();\n}\n\nexport function listEntitiesForMemory(db: RecallDb, memoryId: string): EntityRow[] {\n return db\n .select({\n id: entities.id,\n kind: entities.kind,\n name: entities.name,\n normalized_name: entities.normalized_name,\n repo: entities.repo,\n description: entities.description,\n mention_count: entities.mention_count,\n first_seen_memory_id: entities.first_seen_memory_id,\n created_at: entities.created_at,\n updated_at: entities.updated_at,\n })\n .from(memoryEntities)\n .innerJoin(entities, eq(entities.id, memoryEntities.entity_id))\n .where(eq(memoryEntities.memory_id, memoryId))\n .all() as EntityRow[];\n}\n\nexport function listMemoryIdsForEntity(db: RecallDb, entityId: string): string[] {\n const rows = db\n .select({ memory_id: memoryEntities.memory_id })\n .from(memoryEntities)\n .where(eq(memoryEntities.entity_id, entityId))\n .all();\n return rows.map((r) => r.memory_id);\n}\n\nexport interface UpsertRelationInput {\n source_entity_id: string;\n target_entity_id: string;\n relation_type: RelationType;\n source_memory_id?: string | null;\n confidence?: number;\n}\n\n/** Idempotent on (source, target, relation_type, source_memory_id). */\nexport function upsertRelation(db: RecallDb, input: UpsertRelationInput): EntityRelationRow {\n const sourceMem = input.source_memory_id ?? null;\n const existing = db\n .select()\n .from(entityRelations)\n .where(\n and(\n eq(entityRelations.source_entity_id, input.source_entity_id),\n eq(entityRelations.target_entity_id, input.target_entity_id),\n eq(entityRelations.relation_type, input.relation_type),\n sourceMem === null\n ? sql`${entityRelations.source_memory_id} IS NULL`\n : eq(entityRelations.source_memory_id, sourceMem),\n ),\n )\n .get() as EntityRelationRow | undefined;\n if (existing) {\n if (input.confidence !== undefined && input.confidence > existing.confidence) {\n db.update(entityRelations)\n .set({ confidence: input.confidence })\n .where(eq(entityRelations.id, existing.id))\n .run();\n return { ...existing, confidence: input.confidence };\n }\n return existing;\n }\n const id = randomUUID();\n const now = new Date().toISOString();\n db.insert(entityRelations)\n .values({\n id,\n source_entity_id: input.source_entity_id,\n target_entity_id: input.target_entity_id,\n relation_type: input.relation_type,\n source_memory_id: sourceMem,\n confidence: input.confidence ?? 0.6,\n created_at: now,\n })\n .run();\n return {\n id,\n source_entity_id: input.source_entity_id,\n target_entity_id: input.target_entity_id,\n relation_type: input.relation_type,\n source_memory_id: sourceMem,\n confidence: input.confidence ?? 0.6,\n created_at: now,\n };\n}\n\nexport function neighborsOf(\n db: RecallDb,\n entityId: string,\n options: { hops?: number; relationTypes?: RelationType[] } = {},\n): { entities: EntityRow[]; relations: EntityRelationRow[] } {\n const maxHops = Math.max(1, Math.min(5, options.hops ?? 1));\n const visited = new Set<string>([entityId]);\n let frontier = [entityId];\n const collectedRelations = new Map<string, EntityRelationRow>();\n\n for (let hop = 0; hop < maxHops; hop++) {\n if (frontier.length === 0) break;\n const next: string[] = [];\n const relationFilter = options.relationTypes;\n const outgoing = db\n .select()\n .from(entityRelations)\n .where(\n relationFilter && relationFilter.length > 0\n ? and(\n inArray(entityRelations.source_entity_id, frontier),\n inArray(entityRelations.relation_type, relationFilter),\n )\n : inArray(entityRelations.source_entity_id, frontier),\n )\n .all() as EntityRelationRow[];\n const incoming = db\n .select()\n .from(entityRelations)\n .where(\n relationFilter && relationFilter.length > 0\n ? and(\n inArray(entityRelations.target_entity_id, frontier),\n inArray(entityRelations.relation_type, relationFilter),\n )\n : inArray(entityRelations.target_entity_id, frontier),\n )\n .all() as EntityRelationRow[];\n\n for (const rel of [...outgoing, ...incoming]) {\n collectedRelations.set(rel.id, rel);\n for (const candidate of [rel.source_entity_id, rel.target_entity_id]) {\n if (!visited.has(candidate)) {\n visited.add(candidate);\n next.push(candidate);\n }\n }\n }\n frontier = next;\n }\n\n const entityRows = visited.size === 0\n ? []\n : (db\n .select()\n .from(entities)\n .where(inArray(entities.id, Array.from(visited)))\n .all() as EntityRow[]);\n\n return {\n entities: entityRows,\n relations: Array.from(collectedRelations.values()),\n };\n}\n\n/**\n * List every relation in the graph, optionally restricted to relations\n * whose source AND target entities both belong to the given repo. Used by\n * the WebUI to render the whole graph at once (no seed required).\n */\nexport function listAllRelations(\n db: RecallDb,\n opts: { repo?: string; limit?: number } = {},\n): EntityRelationRow[] {\n const limit = Math.min(Math.max(opts.limit ?? 2000, 1), 10_000);\n if (!opts.repo) {\n return db\n .select()\n .from(entityRelations)\n .limit(limit)\n .all() as EntityRelationRow[];\n }\n // Filter both endpoints to entities in the repo. Two-step: collect ids,\n // then pick relations whose endpoints are both inside that set.\n const repoEntityIds = db\n .select({ id: entities.id })\n .from(entities)\n .where(eq(entities.repo, opts.repo))\n .all()\n .map((r) => r.id);\n if (repoEntityIds.length === 0) return [];\n const idSet = new Set(repoEntityIds);\n const all = db\n .select()\n .from(entityRelations)\n .where(\n and(\n inArray(entityRelations.source_entity_id, repoEntityIds),\n inArray(entityRelations.target_entity_id, repoEntityIds),\n ),\n )\n .limit(limit)\n .all() as EntityRelationRow[];\n return all.filter(\n (r) => idSet.has(r.source_entity_id) && idSet.has(r.target_entity_id),\n );\n}\n\nexport function countEntities(db: RecallDb): number {\n const row = db\n .select({ c: sql<number>`count(*)` })\n .from(entities)\n .get();\n return Number(row?.c ?? 0);\n}\n\nexport function countRelations(db: RecallDb): number {\n const row = db\n .select({ c: sql<number>`count(*)` })\n .from(entityRelations)\n .get();\n return Number(row?.c ?? 0);\n}\n\n/**\n * Wipe all graph state (entities, relations, and memory→entity links). Used\n * by `graph backfill --rebuild` to regenerate the graph from scratch under\n * the current extraction rules, dropping entities that older/looser rules\n * produced (e.g. generic `pnpm build` command nodes).\n */\nexport function clearGraph(db: RecallDb): void {\n db.delete(memoryEntities).run();\n db.delete(entityRelations).run();\n db.delete(entities).run();\n}\n","/**\n * Canonical-form helpers for entity dedup. Two entities with the same\n * (kind, normalizedName, repo) collapse into one node.\n *\n * Normalization rules are conservative on purpose — we'd rather have a\n * duplicate than merge two semantically distinct things. Aggressive\n * merging belongs in a maintenance pass that can be reviewed.\n */\n\nexport type EntityKind =\n | \"file\"\n | \"function\"\n | \"library\"\n | \"tool\"\n | \"concept\"\n | \"repo_path\"\n | \"command\"\n | \"url\";\n\nexport function normalizeName(kind: EntityKind, raw: string): string {\n const trimmed = raw.trim();\n switch (kind) {\n case \"file\":\n case \"repo_path\":\n // Posix-style paths, no leading slash, no trailing slash.\n return trimmed\n .replace(/\\\\/g, \"/\")\n .replace(/^[./]+/, \"\")\n .replace(/\\/+$/, \"\")\n .toLowerCase();\n case \"function\":\n // foo() / Class.method / obj.method — keep the dotted form, drop parens/args.\n return trimmed\n .replace(/\\(.*\\)/, \"\")\n .replace(/\\s+/g, \"\")\n .toLowerCase();\n case \"library\":\n case \"tool\":\n case \"command\":\n // package names / CLI names: lowercase, strip @scope leading-only if present\n // but keep `@scope/name` distinct from `name`.\n return trimmed.toLowerCase();\n case \"url\":\n try {\n const u = new URL(trimmed);\n return `${u.hostname.toLowerCase()}${u.pathname.replace(/\\/+$/, \"\")}`;\n } catch {\n return trimmed.toLowerCase();\n }\n case \"concept\":\n default:\n return trimmed.toLowerCase().replace(/\\s+/g, \" \");\n }\n}\n\nexport function isPlausibleEntityName(kind: EntityKind, name: string): boolean {\n const n = name.trim();\n if (n.length === 0 || n.length > 200) return false;\n // Filter common false positives that look like identifiers but aren't.\n if (/^[0-9]+$/.test(n)) return false;\n if (kind === \"concept\" && n.split(/\\s+/).length > 8) return false;\n // Single-letter \"library\" tokens are almost always noise.\n if ((kind === \"library\" || kind === \"tool\") && n.length < 2) return false;\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;AAKA,SAAS,kBAAkB;;;ACcpB,SAAS,cAAc,MAAkB,KAAqB;AACnE,QAAM,UAAU,IAAI,KAAK;AACzB,UAAQ,MAAM;AAAA,IACZ,KAAK;AAAA,IACL,KAAK;AAEH,aAAO,QACJ,QAAQ,OAAO,GAAG,EAClB,QAAQ,UAAU,EAAE,EACpB,QAAQ,QAAQ,EAAE,EAClB,YAAY;AAAA,IACjB,KAAK;AAEH,aAAO,QACJ,Q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AC;AACxC,QAAM,QAAQ,IAAI,IAAI,aAAa;AACnC,QAAM,MAAM,GACT,OAAO,EACP,KAAK,eAAe,EACpB;AAAA,IACC;AAAA,MACE,QAAQ,gBAAgB,kBAAkB,aAAa;AAAA,MACvD,QAAQ,gBAAgB,kBAAkB,aAAa;AAAA,IACzD;AAAA,EACF,EACC,MAAM,KAAK,EACX,IAAI;AACP,SAAO,IAAI;AAAA,IACT,CAAC,MAAM,MAAM,IAAI,EAAE,gBAAgB,KAAK,MAAM,IAAI,EAAE,gBAAgB;AAAA,EACtE;AACF;AAEO,SAAS,cAAc,IAAsB;AAClD,QAAM,MAAM,GACT,OAAO,EAAE,GAAG,cAAsB,CAAC,EACnC,KAAK,QAAQ,EACb,IAAI;AACP,SAAO,OAAO,KAAK,KAAK,CAAC;AAC3B;AAEO,SAAS,eAAe,IAAsB;AACnD,QAAM,MAAM,GACT,OAAO,EAAE,GAAG,cAAsB,CAAC,EACnC,KAAK,eAAe,EACpB,IAAI;AACP,SAAO,OAAO,KAAK,KAAK,CAAC;AAC3B;AAQO,SAAS,WAAW,IAAoB;AAC7C,KAAG,OAAO,cAAc,EAAE,IAAI;AAC9B,KAAG,OAAO,eAAe,EAAE,IAAI;AAC/B,KAAG,OAAO,QAAQ,EAAE,IAAI;AAC1B;","names":[]}
@@ -1,15 +1,15 @@
1
- import {
2
- listEntitiesForMemory,
3
- listMemoryIdsForEntity,
4
- neighborsOf
5
- } from "./chunk-R4G62MKZ.js";
6
1
  import {
7
2
  getMemory
8
- } from "./chunk-TPCWQS6Q.js";
3
+ } from "./chunk-O4KCMCJG.js";
9
4
  import {
10
5
  hybridSearch,
11
6
  searchMemoryFtsIndex
12
- } from "./chunk-GLQOAY5O.js";
7
+ } from "./chunk-KG7YFARS.js";
8
+ import {
9
+ listEntitiesForMemory,
10
+ listMemoryIdsForEntity,
11
+ neighborsOf
12
+ } from "./chunk-M7OKBKKU.js";
13
13
 
14
14
  // src/graph/retrieval.ts
15
15
  var SEED_WEIGHT = 1;
@@ -120,4 +120,4 @@ async function graphQuery(db, query, embeddingConfig, options = {}) {
120
120
  export {
121
121
  graphQuery
122
122
  };
123
- //# sourceMappingURL=chunk-MIRCNPUN.js.map
123
+ //# sourceMappingURL=chunk-NAYZL5XI.js.map