@edihasaj/recall 0.8.15 → 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 (43) hide show
  1. package/dist/{chunk-JPHSGWSI.js → chunk-6I5U6KS3.js} +10 -10
  2. package/dist/{chunk-OHPGNDSH.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-A54CLR5Q.js → chunk-NAYZL5XI.js} +8 -8
  7. package/dist/{chunk-TPCWQS6Q.js → chunk-O4KCMCJG.js} +326 -3
  8. package/dist/chunk-O4KCMCJG.js.map +1 -0
  9. package/dist/{chunk-XRM6FCWH.js → chunk-SRRPUFXI.js} +14 -14
  10. package/dist/{chunk-33KM4YYX.js → chunk-ZBIJDXA7.js} +7 -7
  11. package/dist/{cleanup-6OK2DCUA.js → cleanup-HWQCVPY4.js} +6 -5
  12. package/dist/cli.js +25 -24
  13. package/dist/cli.js.map +1 -1
  14. package/dist/daemon.js +97 -41
  15. package/dist/daemon.js.map +1 -1
  16. package/dist/{dispatcher-2Z27VP5Q.js → dispatcher-RU25CZK3.js} +6 -5
  17. package/dist/{embeddings-5ARZAEM5.js → embeddings-LNMNKWB7.js} +3 -3
  18. package/dist/{ingest-V73EAXSX.js → ingest-QSOE5XJZ.js} +4 -5
  19. package/dist/mcp.js +10 -10
  20. package/dist/{memory-value-56GK4AC6.js → memory-value-GH67CBQP.js} +6 -5
  21. package/dist/{quality-IXRBBLYF.js → quality-PZ36JND4.js} +7 -6
  22. package/dist/{retrieval-KOMACG36.js → retrieval-HIE5MASN.js} +5 -5
  23. package/dist/{tasks-OZ3IRHL5.js → tasks-LOZ7XWON.js} +6 -5
  24. package/package.json +1 -1
  25. package/dist/chunk-TJGQUY63.js +0 -324
  26. package/dist/chunk-TJGQUY63.js.map +0 -1
  27. package/dist/chunk-TPCWQS6Q.js.map +0 -1
  28. /package/dist/{chunk-JPHSGWSI.js.map → chunk-6I5U6KS3.js.map} +0 -0
  29. /package/dist/{chunk-OHPGNDSH.js.map → chunk-74MS4JSV.js.map} +0 -0
  30. /package/dist/{chunk-FIWV6K57.js.map → chunk-C6YBSU6B.js.map} +0 -0
  31. /package/dist/{chunk-CQZVFS3P.js.map → chunk-K6AFGQWR.js.map} +0 -0
  32. /package/dist/{chunk-GLQOAY5O.js.map → chunk-KG7YFARS.js.map} +0 -0
  33. /package/dist/{chunk-A54CLR5Q.js.map → chunk-NAYZL5XI.js.map} +0 -0
  34. /package/dist/{chunk-XRM6FCWH.js.map → chunk-SRRPUFXI.js.map} +0 -0
  35. /package/dist/{chunk-33KM4YYX.js.map → chunk-ZBIJDXA7.js.map} +0 -0
  36. /package/dist/{cleanup-6OK2DCUA.js.map → cleanup-HWQCVPY4.js.map} +0 -0
  37. /package/dist/{dispatcher-2Z27VP5Q.js.map → dispatcher-RU25CZK3.js.map} +0 -0
  38. /package/dist/{embeddings-5ARZAEM5.js.map → embeddings-LNMNKWB7.js.map} +0 -0
  39. /package/dist/{ingest-V73EAXSX.js.map → ingest-QSOE5XJZ.js.map} +0 -0
  40. /package/dist/{memory-value-56GK4AC6.js.map → memory-value-GH67CBQP.js.map} +0 -0
  41. /package/dist/{quality-IXRBBLYF.js.map → quality-PZ36JND4.js.map} +0 -0
  42. /package/dist/{retrieval-KOMACG36.js.map → retrieval-HIE5MASN.js.map} +0 -0
  43. /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-A54CLR5Q.js";
4
- import {
5
- getEntity,
6
- listEntities,
7
- listMemoryIdsForEntity,
8
- neighborsOf
9
- } from "./chunk-M7OKBKKU.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-OHPGNDSH.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
@@ -1,15 +1,15 @@
1
- import {
2
- listEntitiesForMemory,
3
- listMemoryIdsForEntity,
4
- neighborsOf
5
- } from "./chunk-M7OKBKKU.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-A54CLR5Q.js.map
123
+ //# sourceMappingURL=chunk-NAYZL5XI.js.map
@@ -2,7 +2,13 @@ import {
2
2
  CONFIDENCE,
3
3
  PROMOTION,
4
4
  queueMemoryEmbeddingSync
5
- } from "./chunk-GLQOAY5O.js";
5
+ } from "./chunk-KG7YFARS.js";
6
+ import {
7
+ isPlausibleEntityName,
8
+ linkMemoryToEntity,
9
+ upsertEntity,
10
+ upsertRelation
11
+ } from "./chunk-M7OKBKKU.js";
6
12
  import {
7
13
  and,
8
14
  eq,
@@ -14,6 +20,9 @@ import {
14
20
  sql
15
21
  } from "./chunk-55KCGAOX.js";
16
22
 
23
+ // src/models/memory.ts
24
+ import { randomUUID } from "crypto";
25
+
17
26
  // src/models/dedupe.ts
18
27
  function normalizeDedupeText(text) {
19
28
  return text.toLowerCase().replace(/\s+/g, " ").replace(/[\s.;:,!?`]+$/g, "").trim();
@@ -88,7 +97,6 @@ function stableDedupeJson(value) {
88
97
  }
89
98
 
90
99
  // src/models/memory.ts
91
- import { randomUUID } from "crypto";
92
100
  function statusFromConfidence(confidence) {
93
101
  if (confidence < CONFIDENCE.TRANSIENT_MAX) return "transient";
94
102
  if (confidence < CONFIDENCE.CANDIDATE_MAX) return "candidate";
@@ -204,6 +212,9 @@ function promoteMemory(db, id, reason, evidence) {
204
212
  last_validated_at: now
205
213
  }).where(eq(memories.id, id)).run();
206
214
  queueMemoryEmbeddingSync(db, id);
215
+ if (newStatus === "active" && mem.status !== "active") {
216
+ safeIngestMemoryById(db, id);
217
+ }
207
218
  return true;
208
219
  }
209
220
  function demoteMemory(db, id, reason) {
@@ -437,12 +448,324 @@ function hasEquivalentEvidence(existing, next) {
437
448
  });
438
449
  }
439
450
 
451
+ // src/graph/extractor.ts
452
+ var PATH_RE = /(?:^|[\s`'"(])((?:\.{0,2}\/)?(?:[A-Za-z0-9_.-]+\/){1,}[A-Za-z0-9_.-]+\.[A-Za-z0-9]{1,8})/g;
453
+ var FUNC_RE = /`([A-Za-z_][\w.]{1,}\(\))`/g;
454
+ var SCOPED_PACKAGE_RE = /`(@[a-z0-9_-]+\/[a-z0-9_.-]+|[a-z][a-z0-9_-]*(?:-[a-z0-9]+)+)`/g;
455
+ var SIMPLE_PACKAGE_RE = /`([a-z][a-z0-9_]{2,30})`/g;
456
+ var PACKAGE_STOPWORDS = /* @__PURE__ */ new Set([
457
+ "the",
458
+ "and",
459
+ "but",
460
+ "for",
461
+ "use",
462
+ "uses",
463
+ "used",
464
+ "with",
465
+ "from",
466
+ "this",
467
+ "that",
468
+ "have",
469
+ "has",
470
+ "true",
471
+ "false",
472
+ "null",
473
+ "void",
474
+ "data",
475
+ "code",
476
+ "test",
477
+ "tests",
478
+ "build",
479
+ "run",
480
+ "runs",
481
+ "name",
482
+ "type",
483
+ "types",
484
+ "main",
485
+ "yes",
486
+ "no",
487
+ "ok",
488
+ "all",
489
+ "any",
490
+ "new",
491
+ "old",
492
+ "more",
493
+ "less",
494
+ "always",
495
+ "never",
496
+ "todo",
497
+ "fixme",
498
+ "note",
499
+ "warn",
500
+ "info",
501
+ "error",
502
+ "ts",
503
+ "js",
504
+ // Shell / language builtins that look package-shaped in backticks but are
505
+ // not libraries ("echo", "dict", ...).
506
+ "echo",
507
+ "dict",
508
+ "list",
509
+ "set",
510
+ "map",
511
+ "str",
512
+ "int",
513
+ "bool",
514
+ "float",
515
+ "print",
516
+ "println",
517
+ "log",
518
+ "dir",
519
+ "env",
520
+ "tmp",
521
+ "src",
522
+ "lib",
523
+ "bin",
524
+ "out",
525
+ "obj",
526
+ "val",
527
+ "var",
528
+ "let",
529
+ "const",
530
+ "func",
531
+ "def",
532
+ "cls",
533
+ "self",
534
+ "args",
535
+ "kwargs",
536
+ "none",
537
+ "cat",
538
+ "grep",
539
+ "sed",
540
+ "awk",
541
+ "cwd",
542
+ "std"
543
+ ]);
544
+ var CLI_RE = /\b(npm|pnpm|yarn|bun|cargo|go|uv|pip|node|deno|claude|codex|cursor|recall|brew|gh|git)\s+([a-z][a-z-]{0,30})\b/g;
545
+ var TOOL_ONLY_CLIS = /* @__PURE__ */ new Set(["npm", "pnpm", "yarn", "bun", "node", "deno"]);
546
+ var CLI_SUBCOMMAND_STOPWORDS = /* @__PURE__ */ new Set([
547
+ "a",
548
+ "an",
549
+ "and",
550
+ "are",
551
+ "as",
552
+ "at",
553
+ "be",
554
+ "by",
555
+ "can",
556
+ "do",
557
+ "does",
558
+ "for",
559
+ "from",
560
+ "has",
561
+ "have",
562
+ "i",
563
+ "if",
564
+ "in",
565
+ "into",
566
+ "is",
567
+ "it",
568
+ "its",
569
+ "no",
570
+ "not",
571
+ "of",
572
+ "on",
573
+ "or",
574
+ "so",
575
+ "that",
576
+ "the",
577
+ "then",
578
+ "this",
579
+ "to",
580
+ "up",
581
+ "via",
582
+ "was",
583
+ "we",
584
+ "will",
585
+ "with",
586
+ "you"
587
+ ]);
588
+ var URL_RE = /\bhttps?:\/\/[^\s<>"'`)]+/g;
589
+ var RELATION_CUES = [
590
+ { rx: /\b(?:replaces?|replaced|supersedes?|superseded|deprecates?|deprecated)\b/i, relation: "replaces" },
591
+ { rx: /\b(?:conflicts? with|incompatible with|clashes? with)\b/i, relation: "conflicts_with" },
592
+ { rx: /\b(?:tested by|covered by)\b/i, relation: "tested_by" },
593
+ { rx: /\b(?:depends on|requires|required by)\b/i, relation: "depends_on" },
594
+ { rx: /\b(?:uses?|used|relies on|via)\b/i, relation: "uses" },
595
+ { rx: /\b(?:references?|see also|cf\.)\b/i, relation: "references" },
596
+ { rx: /\b(?:part of|inside|under)\b/i, relation: "part_of" }
597
+ ];
598
+ function heuristic(text) {
599
+ const entities = /* @__PURE__ */ new Map();
600
+ const relations = [];
601
+ const push = (kind, name, weight = 1) => {
602
+ if (!isPlausibleEntityName(kind, name)) return;
603
+ const key = `${kind}|${name}`;
604
+ const existing = entities.get(key);
605
+ if (existing) {
606
+ existing.weight = (existing.weight ?? 1) + weight;
607
+ } else {
608
+ entities.set(key, { kind, name, source: "heuristic", weight });
609
+ }
610
+ };
611
+ for (const m of text.matchAll(PATH_RE)) {
612
+ const raw = m[1];
613
+ if (raw.includes(".") && !raw.endsWith("/")) {
614
+ push("file", raw);
615
+ } else {
616
+ push("repo_path", raw);
617
+ }
618
+ }
619
+ for (const m of text.matchAll(FUNC_RE)) {
620
+ push("function", m[1]);
621
+ }
622
+ for (const m of text.matchAll(SCOPED_PACKAGE_RE)) {
623
+ push("library", m[1]);
624
+ }
625
+ for (const m of text.matchAll(SIMPLE_PACKAGE_RE)) {
626
+ const candidate = m[1];
627
+ if (PACKAGE_STOPWORDS.has(candidate)) continue;
628
+ push("library", candidate, 0.7);
629
+ }
630
+ for (const m of text.matchAll(CLI_RE)) {
631
+ const tool = m[1];
632
+ const sub = m[2];
633
+ if (CLI_SUBCOMMAND_STOPWORDS.has(sub)) {
634
+ push("tool", tool);
635
+ continue;
636
+ }
637
+ push("tool", tool);
638
+ if (TOOL_ONLY_CLIS.has(tool)) continue;
639
+ push("command", `${tool} ${sub}`);
640
+ }
641
+ for (const m of text.matchAll(URL_RE)) {
642
+ push("url", m[0]);
643
+ }
644
+ const sentences = text.split(/(?<=[.!?])\s+|\n+/);
645
+ for (const sentence of sentences) {
646
+ const cue = RELATION_CUES.find((c) => c.rx.test(sentence));
647
+ if (!cue) continue;
648
+ const mentioned = [];
649
+ for (const ent of entities.values()) {
650
+ const idx = sentence.indexOf(ent.name);
651
+ if (idx >= 0) mentioned.push({ kind: ent.kind, name: ent.name, idx });
652
+ }
653
+ if (mentioned.length < 2) continue;
654
+ mentioned.sort((a, b) => a.idx - b.idx);
655
+ relations.push({
656
+ source: { kind: mentioned[0].kind, name: mentioned[0].name },
657
+ target: { kind: mentioned[1].kind, name: mentioned[1].name },
658
+ relation: cue.relation,
659
+ confidence: 0.5
660
+ });
661
+ }
662
+ return { entities: Array.from(entities.values()), relations };
663
+ }
664
+ function mergeExtractions(...passes) {
665
+ const entities = /* @__PURE__ */ new Map();
666
+ for (const pass of passes) {
667
+ for (const ent of pass.entities) {
668
+ const key = `${ent.kind}|${ent.name}`;
669
+ const prev = entities.get(key);
670
+ if (!prev || prev.source === "heuristic" && ent.source === "llm") {
671
+ entities.set(key, ent);
672
+ }
673
+ }
674
+ }
675
+ const relations = /* @__PURE__ */ new Map();
676
+ for (const pass of passes) {
677
+ for (const rel of pass.relations) {
678
+ const key = `${rel.source.kind}|${rel.source.name}->${rel.relation}->${rel.target.kind}|${rel.target.name}`;
679
+ const prev = relations.get(key);
680
+ if (!prev || rel.confidence > prev.confidence) {
681
+ relations.set(key, rel);
682
+ }
683
+ }
684
+ }
685
+ return {
686
+ entities: Array.from(entities.values()),
687
+ relations: Array.from(relations.values())
688
+ };
689
+ }
690
+
691
+ // src/graph/ingest.ts
692
+ function ingestMemoryHeuristic(db, memory) {
693
+ const extraction = heuristic(memory.text);
694
+ return persistExtraction(db, memory, extraction);
695
+ }
696
+ function ingestMemoryExtraction(db, memory, extraction) {
697
+ return persistExtraction(db, memory, extraction);
698
+ }
699
+ function mergeAndIngest(db, memory, passes) {
700
+ return persistExtraction(db, memory, mergeExtractions(...passes));
701
+ }
702
+ function persistExtraction(db, memory, extraction) {
703
+ const entityIndex = /* @__PURE__ */ new Map();
704
+ let entitiesTouched = 0;
705
+ for (const ent of extraction.entities) {
706
+ const row = upsertEntity(db, {
707
+ kind: ent.kind,
708
+ name: ent.name,
709
+ repo: memory.repo,
710
+ first_seen_memory_id: memory.id
711
+ });
712
+ entityIndex.set(`${row.kind}|${row.normalized_name}`, row);
713
+ linkMemoryToEntity(db, {
714
+ memory_id: memory.id,
715
+ entity_id: row.id,
716
+ source: ent.source,
717
+ weight: ent.weight
718
+ });
719
+ entitiesTouched++;
720
+ }
721
+ let relationsTouched = 0;
722
+ const lookupRow = (kind, name) => {
723
+ for (const row of entityIndex.values()) {
724
+ if (row.kind === kind && row.name === name) return row;
725
+ }
726
+ return void 0;
727
+ };
728
+ for (const rel of extraction.relations) {
729
+ const src = lookupRow(rel.source.kind, rel.source.name) ?? upsertEntity(db, { kind: rel.source.kind, name: rel.source.name, repo: memory.repo });
730
+ const tgt = lookupRow(rel.target.kind, rel.target.name) ?? upsertEntity(db, { kind: rel.target.kind, name: rel.target.name, repo: memory.repo });
731
+ if (src.id === tgt.id) continue;
732
+ upsertRelation(db, {
733
+ source_entity_id: src.id,
734
+ target_entity_id: tgt.id,
735
+ relation_type: rel.relation,
736
+ source_memory_id: memory.id,
737
+ confidence: rel.confidence
738
+ });
739
+ relationsTouched++;
740
+ }
741
+ return {
742
+ memory_id: memory.id,
743
+ entities_created_or_updated: entitiesTouched,
744
+ relations_created_or_updated: relationsTouched
745
+ };
746
+ }
747
+ function safeIngestMemoryById(db, memoryId) {
748
+ try {
749
+ const mem = getMemory(db, memoryId);
750
+ if (!mem) return null;
751
+ if (mem.status !== "active") return null;
752
+ return ingestMemoryHeuristic(db, { id: mem.id, text: mem.text, repo: mem.repo });
753
+ } catch (err) {
754
+ console.error(`[recall] graph ingest failed for ${memoryId}:`, err);
755
+ return null;
756
+ }
757
+ }
758
+
440
759
  export {
441
760
  normalizeDedupeText,
442
761
  memoryDedupeKey,
443
762
  historySnippetDedupeKey,
444
763
  activityEventDedupeKey,
445
764
  hookCallDedupeKey,
765
+ ingestMemoryHeuristic,
766
+ ingestMemoryExtraction,
767
+ mergeAndIngest,
768
+ safeIngestMemoryById,
446
769
  statusFromConfidence,
447
770
  createMemory,
448
771
  getMemory,
@@ -463,4 +786,4 @@ export {
463
786
  getMemoryFeedbackSummaries,
464
787
  feedbackWeightedScore
465
788
  };
466
- //# sourceMappingURL=chunk-TPCWQS6Q.js.map
789
+ //# sourceMappingURL=chunk-O4KCMCJG.js.map