@graphorin/memory 0.5.0

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 (287) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +21 -0
  3. package/README.md +401 -0
  4. package/dist/conflict/index.d.ts +3 -0
  5. package/dist/conflict/index.js +7 -0
  6. package/dist/conflict/locale-packs/en.js +262 -0
  7. package/dist/conflict/locale-packs/en.js.map +1 -0
  8. package/dist/conflict/locale-packs/index.js +4 -0
  9. package/dist/conflict/locale-packs/types.d.ts +103 -0
  10. package/dist/conflict/locale-packs/types.d.ts.map +1 -0
  11. package/dist/conflict/locale-packs/types.js +55 -0
  12. package/dist/conflict/locale-packs/types.js.map +1 -0
  13. package/dist/conflict/pipeline.d.ts +35 -0
  14. package/dist/conflict/pipeline.d.ts.map +1 -0
  15. package/dist/conflict/pipeline.js +257 -0
  16. package/dist/conflict/pipeline.js.map +1 -0
  17. package/dist/conflict/stages/helpers.js +66 -0
  18. package/dist/conflict/stages/helpers.js.map +1 -0
  19. package/dist/conflict/stages/stage1-exact-dedup.js +21 -0
  20. package/dist/conflict/stages/stage1-exact-dedup.js.map +1 -0
  21. package/dist/conflict/stages/stage2-embedding-three-zone.js +37 -0
  22. package/dist/conflict/stages/stage2-embedding-three-zone.js.map +1 -0
  23. package/dist/conflict/stages/stage3-heuristic-regex.js +45 -0
  24. package/dist/conflict/stages/stage3-heuristic-regex.js.map +1 -0
  25. package/dist/conflict/stages/stage4-subject-predicate.js +31 -0
  26. package/dist/conflict/stages/stage4-subject-predicate.js.map +1 -0
  27. package/dist/conflict/stages/stage5-defer-to-deep.js +22 -0
  28. package/dist/conflict/stages/stage5-defer-to-deep.js.map +1 -0
  29. package/dist/conflict/types.d.ts +222 -0
  30. package/dist/conflict/types.d.ts.map +1 -0
  31. package/dist/conflict/types.js +50 -0
  32. package/dist/conflict/types.js.map +1 -0
  33. package/dist/consolidator/budget.d.ts +1 -0
  34. package/dist/consolidator/budget.js +214 -0
  35. package/dist/consolidator/budget.js.map +1 -0
  36. package/dist/consolidator/decay.d.ts +35 -0
  37. package/dist/consolidator/decay.d.ts.map +1 -0
  38. package/dist/consolidator/decay.js +91 -0
  39. package/dist/consolidator/decay.js.map +1 -0
  40. package/dist/consolidator/dlq.js +58 -0
  41. package/dist/consolidator/dlq.js.map +1 -0
  42. package/dist/consolidator/errors.d.ts +54 -0
  43. package/dist/consolidator/errors.d.ts.map +1 -0
  44. package/dist/consolidator/errors.js +67 -0
  45. package/dist/consolidator/errors.js.map +1 -0
  46. package/dist/consolidator/idempotency.d.ts +1 -0
  47. package/dist/consolidator/idempotency.js +22 -0
  48. package/dist/consolidator/idempotency.js.map +1 -0
  49. package/dist/consolidator/index.d.ts +34 -0
  50. package/dist/consolidator/index.d.ts.map +1 -0
  51. package/dist/consolidator/index.js +163 -0
  52. package/dist/consolidator/index.js.map +1 -0
  53. package/dist/consolidator/lock.d.ts +2 -0
  54. package/dist/consolidator/lock.js +89 -0
  55. package/dist/consolidator/lock.js.map +1 -0
  56. package/dist/consolidator/noise-filter.d.ts +2 -0
  57. package/dist/consolidator/noise-filter.js +173 -0
  58. package/dist/consolidator/noise-filter.js.map +1 -0
  59. package/dist/consolidator/phases/deep.d.ts +4 -0
  60. package/dist/consolidator/phases/deep.js +198 -0
  61. package/dist/consolidator/phases/deep.js.map +1 -0
  62. package/dist/consolidator/phases/induce.d.ts +154 -0
  63. package/dist/consolidator/phases/induce.d.ts.map +1 -0
  64. package/dist/consolidator/phases/induce.js +253 -0
  65. package/dist/consolidator/phases/induce.js.map +1 -0
  66. package/dist/consolidator/phases/light.d.ts +4 -0
  67. package/dist/consolidator/phases/light.js +99 -0
  68. package/dist/consolidator/phases/light.js.map +1 -0
  69. package/dist/consolidator/phases/reflect.js +287 -0
  70. package/dist/consolidator/phases/reflect.js.map +1 -0
  71. package/dist/consolidator/phases/standard.d.ts +8 -0
  72. package/dist/consolidator/phases/standard.js +499 -0
  73. package/dist/consolidator/phases/standard.js.map +1 -0
  74. package/dist/consolidator/reconcile.js +192 -0
  75. package/dist/consolidator/reconcile.js.map +1 -0
  76. package/dist/consolidator/runtime.d.ts +62 -0
  77. package/dist/consolidator/runtime.d.ts.map +1 -0
  78. package/dist/consolidator/runtime.js +580 -0
  79. package/dist/consolidator/runtime.js.map +1 -0
  80. package/dist/consolidator/scheduler.d.ts +111 -0
  81. package/dist/consolidator/scheduler.d.ts.map +1 -0
  82. package/dist/consolidator/scheduler.js +71 -0
  83. package/dist/consolidator/scheduler.js.map +1 -0
  84. package/dist/consolidator/triggers.d.ts +40 -0
  85. package/dist/consolidator/triggers.d.ts.map +1 -0
  86. package/dist/consolidator/triggers.js +94 -0
  87. package/dist/consolidator/triggers.js.map +1 -0
  88. package/dist/consolidator/types.d.ts +397 -0
  89. package/dist/consolidator/types.d.ts.map +1 -0
  90. package/dist/consolidator/types.js +117 -0
  91. package/dist/consolidator/types.js.map +1 -0
  92. package/dist/context-engine/annotations.d.ts +118 -0
  93. package/dist/context-engine/annotations.d.ts.map +1 -0
  94. package/dist/context-engine/annotations.js +102 -0
  95. package/dist/context-engine/annotations.js.map +1 -0
  96. package/dist/context-engine/auto-recall.d.ts +52 -0
  97. package/dist/context-engine/auto-recall.d.ts.map +1 -0
  98. package/dist/context-engine/auto-recall.js +41 -0
  99. package/dist/context-engine/auto-recall.js.map +1 -0
  100. package/dist/context-engine/compaction/clear-tool-results.d.ts +55 -0
  101. package/dist/context-engine/compaction/clear-tool-results.d.ts.map +1 -0
  102. package/dist/context-engine/compaction/clear-tool-results.js +97 -0
  103. package/dist/context-engine/compaction/clear-tool-results.js.map +1 -0
  104. package/dist/context-engine/compaction/compactor.d.ts +52 -0
  105. package/dist/context-engine/compaction/compactor.d.ts.map +1 -0
  106. package/dist/context-engine/compaction/compactor.js +196 -0
  107. package/dist/context-engine/compaction/compactor.js.map +1 -0
  108. package/dist/context-engine/compaction/hooks/reanchor-persona-block.d.ts +15 -0
  109. package/dist/context-engine/compaction/hooks/reanchor-persona-block.d.ts.map +1 -0
  110. package/dist/context-engine/compaction/hooks/reanchor-persona-block.js +27 -0
  111. package/dist/context-engine/compaction/hooks/reanchor-persona-block.js.map +1 -0
  112. package/dist/context-engine/compaction/hooks/reanchor-pinned-facts.d.ts +18 -0
  113. package/dist/context-engine/compaction/hooks/reanchor-pinned-facts.d.ts.map +1 -0
  114. package/dist/context-engine/compaction/hooks/reanchor-pinned-facts.js +47 -0
  115. package/dist/context-engine/compaction/hooks/reanchor-pinned-facts.js.map +1 -0
  116. package/dist/context-engine/compaction/hooks/reanchor-project-rules.d.ts +15 -0
  117. package/dist/context-engine/compaction/hooks/reanchor-project-rules.d.ts.map +1 -0
  118. package/dist/context-engine/compaction/hooks/reanchor-project-rules.js +32 -0
  119. package/dist/context-engine/compaction/hooks/reanchor-project-rules.js.map +1 -0
  120. package/dist/context-engine/compaction/hooks/types.d.ts +42 -0
  121. package/dist/context-engine/compaction/hooks/types.d.ts.map +1 -0
  122. package/dist/context-engine/compaction/index.d.ts +9 -0
  123. package/dist/context-engine/compaction/index.js +9 -0
  124. package/dist/context-engine/compaction/templates/summary-9-section.d.ts +84 -0
  125. package/dist/context-engine/compaction/templates/summary-9-section.d.ts.map +1 -0
  126. package/dist/context-engine/compaction/templates/summary-9-section.js +84 -0
  127. package/dist/context-engine/compaction/templates/summary-9-section.js.map +1 -0
  128. package/dist/context-engine/compaction/thresholds.d.ts +68 -0
  129. package/dist/context-engine/compaction/thresholds.d.ts.map +1 -0
  130. package/dist/context-engine/compaction/thresholds.js +63 -0
  131. package/dist/context-engine/compaction/thresholds.js.map +1 -0
  132. package/dist/context-engine/compaction/types.d.ts +202 -0
  133. package/dist/context-engine/compaction/types.d.ts.map +1 -0
  134. package/dist/context-engine/engine.d.ts +258 -0
  135. package/dist/context-engine/engine.d.ts.map +1 -0
  136. package/dist/context-engine/engine.js +424 -0
  137. package/dist/context-engine/engine.js.map +1 -0
  138. package/dist/context-engine/index.d.ts +68 -0
  139. package/dist/context-engine/index.d.ts.map +1 -0
  140. package/dist/context-engine/index.js +24 -0
  141. package/dist/context-engine/locale-packs/en.d.ts +14 -0
  142. package/dist/context-engine/locale-packs/en.d.ts.map +1 -0
  143. package/dist/context-engine/locale-packs/en.js +87 -0
  144. package/dist/context-engine/locale-packs/en.js.map +1 -0
  145. package/dist/context-engine/locale-packs/index.js +4 -0
  146. package/dist/context-engine/locale-packs/resolver.d.ts +41 -0
  147. package/dist/context-engine/locale-packs/resolver.d.ts.map +1 -0
  148. package/dist/context-engine/locale-packs/resolver.js +119 -0
  149. package/dist/context-engine/locale-packs/resolver.js.map +1 -0
  150. package/dist/context-engine/locale-packs/types.d.ts +119 -0
  151. package/dist/context-engine/locale-packs/types.d.ts.map +1 -0
  152. package/dist/context-engine/locale-packs/types.js +24 -0
  153. package/dist/context-engine/locale-packs/types.js.map +1 -0
  154. package/dist/context-engine/metadata.d.ts +40 -0
  155. package/dist/context-engine/metadata.d.ts.map +1 -0
  156. package/dist/context-engine/metadata.js +66 -0
  157. package/dist/context-engine/metadata.js.map +1 -0
  158. package/dist/context-engine/preambles/inbound-en.d.ts +20 -0
  159. package/dist/context-engine/preambles/inbound-en.d.ts.map +1 -0
  160. package/dist/context-engine/preambles/inbound-en.js +23 -0
  161. package/dist/context-engine/preambles/inbound-en.js.map +1 -0
  162. package/dist/context-engine/privacy-filter.d.ts +108 -0
  163. package/dist/context-engine/privacy-filter.d.ts.map +1 -0
  164. package/dist/context-engine/privacy-filter.js +113 -0
  165. package/dist/context-engine/privacy-filter.js.map +1 -0
  166. package/dist/context-engine/templates/base-en.d.ts +19 -0
  167. package/dist/context-engine/templates/base-en.d.ts.map +1 -0
  168. package/dist/context-engine/templates/base-en.js +22 -0
  169. package/dist/context-engine/templates/base-en.js.map +1 -0
  170. package/dist/context-engine/templates/composer.d.ts +55 -0
  171. package/dist/context-engine/templates/composer.d.ts.map +1 -0
  172. package/dist/context-engine/templates/composer.js +51 -0
  173. package/dist/context-engine/templates/composer.js.map +1 -0
  174. package/dist/context-engine/token-budget.d.ts +99 -0
  175. package/dist/context-engine/token-budget.d.ts.map +1 -0
  176. package/dist/context-engine/token-budget.js +211 -0
  177. package/dist/context-engine/token-budget.js.map +1 -0
  178. package/dist/context-engine/token-counter.d.ts +54 -0
  179. package/dist/context-engine/token-counter.d.ts.map +1 -0
  180. package/dist/context-engine/token-counter.js +81 -0
  181. package/dist/context-engine/token-counter.js.map +1 -0
  182. package/dist/errors/index.d.ts +171 -0
  183. package/dist/errors/index.d.ts.map +1 -0
  184. package/dist/errors/index.js +206 -0
  185. package/dist/errors/index.js.map +1 -0
  186. package/dist/facade.d.ts +278 -0
  187. package/dist/facade.d.ts.map +1 -0
  188. package/dist/facade.js +265 -0
  189. package/dist/facade.js.map +1 -0
  190. package/dist/graph/entity-resolver.d.ts +135 -0
  191. package/dist/graph/entity-resolver.d.ts.map +1 -0
  192. package/dist/graph/entity-resolver.js +202 -0
  193. package/dist/graph/entity-resolver.js.map +1 -0
  194. package/dist/graph/index.d.ts +1 -0
  195. package/dist/index.d.ts +103 -0
  196. package/dist/index.d.ts.map +1 -0
  197. package/dist/index.js +95 -0
  198. package/dist/index.js.map +1 -0
  199. package/dist/internal/contextualize.d.ts +14 -0
  200. package/dist/internal/contextualize.d.ts.map +1 -0
  201. package/dist/internal/contextualize.js +110 -0
  202. package/dist/internal/contextualize.js.map +1 -0
  203. package/dist/internal/embedder-binding.js +50 -0
  204. package/dist/internal/embedder-binding.js.map +1 -0
  205. package/dist/internal/id.js +24 -0
  206. package/dist/internal/id.js.map +1 -0
  207. package/dist/internal/injection-heuristics.js +64 -0
  208. package/dist/internal/injection-heuristics.js.map +1 -0
  209. package/dist/internal/spans.js +35 -0
  210. package/dist/internal/spans.js.map +1 -0
  211. package/dist/internal/storage-adapter.d.ts +742 -0
  212. package/dist/internal/storage-adapter.d.ts.map +1 -0
  213. package/dist/migration/embedder-migration.d.ts +124 -0
  214. package/dist/migration/embedder-migration.d.ts.map +1 -0
  215. package/dist/migration/embedder-migration.js +109 -0
  216. package/dist/migration/embedder-migration.js.map +1 -0
  217. package/dist/migration/index.d.ts +2 -0
  218. package/dist/migration/index.js +3 -0
  219. package/dist/search/explain.d.ts +74 -0
  220. package/dist/search/explain.d.ts.map +1 -0
  221. package/dist/search/explain.js +50 -0
  222. package/dist/search/explain.js.map +1 -0
  223. package/dist/search/index.d.ts +6 -0
  224. package/dist/search/index.js +6 -0
  225. package/dist/search/iterative.d.ts +223 -0
  226. package/dist/search/iterative.d.ts.map +1 -0
  227. package/dist/search/iterative.js +330 -0
  228. package/dist/search/iterative.js.map +1 -0
  229. package/dist/search/query-transform.d.ts +112 -0
  230. package/dist/search/query-transform.d.ts.map +1 -0
  231. package/dist/search/query-transform.js +184 -0
  232. package/dist/search/query-transform.js.map +1 -0
  233. package/dist/search/rrf.d.ts +95 -0
  234. package/dist/search/rrf.d.ts.map +1 -0
  235. package/dist/search/rrf.js +166 -0
  236. package/dist/search/rrf.js.map +1 -0
  237. package/dist/search/types.d.ts +50 -0
  238. package/dist/search/types.d.ts.map +1 -0
  239. package/dist/tiers/episodic-memory.d.ts +142 -0
  240. package/dist/tiers/episodic-memory.d.ts.map +1 -0
  241. package/dist/tiers/episodic-memory.js +254 -0
  242. package/dist/tiers/episodic-memory.js.map +1 -0
  243. package/dist/tiers/index.d.ts +8 -0
  244. package/dist/tiers/index.js +9 -0
  245. package/dist/tiers/insight-memory.d.ts +71 -0
  246. package/dist/tiers/insight-memory.d.ts.map +1 -0
  247. package/dist/tiers/insight-memory.js +133 -0
  248. package/dist/tiers/insight-memory.js.map +1 -0
  249. package/dist/tiers/procedural-memory.d.ts +147 -0
  250. package/dist/tiers/procedural-memory.d.ts.map +1 -0
  251. package/dist/tiers/procedural-memory.js +267 -0
  252. package/dist/tiers/procedural-memory.js.map +1 -0
  253. package/dist/tiers/semantic-memory.d.ts +461 -0
  254. package/dist/tiers/semantic-memory.d.ts.map +1 -0
  255. package/dist/tiers/semantic-memory.js +631 -0
  256. package/dist/tiers/semantic-memory.js.map +1 -0
  257. package/dist/tiers/session-memory.d.ts +117 -0
  258. package/dist/tiers/session-memory.d.ts.map +1 -0
  259. package/dist/tiers/session-memory.js +163 -0
  260. package/dist/tiers/session-memory.js.map +1 -0
  261. package/dist/tiers/shared-memory.d.ts +29 -0
  262. package/dist/tiers/shared-memory.d.ts.map +1 -0
  263. package/dist/tiers/shared-memory.js +58 -0
  264. package/dist/tiers/shared-memory.js.map +1 -0
  265. package/dist/tiers/working-memory.d.ts +129 -0
  266. package/dist/tiers/working-memory.d.ts.map +1 -0
  267. package/dist/tiers/working-memory.js +229 -0
  268. package/dist/tiers/working-memory.js.map +1 -0
  269. package/dist/tools/block-tools.d.ts +98 -0
  270. package/dist/tools/block-tools.d.ts.map +1 -0
  271. package/dist/tools/block-tools.js +114 -0
  272. package/dist/tools/block-tools.js.map +1 -0
  273. package/dist/tools/fact-tools.d.ts +294 -0
  274. package/dist/tools/fact-tools.d.ts.map +1 -0
  275. package/dist/tools/fact-tools.js +293 -0
  276. package/dist/tools/fact-tools.js.map +1 -0
  277. package/dist/tools/index.d.ts +35 -0
  278. package/dist/tools/index.d.ts.map +1 -0
  279. package/dist/tools/index.js +36 -0
  280. package/dist/tools/index.js.map +1 -0
  281. package/dist/tools/recall-tools.d.ts +209 -0
  282. package/dist/tools/recall-tools.d.ts.map +1 -0
  283. package/dist/tools/recall-tools.js +170 -0
  284. package/dist/tools/recall-tools.js.map +1 -0
  285. package/dist/tools/types.d.ts +40 -0
  286. package/dist/tools/types.d.ts.map +1 -0
  287. package/package.json +119 -0
@@ -0,0 +1,135 @@
1
+ import { GraphMemoryStoreExt } from "../internal/storage-adapter.js";
2
+ import { EmbedderProvider, Fact, Provider, ProviderRequest, SessionScope } from "@graphorin/core";
3
+
4
+ //#region src/graph/entity-resolver.d.ts
5
+
6
+ /** Cosine `≥` this auto-reuses an existing entity (embedding match). */
7
+ declare const DEFAULT_MERGE_THRESHOLD = 0.92;
8
+ /** Cosine in `[this, merge)` is *ambiguous* — adjudicate or mint new. */
9
+ declare const DEFAULT_ADJUDICATE_THRESHOLD = 0.82;
10
+ /**
11
+ * Outcome of the pure resolution policy. `match` reuses an existing
12
+ * entity; `ambiguous` flags a middle-similarity candidate for the caller
13
+ * to adjudicate (or conservatively reject); `new` mints a fresh entity.
14
+ *
15
+ * @stable
16
+ */
17
+ type EntityResolveDecision = {
18
+ readonly kind: 'match';
19
+ readonly entityId: string;
20
+ readonly similarity: number;
21
+ readonly via: 'lexical' | 'embedding';
22
+ } | {
23
+ readonly kind: 'ambiguous';
24
+ readonly entityId: string;
25
+ readonly similarity: number;
26
+ } | {
27
+ readonly kind: 'new';
28
+ };
29
+ /** Minimal candidate shape the pure policy compares against. */
30
+ interface ResolutionCandidate {
31
+ readonly id: string;
32
+ readonly normalizedName: string;
33
+ readonly vector: Float32Array | null;
34
+ /**
35
+ * MST-11: the embedder that produced `vector`. When both this and the
36
+ * query's `vectorEmbedderId` are known and differ, the candidate is skipped
37
+ * for embedding comparison — vectors from different models live in different
38
+ * spaces, so their cosine is meaningless. Absent on either side ⇒ compared
39
+ * (byte-identical to the prior behaviour).
40
+ */
41
+ readonly embedderId?: string | null;
42
+ }
43
+ /** Inputs to {@link resolveEntityDecision} (all provided by the caller). */
44
+ interface ResolveDecisionInput {
45
+ readonly normalizedName: string;
46
+ readonly vector?: Float32Array | null;
47
+ /** MST-11: the embedder that produced `vector` (gates cross-embedder cosine). */
48
+ readonly vectorEmbedderId?: string | null;
49
+ readonly candidates: ReadonlyArray<ResolutionCandidate>;
50
+ readonly mergeThreshold: number;
51
+ readonly adjudicateThreshold: number;
52
+ }
53
+ /**
54
+ * Fold an entity surface form into a canonical lexical key: Unicode
55
+ * NFKC, lowercased, internal whitespace collapsed, surrounding
56
+ * punctuation stripped. `" Anna S. "` → `"anna s"`. Returns `''` for a
57
+ * name with no letters/digits (the resolver treats that as "no entity").
58
+ *
59
+ * @stable
60
+ */
61
+ declare function normalizeEntityName(name: string): string;
62
+ /**
63
+ * Cosine similarity of two embeddings in `[-1, 1]`. Compares over the
64
+ * shorter length and returns `0` when either vector is empty / zero-norm.
65
+ *
66
+ * @stable
67
+ */
68
+ declare function cosineSimilarity(a: Float32Array, b: Float32Array): number;
69
+ /**
70
+ * Pure resolution policy: lexical exact match → embedding cosine →
71
+ * ambiguous band → new. No I/O; deterministic. The caller decides what
72
+ * to do with `ambiguous` (LLM adjudicate, or conservatively mint new).
73
+ *
74
+ * @stable
75
+ */
76
+ declare function resolveEntityDecision(input: ResolveDecisionInput): EntityResolveDecision;
77
+ /** Tunable thresholds + LLM-adjudication switch for {@link EntityResolver}. */
78
+ interface EntityResolutionConfig {
79
+ /** Cosine `≥` this auto-reuses a match. Default {@link DEFAULT_MERGE_THRESHOLD}. */
80
+ readonly mergeThreshold?: number;
81
+ /** Cosine in `[this, merge)` is ambiguous. Default {@link DEFAULT_ADJUDICATE_THRESHOLD}. */
82
+ readonly adjudicateThreshold?: number;
83
+ /**
84
+ * Resolve the ambiguous band with one provider call. Requires a
85
+ * `provider`. Default `false` ⇒ ambiguous mints a new entity (no
86
+ * network call; never auto-merges on weak evidence).
87
+ */
88
+ readonly llmAdjudication?: boolean;
89
+ }
90
+ /** Construction deps for {@link EntityResolver}. */
91
+ interface EntityResolverDeps {
92
+ readonly store: GraphMemoryStoreExt;
93
+ readonly embedder?: EmbedderProvider | null;
94
+ readonly embedderId?: () => string | null;
95
+ readonly provider?: Provider | null;
96
+ readonly config?: EntityResolutionConfig;
97
+ }
98
+ /** Build the (pure) adjudication request. Exposed for testing. */
99
+ declare function buildAdjudicationRequest(nameA: string, nameB: string, options?: {
100
+ readonly signal?: AbortSignal;
101
+ }): ProviderRequest;
102
+ /** Parse a yes/no adjudication reply. Conservative: only a clear yes is `true`. */
103
+ declare function parseAdjudication(text: string): boolean;
104
+ /**
105
+ * Resolves a fact's subject / object strings to canonical entity ids and
106
+ * links them, applying {@link resolveEntityDecision} backed by an
107
+ * injected store + embedder (+ optional provider for adjudication).
108
+ * Constructed only when entity resolution is opted in
109
+ * (`createMemory({ graph: { entityResolution: true } })`); otherwise the
110
+ * write path skips it and behaviour is unchanged + offline.
111
+ *
112
+ * @stable
113
+ */
114
+ declare class EntityResolver {
115
+ #private;
116
+ constructor(deps: EntityResolverDeps);
117
+ /**
118
+ * Resolve a single name to a canonical entity id (find-or-create),
119
+ * deduping via lexical + embedding similarity. Returns `null` for a
120
+ * name that normalizes to empty (no entity).
121
+ */
122
+ resolve(scope: SessionScope, rawName: string, opts?: {
123
+ readonly signal?: AbortSignal;
124
+ }): Promise<string | null>;
125
+ /**
126
+ * Resolve + link a fact's subject and object (the predicate is a
127
+ * relation label, never an entity). Idempotent on re-link.
128
+ */
129
+ linkFact(scope: SessionScope, fact: Fact, opts?: {
130
+ readonly signal?: AbortSignal;
131
+ }): Promise<void>;
132
+ }
133
+ //#endregion
134
+ export { DEFAULT_ADJUDICATE_THRESHOLD, DEFAULT_MERGE_THRESHOLD, EntityResolutionConfig, EntityResolveDecision, EntityResolver, EntityResolverDeps, ResolutionCandidate, ResolveDecisionInput, buildAdjudicationRequest, cosineSimilarity, normalizeEntityName, parseAdjudication, resolveEntityDecision };
135
+ //# sourceMappingURL=entity-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-resolver.d.ts","names":[],"sources":["../../src/graph/entity-resolver.ts"],"sourcesContent":[],"mappings":";;;;;;AA2PW,cAxNE,uBAAA,GAwNF,IAAA;;AAGN,cAzNQ,4BAAA,GAyNR,IAAA;;;;;;;;KAhNO,qBAAA;;;;;;;;;;;;;UAWK,mBAAA;;;mBAGE;;;;;;;;;;;UAYF,oBAAA;;oBAEG;;;uBAGG,cAAc;;;;;;;;;;;;iBAarB,mBAAA;;;;;;;iBAeA,gBAAA,IAAoB,iBAAiB;;;;;;;;iBAuBrC,qBAAA,QAA6B,uBAAuB;;UAyCnD,sBAAA;;;;;;;;;;;;;UAcA,kBAAA;kBACC;sBACI;;sBAEA;oBACF;;;iBASJ,wBAAA;oBAGe;IAC5B;;iBAWa,iBAAA;;;;;;;;;;;cAcH,cAAA;;oBASO;;;;;;iBAgBT;sBAEmB;MACzB;;;;;kBAyCM,oBACD;sBACoB;MACzB"}
@@ -0,0 +1,202 @@
1
+ //#region src/graph/entity-resolver.ts
2
+ /** Cosine `≥` this auto-reuses an existing entity (embedding match). */
3
+ const DEFAULT_MERGE_THRESHOLD = .92;
4
+ /** Cosine in `[this, merge)` is *ambiguous* — adjudicate or mint new. */
5
+ const DEFAULT_ADJUDICATE_THRESHOLD = .82;
6
+ /**
7
+ * Fold an entity surface form into a canonical lexical key: Unicode
8
+ * NFKC, lowercased, internal whitespace collapsed, surrounding
9
+ * punctuation stripped. `" Anna S. "` → `"anna s"`. Returns `''` for a
10
+ * name with no letters/digits (the resolver treats that as "no entity").
11
+ *
12
+ * @stable
13
+ */
14
+ function normalizeEntityName(name) {
15
+ return name.normalize("NFKC").toLowerCase().replace(/\s+/g, " ").trim().replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, "");
16
+ }
17
+ /**
18
+ * Cosine similarity of two embeddings in `[-1, 1]`. Compares over the
19
+ * shorter length and returns `0` when either vector is empty / zero-norm.
20
+ *
21
+ * @stable
22
+ */
23
+ function cosineSimilarity(a, b) {
24
+ const len = Math.min(a.length, b.length);
25
+ let dot = 0;
26
+ let na = 0;
27
+ let nb = 0;
28
+ for (let i = 0; i < len; i++) {
29
+ const ai = a[i] ?? 0;
30
+ const bi = b[i] ?? 0;
31
+ dot += ai * bi;
32
+ na += ai * ai;
33
+ nb += bi * bi;
34
+ }
35
+ if (na === 0 || nb === 0) return 0;
36
+ return dot / Math.sqrt(na * nb);
37
+ }
38
+ /**
39
+ * Pure resolution policy: lexical exact match → embedding cosine →
40
+ * ambiguous band → new. No I/O; deterministic. The caller decides what
41
+ * to do with `ambiguous` (LLM adjudicate, or conservatively mint new).
42
+ *
43
+ * @stable
44
+ */
45
+ function resolveEntityDecision(input) {
46
+ for (const c of input.candidates) if (c.normalizedName === input.normalizedName) return {
47
+ kind: "match",
48
+ entityId: c.id,
49
+ similarity: 1,
50
+ via: "lexical"
51
+ };
52
+ const v = input.vector;
53
+ if (v === void 0 || v === null || v.length === 0) return { kind: "new" };
54
+ let bestId = null;
55
+ let bestSim = Number.NEGATIVE_INFINITY;
56
+ for (const c of input.candidates) {
57
+ if (c.vector === null || c.vector.length === 0) continue;
58
+ if (input.vectorEmbedderId != null && c.embedderId != null && c.embedderId !== input.vectorEmbedderId) continue;
59
+ const sim = cosineSimilarity(v, c.vector);
60
+ if (sim > bestSim) {
61
+ bestSim = sim;
62
+ bestId = c.id;
63
+ }
64
+ }
65
+ if (bestId === null) return { kind: "new" };
66
+ if (bestSim >= input.mergeThreshold) return {
67
+ kind: "match",
68
+ entityId: bestId,
69
+ similarity: bestSim,
70
+ via: "embedding"
71
+ };
72
+ if (bestSim >= input.adjudicateThreshold) return {
73
+ kind: "ambiguous",
74
+ entityId: bestId,
75
+ similarity: bestSim
76
+ };
77
+ return { kind: "new" };
78
+ }
79
+ const ADJUDICATION_SYSTEM_PROMPT = "You decide whether two short names refer to the SAME real-world entity (person, place, org, thing). Reply with a single word: \"yes\" or \"no\". Be conservative — answer \"no\" unless they are clearly the same entity.";
80
+ /** Build the (pure) adjudication request. Exposed for testing. */
81
+ function buildAdjudicationRequest(nameA, nameB, options = {}) {
82
+ return {
83
+ messages: [{
84
+ role: "user",
85
+ content: `Name A: ${nameA}\nName B: ${nameB}\nSame entity?`
86
+ }],
87
+ systemMessage: ADJUDICATION_SYSTEM_PROMPT,
88
+ temperature: 0,
89
+ maxTokens: 4,
90
+ ...options.signal !== void 0 ? { signal: options.signal } : {}
91
+ };
92
+ }
93
+ /** Parse a yes/no adjudication reply. Conservative: only a clear yes is `true`. */
94
+ function parseAdjudication(text) {
95
+ return /^\s*(yes|true|same)\b/i.test(text);
96
+ }
97
+ /**
98
+ * Resolves a fact's subject / object strings to canonical entity ids and
99
+ * links them, applying {@link resolveEntityDecision} backed by an
100
+ * injected store + embedder (+ optional provider for adjudication).
101
+ * Constructed only when entity resolution is opted in
102
+ * (`createMemory({ graph: { entityResolution: true } })`); otherwise the
103
+ * write path skips it and behaviour is unchanged + offline.
104
+ *
105
+ * @stable
106
+ */
107
+ var EntityResolver = class {
108
+ #store;
109
+ #embedder;
110
+ #embedderId;
111
+ #provider;
112
+ #mergeThreshold;
113
+ #adjudicateThreshold;
114
+ #llmAdjudication;
115
+ constructor(deps) {
116
+ this.#store = deps.store;
117
+ this.#embedder = deps.embedder ?? null;
118
+ this.#embedderId = deps.embedderId ?? (() => null);
119
+ this.#provider = deps.provider ?? null;
120
+ this.#mergeThreshold = deps.config?.mergeThreshold ?? DEFAULT_MERGE_THRESHOLD;
121
+ this.#adjudicateThreshold = deps.config?.adjudicateThreshold ?? DEFAULT_ADJUDICATE_THRESHOLD;
122
+ this.#llmAdjudication = deps.config?.llmAdjudication ?? false;
123
+ }
124
+ /**
125
+ * Resolve a single name to a canonical entity id (find-or-create),
126
+ * deduping via lexical + embedding similarity. Returns `null` for a
127
+ * name that normalizes to empty (no entity).
128
+ */
129
+ async resolve(scope, rawName, opts = {}) {
130
+ const normalizedName = normalizeEntityName(rawName);
131
+ if (normalizedName.length === 0) return null;
132
+ const exact = await this.#store.findEntityByNormalizedName?.(scope, normalizedName);
133
+ if (exact != null) return exact.id;
134
+ const vector = await this.#embed(rawName, opts.signal);
135
+ if (vector === null || vector.length === 0) return this.#create(scope, rawName, normalizedName, vector);
136
+ const candidates = await this.#store.listEntities(scope);
137
+ const decision = resolveEntityDecision({
138
+ normalizedName,
139
+ vector,
140
+ vectorEmbedderId: this.#embedderId(),
141
+ candidates,
142
+ mergeThreshold: this.#mergeThreshold,
143
+ adjudicateThreshold: this.#adjudicateThreshold
144
+ });
145
+ if (decision.kind === "match") return decision.entityId;
146
+ if (decision.kind === "ambiguous") {
147
+ if (this.#llmAdjudication && this.#provider !== null) {
148
+ if (await this.#adjudicate(rawName, decision.entityId, candidates, opts.signal)) return decision.entityId;
149
+ }
150
+ }
151
+ return this.#create(scope, rawName, normalizedName, vector);
152
+ }
153
+ /**
154
+ * Resolve + link a fact's subject and object (the predicate is a
155
+ * relation label, never an entity). Idempotent on re-link.
156
+ */
157
+ async linkFact(scope, fact, opts = {}) {
158
+ if (fact.subject !== void 0) {
159
+ const id = await this.resolve(scope, fact.subject, opts);
160
+ if (id !== null) await this.#store.linkFactEntity(fact.id, id, "subject");
161
+ }
162
+ if (fact.object !== void 0) {
163
+ const id = await this.resolve(scope, fact.object, opts);
164
+ if (id !== null) await this.#store.linkFactEntity(fact.id, id, "object");
165
+ }
166
+ }
167
+ async #embed(name, signal) {
168
+ const embedder = this.#embedder;
169
+ if (embedder === null || this.#embedderId() === null) return null;
170
+ try {
171
+ const [vector] = await embedder.embed([name]);
172
+ return vector ?? null;
173
+ } catch {
174
+ return null;
175
+ }
176
+ }
177
+ async #create(scope, name, normalizedName, vector) {
178
+ const embedderId = this.#embedderId();
179
+ return this.#store.upsertEntity(scope, {
180
+ name,
181
+ normalizedName,
182
+ ...vector !== null ? { vector } : {},
183
+ ...vector !== null && embedderId !== null ? { embedderId } : {}
184
+ });
185
+ }
186
+ async #adjudicate(name, candidateId, candidates, signal) {
187
+ const provider = this.#provider;
188
+ if (provider === null) return false;
189
+ const candidate = candidates.find((c) => c.id === candidateId);
190
+ if (candidate === void 0) return false;
191
+ try {
192
+ const request = buildAdjudicationRequest(name, candidate.name, { ...signal !== void 0 ? { signal } : {} });
193
+ return parseAdjudication((await provider.generate(request)).text ?? "");
194
+ } catch {
195
+ return false;
196
+ }
197
+ }
198
+ };
199
+
200
+ //#endregion
201
+ export { DEFAULT_ADJUDICATE_THRESHOLD, DEFAULT_MERGE_THRESHOLD, EntityResolver, buildAdjudicationRequest, cosineSimilarity, normalizeEntityName, parseAdjudication, resolveEntityDecision };
202
+ //# sourceMappingURL=entity-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-resolver.js","names":["bestId: string | null","#store","#embedder","#embedderId","#provider","#mergeThreshold","#adjudicateThreshold","#llmAdjudication","#embed","#create","#adjudicate"],"sources":["../../src/graph/entity-resolver.ts"],"sourcesContent":["/**\n * Entity resolution for the lightweight in-SQLite relation graph (P2-1).\n *\n * Raw `subject` / `object` strings on facts fragment (\"Anna\", \"Anna S.\",\n * \"my sister\" become unrelated rows), which kills multi-hop recall. This\n * module folds them into **canonical entities** so the one-hop CTE can\n * traverse relationships. Resolution is layered, cheapest first:\n *\n * 1. **lexical** — exact match on the folded {@link normalizeEntityName}.\n * 2. **embedding** — cosine over candidate name vectors; `≥ mergeThreshold`\n * reuses the match.\n * 3. **adjudication** — a middle similarity band (`[adjudicate, merge)`)\n * is *ambiguous*; an opt-in LLM call (provider + `llmAdjudication`)\n * decides. **Offline / by default the ambiguous band mints a new\n * entity** — the resolver never auto-merges on weak evidence, because\n * a wrong merge fuses two distinct people (the stated P2-1 risk).\n *\n * The pure policy ({@link resolveEntityDecision}) is provider-agnostic and\n * does no I/O; {@link EntityResolver} wires it to an injected store +\n * embedder + optional provider. With no embedder it degrades to\n * lexical-only — still useful, and still fully offline.\n *\n * @packageDocumentation\n */\n\nimport type {\n EmbedderProvider,\n Fact,\n Provider,\n ProviderRequest,\n SessionScope,\n} from '@graphorin/core';\nimport type { EntityWithEmbedding, GraphMemoryStoreExt } from '../internal/storage-adapter.js';\n\n/** Cosine `≥` this auto-reuses an existing entity (embedding match). */\nexport const DEFAULT_MERGE_THRESHOLD = 0.92;\n/** Cosine in `[this, merge)` is *ambiguous* — adjudicate or mint new. */\nexport const DEFAULT_ADJUDICATE_THRESHOLD = 0.82;\n\n/**\n * Outcome of the pure resolution policy. `match` reuses an existing\n * entity; `ambiguous` flags a middle-similarity candidate for the caller\n * to adjudicate (or conservatively reject); `new` mints a fresh entity.\n *\n * @stable\n */\nexport type EntityResolveDecision =\n | {\n readonly kind: 'match';\n readonly entityId: string;\n readonly similarity: number;\n readonly via: 'lexical' | 'embedding';\n }\n | { readonly kind: 'ambiguous'; readonly entityId: string; readonly similarity: number }\n | { readonly kind: 'new' };\n\n/** Minimal candidate shape the pure policy compares against. */\nexport interface ResolutionCandidate {\n readonly id: string;\n readonly normalizedName: string;\n readonly vector: Float32Array | null;\n /**\n * MST-11: the embedder that produced `vector`. When both this and the\n * query's `vectorEmbedderId` are known and differ, the candidate is skipped\n * for embedding comparison — vectors from different models live in different\n * spaces, so their cosine is meaningless. Absent on either side ⇒ compared\n * (byte-identical to the prior behaviour).\n */\n readonly embedderId?: string | null;\n}\n\n/** Inputs to {@link resolveEntityDecision} (all provided by the caller). */\nexport interface ResolveDecisionInput {\n readonly normalizedName: string;\n readonly vector?: Float32Array | null;\n /** MST-11: the embedder that produced `vector` (gates cross-embedder cosine). */\n readonly vectorEmbedderId?: string | null;\n readonly candidates: ReadonlyArray<ResolutionCandidate>;\n readonly mergeThreshold: number;\n readonly adjudicateThreshold: number;\n}\n\n/**\n * Fold an entity surface form into a canonical lexical key: Unicode\n * NFKC, lowercased, internal whitespace collapsed, surrounding\n * punctuation stripped. `\" Anna S. \"` → `\"anna s\"`. Returns `''` for a\n * name with no letters/digits (the resolver treats that as \"no entity\").\n *\n * @stable\n */\nexport function normalizeEntityName(name: string): string {\n return name\n .normalize('NFKC')\n .toLowerCase()\n .replace(/\\s+/g, ' ')\n .trim()\n .replace(/^[^\\p{L}\\p{N}]+|[^\\p{L}\\p{N}]+$/gu, '');\n}\n\n/**\n * Cosine similarity of two embeddings in `[-1, 1]`. Compares over the\n * shorter length and returns `0` when either vector is empty / zero-norm.\n *\n * @stable\n */\nexport function cosineSimilarity(a: Float32Array, b: Float32Array): number {\n const len = Math.min(a.length, b.length);\n let dot = 0;\n let na = 0;\n let nb = 0;\n for (let i = 0; i < len; i++) {\n const ai = a[i] ?? 0;\n const bi = b[i] ?? 0;\n dot += ai * bi;\n na += ai * ai;\n nb += bi * bi;\n }\n if (na === 0 || nb === 0) return 0;\n return dot / Math.sqrt(na * nb);\n}\n\n/**\n * Pure resolution policy: lexical exact match → embedding cosine →\n * ambiguous band → new. No I/O; deterministic. The caller decides what\n * to do with `ambiguous` (LLM adjudicate, or conservatively mint new).\n *\n * @stable\n */\nexport function resolveEntityDecision(input: ResolveDecisionInput): EntityResolveDecision {\n // 1. Exact lexical match is the cheapest + strongest signal.\n for (const c of input.candidates) {\n if (c.normalizedName === input.normalizedName) {\n return { kind: 'match', entityId: c.id, similarity: 1, via: 'lexical' };\n }\n }\n // 2. Embedding similarity (only when both sides have a vector).\n const v = input.vector;\n if (v === undefined || v === null || v.length === 0) return { kind: 'new' };\n let bestId: string | null = null;\n let bestSim = Number.NEGATIVE_INFINITY;\n for (const c of input.candidates) {\n if (c.vector === null || c.vector.length === 0) continue;\n // MST-11: never compare vectors across embedders — different models live\n // in different vector spaces, so their cosine is meaningless. Skip only\n // when both embedder ids are known and differ.\n if (\n input.vectorEmbedderId != null &&\n c.embedderId != null &&\n c.embedderId !== input.vectorEmbedderId\n ) {\n continue;\n }\n const sim = cosineSimilarity(v, c.vector);\n if (sim > bestSim) {\n bestSim = sim;\n bestId = c.id;\n }\n }\n if (bestId === null) return { kind: 'new' };\n if (bestSim >= input.mergeThreshold) {\n return { kind: 'match', entityId: bestId, similarity: bestSim, via: 'embedding' };\n }\n if (bestSim >= input.adjudicateThreshold) {\n return { kind: 'ambiguous', entityId: bestId, similarity: bestSim };\n }\n return { kind: 'new' };\n}\n\n/** Tunable thresholds + LLM-adjudication switch for {@link EntityResolver}. */\nexport interface EntityResolutionConfig {\n /** Cosine `≥` this auto-reuses a match. Default {@link DEFAULT_MERGE_THRESHOLD}. */\n readonly mergeThreshold?: number;\n /** Cosine in `[this, merge)` is ambiguous. Default {@link DEFAULT_ADJUDICATE_THRESHOLD}. */\n readonly adjudicateThreshold?: number;\n /**\n * Resolve the ambiguous band with one provider call. Requires a\n * `provider`. Default `false` ⇒ ambiguous mints a new entity (no\n * network call; never auto-merges on weak evidence).\n */\n readonly llmAdjudication?: boolean;\n}\n\n/** Construction deps for {@link EntityResolver}. */\nexport interface EntityResolverDeps {\n readonly store: GraphMemoryStoreExt;\n readonly embedder?: EmbedderProvider | null;\n readonly embedderId?: () => string | null;\n readonly provider?: Provider | null;\n readonly config?: EntityResolutionConfig;\n}\n\nconst ADJUDICATION_SYSTEM_PROMPT =\n 'You decide whether two short names refer to the SAME real-world entity ' +\n '(person, place, org, thing). Reply with a single word: \"yes\" or \"no\". ' +\n 'Be conservative — answer \"no\" unless they are clearly the same entity.';\n\n/** Build the (pure) adjudication request. Exposed for testing. */\nexport function buildAdjudicationRequest(\n nameA: string,\n nameB: string,\n options: { readonly signal?: AbortSignal } = {},\n): ProviderRequest {\n return {\n messages: [{ role: 'user', content: `Name A: ${nameA}\\nName B: ${nameB}\\nSame entity?` }],\n systemMessage: ADJUDICATION_SYSTEM_PROMPT,\n temperature: 0,\n maxTokens: 4,\n ...(options.signal !== undefined ? { signal: options.signal } : {}),\n };\n}\n\n/** Parse a yes/no adjudication reply. Conservative: only a clear yes is `true`. */\nexport function parseAdjudication(text: string): boolean {\n return /^\\s*(yes|true|same)\\b/i.test(text);\n}\n\n/**\n * Resolves a fact's subject / object strings to canonical entity ids and\n * links them, applying {@link resolveEntityDecision} backed by an\n * injected store + embedder (+ optional provider for adjudication).\n * Constructed only when entity resolution is opted in\n * (`createMemory({ graph: { entityResolution: true } })`); otherwise the\n * write path skips it and behaviour is unchanged + offline.\n *\n * @stable\n */\nexport class EntityResolver {\n readonly #store: GraphMemoryStoreExt;\n readonly #embedder: EmbedderProvider | null;\n readonly #embedderId: () => string | null;\n readonly #provider: Provider | null;\n readonly #mergeThreshold: number;\n readonly #adjudicateThreshold: number;\n readonly #llmAdjudication: boolean;\n\n constructor(deps: EntityResolverDeps) {\n this.#store = deps.store;\n this.#embedder = deps.embedder ?? null;\n this.#embedderId = deps.embedderId ?? (() => null);\n this.#provider = deps.provider ?? null;\n this.#mergeThreshold = deps.config?.mergeThreshold ?? DEFAULT_MERGE_THRESHOLD;\n this.#adjudicateThreshold = deps.config?.adjudicateThreshold ?? DEFAULT_ADJUDICATE_THRESHOLD;\n this.#llmAdjudication = deps.config?.llmAdjudication ?? false;\n }\n\n /**\n * Resolve a single name to a canonical entity id (find-or-create),\n * deduping via lexical + embedding similarity. Returns `null` for a\n * name that normalizes to empty (no entity).\n */\n async resolve(\n scope: SessionScope,\n rawName: string,\n opts: { readonly signal?: AbortSignal } = {},\n ): Promise<string | null> {\n const normalizedName = normalizeEntityName(rawName);\n if (normalizedName.length === 0) return null;\n // 1. Exact lexical match — the cheapest, strongest signal. Resolve it via\n // an uncapped indexed lookup so an alias of an arbitrarily-old entity\n // dedups without scanning (and deserializing) the bounded candidate\n // window, and short-circuits before any embedding call (CS-11). Stores\n // that don't implement it fall through to the capped lexical scan below.\n const exact = await this.#store.findEntityByNormalizedName?.(scope, normalizedName);\n if (exact != null) return exact.id;\n const vector = await this.#embed(rawName, opts.signal);\n // 2. Without a query vector, embedding dedup is impossible — skip the\n // BLOB-deserializing candidate scan entirely and mint a new entity.\n if (vector === null || vector.length === 0) {\n return this.#create(scope, rawName, normalizedName, vector);\n }\n const candidates = await this.#store.listEntities(scope);\n const decision = resolveEntityDecision({\n normalizedName,\n vector,\n vectorEmbedderId: this.#embedderId(),\n candidates,\n mergeThreshold: this.#mergeThreshold,\n adjudicateThreshold: this.#adjudicateThreshold,\n });\n if (decision.kind === 'match') return decision.entityId;\n if (decision.kind === 'ambiguous') {\n if (this.#llmAdjudication && this.#provider !== null) {\n const same = await this.#adjudicate(rawName, decision.entityId, candidates, opts.signal);\n if (same) return decision.entityId;\n }\n // Conservative default: weak evidence ⇒ a distinct new entity.\n }\n return this.#create(scope, rawName, normalizedName, vector);\n }\n\n /**\n * Resolve + link a fact's subject and object (the predicate is a\n * relation label, never an entity). Idempotent on re-link.\n */\n async linkFact(\n scope: SessionScope,\n fact: Fact,\n opts: { readonly signal?: AbortSignal } = {},\n ): Promise<void> {\n if (fact.subject !== undefined) {\n const id = await this.resolve(scope, fact.subject, opts);\n if (id !== null) await this.#store.linkFactEntity(fact.id, id, 'subject');\n }\n if (fact.object !== undefined) {\n const id = await this.resolve(scope, fact.object, opts);\n if (id !== null) await this.#store.linkFactEntity(fact.id, id, 'object');\n }\n }\n\n async #embed(name: string, signal?: AbortSignal): Promise<Float32Array | null> {\n const embedder = this.#embedder;\n if (embedder === null || this.#embedderId() === null) return null;\n void signal;\n try {\n const [vector] = await embedder.embed([name]);\n return vector ?? null;\n } catch {\n return null;\n }\n }\n\n async #create(\n scope: SessionScope,\n name: string,\n normalizedName: string,\n vector: Float32Array | null,\n ): Promise<string> {\n const embedderId = this.#embedderId();\n return this.#store.upsertEntity(scope, {\n name,\n normalizedName,\n ...(vector !== null ? { vector } : {}),\n ...(vector !== null && embedderId !== null ? { embedderId } : {}),\n });\n }\n\n async #adjudicate(\n name: string,\n candidateId: string,\n candidates: ReadonlyArray<EntityWithEmbedding>,\n signal?: AbortSignal,\n ): Promise<boolean> {\n const provider = this.#provider;\n if (provider === null) return false;\n const candidate = candidates.find((c) => c.id === candidateId);\n if (candidate === undefined) return false;\n try {\n const request = buildAdjudicationRequest(name, candidate.name, {\n ...(signal !== undefined ? { signal } : {}),\n });\n const response = await provider.generate(request);\n return parseAdjudication(response.text ?? '');\n } catch {\n return false;\n }\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1 @@
1
+ import { DEFAULT_ADJUDICATE_THRESHOLD, DEFAULT_MERGE_THRESHOLD, EntityResolutionConfig, EntityResolveDecision, EntityResolver, EntityResolverDeps, ResolutionCandidate, ResolveDecisionInput, buildAdjudicationRequest, cosineSimilarity, normalizeEntityName, parseAdjudication, resolveEntityDecision } from "./entity-resolver.js";
@@ -0,0 +1,103 @@
1
+ import { EmbedderMigrationAbortedError, EmbedderMigrationLockedError, EmbedderMigrationStateError, EmbedderRegistrationError, GraphorinMemoryError, MemoryToolDeniedError, ProcedureInductionNotConfiguredError, QuarantinePromotionRefusedError, WorkingBlockOverflowError, WorkingBlockReadOnlyError, WorkingBlockReplaceMismatchError } from "./errors/index.js";
2
+ import { LocaleMatch, LocalePack, LocalePatternEntry, LocaleSupersedeKind, defineLocalePack, evaluateMarkers } from "./conflict/locale-packs/types.js";
3
+ import { ConflictAuditDecision, ConflictAuditInputLike, ConflictAuditStage, ConflictMemoryStoreExt, ConsolidatorMemoryStoreExt, ConsolidatorRunFinish, ConsolidatorRunInput, ConsolidatorStatePatch, ConsolidatorStateRow, DecayMemoryStoreExt, DlqBatchInput, DlqBatchRow, EmbeddedWriteOptions, EmbeddingMetaRegistryLike, EpisodicMemoryStoreExt, InsightListOptions as InsightListOptions$1, InsightMemoryStoreExt, InsightSearchStoreOptions, MemoryStoreAdapter, PendingConflictInputLike, PendingConflictRowLike, SemanticMemoryStoreExt, SessionMemoryStoreExt, SessionMessageRecord } from "./internal/storage-adapter.js";
4
+ import { ConflictDecision, ConflictPipeline, ConflictPipelineDeps, ConflictPipelineOptions, ConflictStage, ConflictThresholds, DEFAULT_CONFLICT_THRESHOLDS, PipelineStage, ReconcileAction, ReconcileDecision, StageContext, StageOutcome, reconcileToConflictDecision } from "./conflict/types.js";
5
+ import { _resetBypassWarningForTesting, createConflictPipeline, runConflictPipeline } from "./conflict/pipeline.js";
6
+ import "./conflict/index.js";
7
+ import { ContextualRetrievalMode } from "./internal/contextualize.js";
8
+ import { EpisodeInput, EpisodeRetrievalWeights, EpisodeSearchOptions, EpisodicMemory } from "./tiers/episodic-memory.js";
9
+ import { DEFAULT_ADJUDICATE_THRESHOLD, DEFAULT_MERGE_THRESHOLD, EntityResolutionConfig, EntityResolveDecision, EntityResolver, EntityResolverDeps, ResolutionCandidate, ResolveDecisionInput, buildAdjudicationRequest, cosineSimilarity, normalizeEntityName, parseAdjudication, resolveEntityDecision } from "./graph/entity-resolver.js";
10
+ import { DEFAULT_DIFFICULTY_THRESHOLD, DEFAULT_MAX_ITERATIONS, DifficultyAssessment, DifficultyGateOptions, IterativeRetrievalDeps, IterativeRetrievalOptions, IterativeRetrievalResult, MAX_ITERATIONS_CEILING, RETRIEVAL_GRADE_SYSTEM_PROMPT, RetrievalGrade, RetrievalGradeOptions, RetrievalGrader, assessQueryDifficulty, buildGradeRequest, createProviderRetrievalGrader, parseGrade, runIterativeRetrieval } from "./search/iterative.js";
11
+ import { DEFAULT_MAX_QUERY_VARIANTS, HYDE_SYSTEM_PROMPT, QUERY_EXPANSION_SYSTEM_PROMPT, QueryTransformOptions, QueryTransformer, buildExpansionRequest, buildHydeRequest, createProviderQueryTransformer, parseHypothetical, parseQueryVariants } from "./search/query-transform.js";
12
+ import { ReRankOptions, ReRanker } from "./search/types.js";
13
+ import { FactInput, FactRememberOptions, FactSearchOptions, FusionStrategy, FusionWeights, IterativeRecallResult, IterativeSearchOptions, RememberOutcome, SemanticMemory } from "./tiers/semantic-memory.js";
14
+ import { CONSOLIDATOR_TIER_DEFAULTS, ConsolidatorBudgetSnapshot, ConsolidatorCeilings, ConsolidatorConfig, ConsolidatorLastRuns, ConsolidatorPhase, ConsolidatorStatus, ConsolidatorTier, ConsolidatorTriggerReason, ConsolidatorTriggerSpec, CreateConsolidatorOptions, OnBudgetExceed, PhaseListener, PhaseOutcome } from "./consolidator/types.js";
15
+ import { ParsedTrigger, parseTriggerSpec, reasonFromTrigger } from "./consolidator/triggers.js";
16
+ import { ConsolidatorCatchupPolicy, RegisterTriggersOptions, RegisterTriggersResult, SchedulerLike, TriggerDeclarationLike, registerConsolidatorTriggers } from "./consolidator/scheduler.js";
17
+ import { Consolidator, createConsolidator } from "./consolidator/runtime.js";
18
+ import { BudgetExceededError, CustomTierMisconfiguredError, ProviderNotConfiguredError } from "./consolidator/errors.js";
19
+ import { DEFAULT_INDUCTION_MAX_TOKENS, INDUCTION_SYSTEM_PROMPT, InducedProcedure, MAX_PROCEDURE_STEPS, MAX_TRAJECTORY_STEPS_SHOWN, Trajectory, TrajectoryStep, VerificationResult, WorkflowInducer, WorkflowInductionOptions, buildInductionRequest, checkSuccessCriteria, createProviderWorkflowInducer, normalizeInducedProcedure, parseInducedProcedure, runWorkflowInduction, trajectoryFromRunState } from "./consolidator/phases/induce.js";
20
+ import { createConsolidatorPlaceholder } from "./consolidator/index.js";
21
+ import { CONTENT_ORIGIN_ATTR, ContentAnnotation, ContentOrigin, INBOUND_TRUST_ATTR, InboundTrust, NON_INBOUND_ORIGINS, annotate, shouldFireInboundPreamble, toSpanAttributes } from "./context-engine/annotations.js";
22
+ import { AutoRecallTriggers, BaseTemplateFragments, CompactionSummaryTemplate, ContextLocalePack, InboundSanitizationPreamble, PartialContextLocalePack, defineContextLocalePack } from "./context-engine/locale-packs/types.js";
23
+ import { enLocalePack } from "./context-engine/locale-packs/en.js";
24
+ import { AutoRecallStrategy, AutoRecallStrategyContext, AutoRecallTriggerResult, defaultLocaleHeuristicStrategy, defineAutoRecallStrategy } from "./context-engine/auto-recall.js";
25
+ import { ContextTokenCounter, HEURISTIC_TOKEN_COUNTER, adaptTokenCounter, countMessageTokens, renderMessageText } from "./context-engine/token-counter.js";
26
+ import { CLEARED_TOOL_RESULT_MARKER, ClearToolResultsOptions, ClearToolResultsOutcome, clearOldToolResults } from "./context-engine/compaction/clear-tool-results.js";
27
+ import { CompactionConfig, CompactionContext, CompactionResult, CompactionSource, CompactionStrategy, CompactionSummarizer, CompactionTriggerConfig, PostCompactionHook, PostCompactionHookContext } from "./context-engine/compaction/types.js";
28
+ import { DEFAULT_PRESERVE_RECENT_TURNS, ExecuteCompactionInput, executeCompaction } from "./context-engine/compaction/compactor.js";
29
+ import { NamedPostCompactionHook } from "./context-engine/compaction/hooks/types.js";
30
+ import { reanchorPersonaBlock } from "./context-engine/compaction/hooks/reanchor-persona-block.js";
31
+ import { reanchorPinnedFacts } from "./context-engine/compaction/hooks/reanchor-pinned-facts.js";
32
+ import { reanchorProjectRules } from "./context-engine/compaction/hooks/reanchor-project-rules.js";
33
+ import { CompactionMetadataPayload, RenderedTemplate, SUMMARY_TEMPLATE_NAME, SUMMARY_TEMPLATE_VERSION, buildSummarizerPrompt, renderFinalSummary } from "./context-engine/compaction/templates/summary-9-section.js";
34
+ import { AutoCompactionDefault, DEFAULT_RESERVED_FOR_COMPACTION, DEFAULT_RESERVED_FOR_RESPONSE, DEFAULT_THRESHOLD_RATIO, resolveAutoCompactionDefault, resolveTriggerThreshold } from "./context-engine/compaction/thresholds.js";
35
+ import { PartitionResult, PrivacyDecision, PrivacyDecisionReason, PrivacyFilterContext, decide, effectiveAcceptsSensitivity, partition } from "./context-engine/privacy-filter.js";
36
+ import { MemoryBaseMode, SkillMetadataCard, composeInboundPreamble, composeLayer1, composeLayer2, composeLayer4Skills } from "./context-engine/templates/composer.js";
37
+ import { AllocationResult, DEFAULT_LAYER_PRIORITY, LayerAllocation, LayerCandidate, LayerId, OverflowMode, allocate, truncateToTokens } from "./context-engine/token-budget.js";
38
+ import { AnnotatedPart, AssembleInput, AssembledPrompt, AutoRecallConfig, ContextEngine, ContextEngineConfig, LayerConfig, PrivacyConfig, ResolvedContextEngineConfig, createContextEngine } from "./context-engine/engine.js";
39
+ import { LocaleResolverLogger, _getLocaleFallbackWarningsForTesting, _resetLocaleFallbackWarningsForTesting, resolveLocalePack } from "./context-engine/locale-packs/resolver.js";
40
+ import { MemoryMetadataDeps, gatherMemoryMetadata, renderMetadataBlock } from "./context-engine/metadata.js";
41
+ import { INBOUND_SANITIZATION_PREAMBLE_EN } from "./context-engine/preambles/inbound-en.js";
42
+ import { BASE_TEMPLATE_EN_FULL, BASE_TEMPLATE_EN_MINIMAL } from "./context-engine/templates/base-en.js";
43
+ import { CompileOptions, CompileScope, MemoryContextBlocks } from "./context-engine/index.js";
44
+ import { InsightListOptions, InsightMemory, InsightSearchOptions, capInsightsBelowFacts } from "./tiers/insight-memory.js";
45
+ import { InduceOptions, ProceduralMemory, RuleActivationContext, RuleInput } from "./tiers/procedural-memory.js";
46
+ import { SessionCompactionPolicy, SessionCompactionResult, SessionMemory } from "./tiers/session-memory.js";
47
+ import { SharedMemory } from "./tiers/shared-memory.js";
48
+ import { BlockDefinition, BlockSpec, WorkingMemory, defineBlock } from "./tiers/working-memory.js";
49
+ import { MemoryToolDeps, ScopeResolver } from "./tools/types.js";
50
+ import { createBlockAppendTool, createBlockReplaceTool, createBlockRethinkTool } from "./tools/block-tools.js";
51
+ import { createFactForgetTool, createFactHistoryTool, createFactRememberTool, createFactSearchTool, createFactSupersedeTool, createFactValidateTool } from "./tools/fact-tools.js";
52
+ import { createConversationSearchTool, createDeepRecallTool, createRecallEpisodesTool } from "./tools/recall-tools.js";
53
+ import { BuildMemoryToolsOptions, buildMemoryTools } from "./tools/index.js";
54
+ import { CreateMemoryOptions, Memory, _resetConsolidatorConfigWarningForTesting, createMemory } from "./facade.js";
55
+ import "./graph/index.js";
56
+ import { EmbedderMigrationStrategy, MigrateEmbedderOptions, MigrationProgress, migrateEmbedder } from "./migration/embedder-migration.js";
57
+ import "./migration/index.js";
58
+ import { RecallExplanation, RecalledMemoryExplanation, explainRecall, formatRecallExplanation } from "./search/explain.js";
59
+ import { RRFReranker, RRF_DEFAULT_K, WeightedRRFReranker, fuseRrf, fuseWeighted } from "./search/rrf.js";
60
+ import "./search/index.js";
61
+ import "./tiers/index.js";
62
+
63
+ //#region src/index.d.ts
64
+ /**
65
+ * `@graphorin/memory` — seven-tier memory system for the Graphorin
66
+ * framework (MST-13: working / session / episodic / semantic /
67
+ * procedural / shared + the read-only insight tier from P1-1).
68
+ *
69
+ * Surface overview:
70
+ *
71
+ * - The {@link createMemory} facade that wires every tier sub-module
72
+ * + the memory tools + the search reranker + the context-engine +
73
+ * the consolidator.
74
+ * - Tier sub-modules under `./tiers`: {@link WorkingMemory},
75
+ * {@link SessionMemory}, {@link EpisodicMemory}, {@link SemanticMemory},
76
+ * {@link ProceduralMemory}, {@link SharedMemory}, plus the read-only
77
+ * {@link InsightMemory}.
78
+ * - Eleven memory tools under `./tools` (plus the gated twelfth,
79
+ * `deep_recall`, registered only when iterative retrieval is
80
+ * configured): `block_append`, `block_replace`, `block_rethink`,
81
+ * `fact_remember`, `fact_search`, `fact_supersede`, `fact_forget`,
82
+ * `recall_episodes`, `conversation_search`, `fact_history` (P0-2),
83
+ * `fact_validate` (P1-4).
84
+ * - The hybrid search composition under `./search`, including the
85
+ * built-in {@link RRFReranker} (k=60 default) and the
86
+ * {@link ReRanker} contract.
87
+ * - The embedder migration runner under `./migration`
88
+ * ({@link migrateEmbedder} with three coexistence policies).
89
+ * - Typed errors under `./errors`.
90
+ *
91
+ * Forward-looking surfaces (for ergonomic typing today):
92
+ *
93
+ * - {@link MemoryContextBlocks} + {@link CompileOptions} from `./context-engine`.
94
+ * - {@link Consolidator}, {@link ConsolidatorTriggerSpec},
95
+ * {@link ConsolidatorTier} from `./consolidator`.
96
+ *
97
+ * @packageDocumentation
98
+ */
99
+ /** Canonical version constant. Mirrors the `package.json` version. */
100
+ declare const VERSION = "0.5.0";
101
+ //#endregion
102
+ export { type AllocationResult, type AnnotatedPart, type AssembleInput, type AssembledPrompt, type AutoCompactionDefault, type AutoRecallConfig, type AutoRecallStrategy, type AutoRecallStrategyContext, type AutoRecallTriggerResult, type AutoRecallTriggers, BASE_TEMPLATE_EN_FULL, BASE_TEMPLATE_EN_MINIMAL, type BaseTemplateFragments, BlockDefinition, BlockSpec, BudgetExceededError, type BuildMemoryToolsOptions, CLEARED_TOOL_RESULT_MARKER, CONSOLIDATOR_TIER_DEFAULTS, CONTENT_ORIGIN_ATTR, type ClearToolResultsOptions, type ClearToolResultsOutcome, type CompactionConfig, type CompactionContext, type CompactionMetadataPayload, type CompactionResult, type CompactionSource, type CompactionStrategy, type CompactionSummarizer, type CompactionSummaryTemplate, type CompactionTriggerConfig, type CompileOptions, type CompileScope, type ConflictAuditDecision, type ConflictAuditInputLike, type ConflictAuditStage, ConflictDecision, type ConflictMemoryStoreExt, ConflictPipeline, ConflictPipelineDeps, ConflictPipelineOptions, ConflictStage, ConflictThresholds, type Consolidator, type ConsolidatorBudgetSnapshot, type ConsolidatorCatchupPolicy, type ConsolidatorCeilings, type ConsolidatorConfig, type ConsolidatorLastRuns, type ConsolidatorMemoryStoreExt, type ConsolidatorPhase, type ConsolidatorRunFinish, type ConsolidatorRunInput, type ConsolidatorStatePatch, type ConsolidatorStateRow, type ConsolidatorStatus, type ConsolidatorTier, type ConsolidatorTriggerReason, type ConsolidatorTriggerSpec, type ContentAnnotation, type ContentOrigin, type ContextEngine, type ContextEngineConfig, type ContextLocalePack, type ContextTokenCounter, type ContextualRetrievalMode, type CreateConsolidatorOptions, type CreateMemoryOptions, CustomTierMisconfiguredError, DEFAULT_ADJUDICATE_THRESHOLD, DEFAULT_CONFLICT_THRESHOLDS, DEFAULT_DIFFICULTY_THRESHOLD, DEFAULT_INDUCTION_MAX_TOKENS, DEFAULT_LAYER_PRIORITY, DEFAULT_MAX_ITERATIONS, DEFAULT_MAX_QUERY_VARIANTS, DEFAULT_MERGE_THRESHOLD, DEFAULT_PRESERVE_RECENT_TURNS, DEFAULT_RESERVED_FOR_COMPACTION, DEFAULT_RESERVED_FOR_RESPONSE, DEFAULT_THRESHOLD_RATIO, type DecayMemoryStoreExt, DifficultyAssessment, DifficultyGateOptions, type DlqBatchInput, type DlqBatchRow, type EmbeddedWriteOptions, EmbedderMigrationAbortedError, EmbedderMigrationLockedError, EmbedderMigrationStateError, EmbedderMigrationStrategy, EmbedderRegistrationError, type EmbeddingMetaRegistryLike, EntityResolutionConfig, EntityResolveDecision, EntityResolver, EntityResolverDeps, EpisodeInput, EpisodeRetrievalWeights, EpisodeSearchOptions, EpisodicMemory, type EpisodicMemoryStoreExt, type ExecuteCompactionInput, FactInput, FactRememberOptions, FactSearchOptions, FusionStrategy, FusionWeights, GraphorinMemoryError, HEURISTIC_TOKEN_COUNTER, HYDE_SYSTEM_PROMPT, INBOUND_SANITIZATION_PREAMBLE_EN, INBOUND_TRUST_ATTR, INDUCTION_SYSTEM_PROMPT, type InboundSanitizationPreamble, type InboundTrust, InduceOptions, type InducedProcedure, InsightListOptions, InsightMemory, type InsightMemoryStoreExt, InsightSearchOptions, type InsightSearchStoreOptions, type InsightListOptions$1 as InsightStoreListOptions, IterativeRecallResult, IterativeRetrievalDeps, IterativeRetrievalOptions, IterativeRetrievalResult, IterativeSearchOptions, type LayerAllocation, type LayerCandidate, type LayerConfig, type LayerId, LocaleMatch, LocalePack, LocalePatternEntry, type LocaleResolverLogger, LocaleSupersedeKind, MAX_ITERATIONS_CEILING, MAX_PROCEDURE_STEPS, MAX_TRAJECTORY_STEPS_SHOWN, type Memory, type MemoryBaseMode, type MemoryContextBlocks, type MemoryMetadataDeps, type MemoryStoreAdapter, MemoryToolDeniedError, type MemoryToolDeps, MigrateEmbedderOptions, MigrationProgress, NON_INBOUND_ORIGINS, type NamedPostCompactionHook, type OnBudgetExceed, type OverflowMode, type ParsedTrigger, type PartialContextLocalePack, type PartitionResult, type PendingConflictInputLike, type PendingConflictRowLike, type PhaseListener, type PhaseOutcome, PipelineStage, type PostCompactionHook, type PostCompactionHookContext, type PrivacyConfig, type PrivacyDecision, type PrivacyDecisionReason, type PrivacyFilterContext, ProceduralMemory, ProcedureInductionNotConfiguredError, ProviderNotConfiguredError, QUERY_EXPANSION_SYSTEM_PROMPT, QuarantinePromotionRefusedError, QueryTransformOptions, QueryTransformer, RETRIEVAL_GRADE_SYSTEM_PROMPT, RRFReranker, RRF_DEFAULT_K, ReRankOptions, ReRanker, RecallExplanation, RecalledMemoryExplanation, ReconcileAction, ReconcileDecision, type RegisterTriggersOptions, type RegisterTriggersResult, RememberOutcome, type RenderedTemplate, ResolutionCandidate, ResolveDecisionInput, type ResolvedContextEngineConfig, RetrievalGrade, RetrievalGradeOptions, RetrievalGrader, RuleActivationContext, RuleInput, SUMMARY_TEMPLATE_NAME, SUMMARY_TEMPLATE_VERSION, type SchedulerLike, type ScopeResolver, SemanticMemory, type SemanticMemoryStoreExt, SessionCompactionPolicy, SessionCompactionResult, SessionMemory, type SessionMemoryStoreExt, type SessionMessageRecord, SharedMemory, type SkillMetadataCard, StageContext, StageOutcome, type Trajectory, type TrajectoryStep, type TriggerDeclarationLike, VERSION, type VerificationResult, WeightedRRFReranker, type WorkflowInducer, type WorkflowInductionOptions, WorkingBlockOverflowError, WorkingBlockReadOnlyError, WorkingBlockReplaceMismatchError, WorkingMemory, _getLocaleFallbackWarningsForTesting, _resetBypassWarningForTesting, _resetConsolidatorConfigWarningForTesting, _resetLocaleFallbackWarningsForTesting, adaptTokenCounter, allocate as allocateTokenBudget, annotate, assessQueryDifficulty, buildAdjudicationRequest, buildExpansionRequest, buildGradeRequest, buildHydeRequest, buildInductionRequest, buildMemoryTools, buildSummarizerPrompt, capInsightsBelowFacts, checkSuccessCriteria, clearOldToolResults, composeInboundPreamble, composeLayer1, composeLayer2, composeLayer4Skills, cosineSimilarity, countMessageTokens, createBlockAppendTool, createBlockReplaceTool, createBlockRethinkTool, createConflictPipeline, createConsolidator, createConsolidatorPlaceholder, createContextEngine, createConversationSearchTool, createDeepRecallTool, createFactForgetTool, createFactHistoryTool, createFactRememberTool, createFactSearchTool, createFactSupersedeTool, createFactValidateTool, createMemory, createProviderQueryTransformer, createProviderRetrievalGrader, createProviderWorkflowInducer, createRecallEpisodesTool, defaultLocaleHeuristicStrategy, defineAutoRecallStrategy, defineBlock, defineContextLocalePack, defineLocalePack, effectiveAcceptsSensitivity, enLocalePack, evaluateMarkers, executeCompaction, explainRecall, formatRecallExplanation, fuseRrf, fuseWeighted, gatherMemoryMetadata, migrateEmbedder, normalizeEntityName, normalizeInducedProcedure, parseAdjudication, parseGrade, parseHypothetical, parseInducedProcedure, parseQueryVariants, parseTriggerSpec, partition as partitionBySensitivity, decide as privacyDecide, reanchorPersonaBlock, reanchorPinnedFacts, reanchorProjectRules, reasonFromTrigger, reconcileToConflictDecision, registerConsolidatorTriggers, renderFinalSummary, renderMessageText, renderMetadataBlock, resolveAutoCompactionDefault, resolveEntityDecision, resolveLocalePack, resolveTriggerThreshold, runConflictPipeline, runIterativeRetrieval, runWorkflowInduction, shouldFireInboundPreamble, toSpanAttributes, trajectoryFromRunState, truncateToTokens };
103
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqCa,OAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,95 @@
1
+ import { defineLocalePack, evaluateMarkers } from "./conflict/locale-packs/types.js";
2
+ import { DEFAULT_CONFLICT_THRESHOLDS, reconcileToConflictDecision } from "./conflict/types.js";
3
+ import { _resetBypassWarningForTesting, createConflictPipeline, runConflictPipeline } from "./conflict/pipeline.js";
4
+ import "./conflict/index.js";
5
+ import { EmbedderMigrationAbortedError, EmbedderMigrationLockedError, EmbedderMigrationStateError, EmbedderRegistrationError, GraphorinMemoryError, MemoryToolDeniedError, ProcedureInductionNotConfiguredError, QuarantinePromotionRefusedError, WorkingBlockOverflowError, WorkingBlockReadOnlyError, WorkingBlockReplaceMismatchError } from "./errors/index.js";
6
+ import { BudgetExceededError, CustomTierMisconfiguredError, ProviderNotConfiguredError } from "./consolidator/errors.js";
7
+ import { DEFAULT_INDUCTION_MAX_TOKENS, INDUCTION_SYSTEM_PROMPT, MAX_PROCEDURE_STEPS, MAX_TRAJECTORY_STEPS_SHOWN, buildInductionRequest, checkSuccessCriteria, createProviderWorkflowInducer, normalizeInducedProcedure, parseInducedProcedure, runWorkflowInduction, trajectoryFromRunState } from "./consolidator/phases/induce.js";
8
+ import { parseTriggerSpec, reasonFromTrigger } from "./consolidator/triggers.js";
9
+ import { registerConsolidatorTriggers } from "./consolidator/scheduler.js";
10
+ import { CONSOLIDATOR_TIER_DEFAULTS } from "./consolidator/types.js";
11
+ import { createConsolidator } from "./consolidator/runtime.js";
12
+ import { createConsolidatorPlaceholder } from "./consolidator/index.js";
13
+ import { CONTENT_ORIGIN_ATTR, INBOUND_TRUST_ATTR, NON_INBOUND_ORIGINS, annotate, shouldFireInboundPreamble, toSpanAttributes } from "./context-engine/annotations.js";
14
+ import { defaultLocaleHeuristicStrategy, defineAutoRecallStrategy } from "./context-engine/auto-recall.js";
15
+ import { HEURISTIC_TOKEN_COUNTER, adaptTokenCounter, countMessageTokens, renderMessageText } from "./context-engine/token-counter.js";
16
+ import { CLEARED_TOOL_RESULT_MARKER, clearOldToolResults } from "./context-engine/compaction/clear-tool-results.js";
17
+ import { SUMMARY_TEMPLATE_NAME, SUMMARY_TEMPLATE_VERSION, buildSummarizerPrompt, renderFinalSummary } from "./context-engine/compaction/templates/summary-9-section.js";
18
+ import { DEFAULT_PRESERVE_RECENT_TURNS, executeCompaction } from "./context-engine/compaction/compactor.js";
19
+ import { reanchorPersonaBlock } from "./context-engine/compaction/hooks/reanchor-persona-block.js";
20
+ import { reanchorPinnedFacts } from "./context-engine/compaction/hooks/reanchor-pinned-facts.js";
21
+ import { reanchorProjectRules } from "./context-engine/compaction/hooks/reanchor-project-rules.js";
22
+ import { DEFAULT_RESERVED_FOR_COMPACTION, DEFAULT_RESERVED_FOR_RESPONSE, DEFAULT_THRESHOLD_RATIO, resolveAutoCompactionDefault, resolveTriggerThreshold } from "./context-engine/compaction/thresholds.js";
23
+ import { enLocalePack } from "./context-engine/locale-packs/en.js";
24
+ import { defineContextLocalePack } from "./context-engine/locale-packs/types.js";
25
+ import { _getLocaleFallbackWarningsForTesting, _resetLocaleFallbackWarningsForTesting, resolveLocalePack } from "./context-engine/locale-packs/resolver.js";
26
+ import { gatherMemoryMetadata, renderMetadataBlock } from "./context-engine/metadata.js";
27
+ import { decide, effectiveAcceptsSensitivity, partition } from "./context-engine/privacy-filter.js";
28
+ import { composeInboundPreamble, composeLayer1, composeLayer2, composeLayer4Skills } from "./context-engine/templates/composer.js";
29
+ import { DEFAULT_LAYER_PRIORITY, allocate, truncateToTokens } from "./context-engine/token-budget.js";
30
+ import { createContextEngine } from "./context-engine/engine.js";
31
+ import { INBOUND_SANITIZATION_PREAMBLE_EN } from "./context-engine/preambles/inbound-en.js";
32
+ import { BASE_TEMPLATE_EN_FULL, BASE_TEMPLATE_EN_MINIMAL } from "./context-engine/templates/base-en.js";
33
+ import "./context-engine/index.js";
34
+ import { DEFAULT_ADJUDICATE_THRESHOLD, DEFAULT_MERGE_THRESHOLD, EntityResolver, buildAdjudicationRequest, cosineSimilarity, normalizeEntityName, parseAdjudication, resolveEntityDecision } from "./graph/entity-resolver.js";
35
+ import { DEFAULT_DIFFICULTY_THRESHOLD, DEFAULT_MAX_ITERATIONS, MAX_ITERATIONS_CEILING, RETRIEVAL_GRADE_SYSTEM_PROMPT, assessQueryDifficulty, buildGradeRequest, createProviderRetrievalGrader, parseGrade, runIterativeRetrieval } from "./search/iterative.js";
36
+ import { DEFAULT_MAX_QUERY_VARIANTS, HYDE_SYSTEM_PROMPT, QUERY_EXPANSION_SYSTEM_PROMPT, buildExpansionRequest, buildHydeRequest, createProviderQueryTransformer, parseHypothetical, parseQueryVariants } from "./search/query-transform.js";
37
+ import { RRFReranker, RRF_DEFAULT_K, WeightedRRFReranker, fuseRrf, fuseWeighted } from "./search/rrf.js";
38
+ import { EpisodicMemory } from "./tiers/episodic-memory.js";
39
+ import { InsightMemory, capInsightsBelowFacts } from "./tiers/insight-memory.js";
40
+ import { ProceduralMemory } from "./tiers/procedural-memory.js";
41
+ import { explainRecall, formatRecallExplanation } from "./search/explain.js";
42
+ import { SemanticMemory } from "./tiers/semantic-memory.js";
43
+ import { SessionMemory } from "./tiers/session-memory.js";
44
+ import { SharedMemory } from "./tiers/shared-memory.js";
45
+ import { WorkingMemory, defineBlock } from "./tiers/working-memory.js";
46
+ import { createBlockAppendTool, createBlockReplaceTool, createBlockRethinkTool } from "./tools/block-tools.js";
47
+ import { createFactForgetTool, createFactHistoryTool, createFactRememberTool, createFactSearchTool, createFactSupersedeTool, createFactValidateTool } from "./tools/fact-tools.js";
48
+ import { createConversationSearchTool, createDeepRecallTool, createRecallEpisodesTool } from "./tools/recall-tools.js";
49
+ import { buildMemoryTools } from "./tools/index.js";
50
+ import { _resetConsolidatorConfigWarningForTesting, createMemory } from "./facade.js";
51
+ import { migrateEmbedder } from "./migration/embedder-migration.js";
52
+ import "./tiers/index.js";
53
+
54
+ //#region src/index.ts
55
+ /**
56
+ * `@graphorin/memory` — seven-tier memory system for the Graphorin
57
+ * framework (MST-13: working / session / episodic / semantic /
58
+ * procedural / shared + the read-only insight tier from P1-1).
59
+ *
60
+ * Surface overview:
61
+ *
62
+ * - The {@link createMemory} facade that wires every tier sub-module
63
+ * + the memory tools + the search reranker + the context-engine +
64
+ * the consolidator.
65
+ * - Tier sub-modules under `./tiers`: {@link WorkingMemory},
66
+ * {@link SessionMemory}, {@link EpisodicMemory}, {@link SemanticMemory},
67
+ * {@link ProceduralMemory}, {@link SharedMemory}, plus the read-only
68
+ * {@link InsightMemory}.
69
+ * - Eleven memory tools under `./tools` (plus the gated twelfth,
70
+ * `deep_recall`, registered only when iterative retrieval is
71
+ * configured): `block_append`, `block_replace`, `block_rethink`,
72
+ * `fact_remember`, `fact_search`, `fact_supersede`, `fact_forget`,
73
+ * `recall_episodes`, `conversation_search`, `fact_history` (P0-2),
74
+ * `fact_validate` (P1-4).
75
+ * - The hybrid search composition under `./search`, including the
76
+ * built-in {@link RRFReranker} (k=60 default) and the
77
+ * {@link ReRanker} contract.
78
+ * - The embedder migration runner under `./migration`
79
+ * ({@link migrateEmbedder} with three coexistence policies).
80
+ * - Typed errors under `./errors`.
81
+ *
82
+ * Forward-looking surfaces (for ergonomic typing today):
83
+ *
84
+ * - {@link MemoryContextBlocks} + {@link CompileOptions} from `./context-engine`.
85
+ * - {@link Consolidator}, {@link ConsolidatorTriggerSpec},
86
+ * {@link ConsolidatorTier} from `./consolidator`.
87
+ *
88
+ * @packageDocumentation
89
+ */
90
+ /** Canonical version constant. Mirrors the `package.json` version. */
91
+ const VERSION = "0.5.0";
92
+
93
+ //#endregion
94
+ export { BASE_TEMPLATE_EN_FULL, BASE_TEMPLATE_EN_MINIMAL, BudgetExceededError, CLEARED_TOOL_RESULT_MARKER, CONSOLIDATOR_TIER_DEFAULTS, CONTENT_ORIGIN_ATTR, CustomTierMisconfiguredError, DEFAULT_ADJUDICATE_THRESHOLD, DEFAULT_CONFLICT_THRESHOLDS, DEFAULT_DIFFICULTY_THRESHOLD, DEFAULT_INDUCTION_MAX_TOKENS, DEFAULT_LAYER_PRIORITY, DEFAULT_MAX_ITERATIONS, DEFAULT_MAX_QUERY_VARIANTS, DEFAULT_MERGE_THRESHOLD, DEFAULT_PRESERVE_RECENT_TURNS, DEFAULT_RESERVED_FOR_COMPACTION, DEFAULT_RESERVED_FOR_RESPONSE, DEFAULT_THRESHOLD_RATIO, EmbedderMigrationAbortedError, EmbedderMigrationLockedError, EmbedderMigrationStateError, EmbedderRegistrationError, EntityResolver, EpisodicMemory, GraphorinMemoryError, HEURISTIC_TOKEN_COUNTER, HYDE_SYSTEM_PROMPT, INBOUND_SANITIZATION_PREAMBLE_EN, INBOUND_TRUST_ATTR, INDUCTION_SYSTEM_PROMPT, InsightMemory, MAX_ITERATIONS_CEILING, MAX_PROCEDURE_STEPS, MAX_TRAJECTORY_STEPS_SHOWN, MemoryToolDeniedError, NON_INBOUND_ORIGINS, ProceduralMemory, ProcedureInductionNotConfiguredError, ProviderNotConfiguredError, QUERY_EXPANSION_SYSTEM_PROMPT, QuarantinePromotionRefusedError, RETRIEVAL_GRADE_SYSTEM_PROMPT, RRFReranker, RRF_DEFAULT_K, SUMMARY_TEMPLATE_NAME, SUMMARY_TEMPLATE_VERSION, SemanticMemory, SessionMemory, SharedMemory, VERSION, WeightedRRFReranker, WorkingBlockOverflowError, WorkingBlockReadOnlyError, WorkingBlockReplaceMismatchError, WorkingMemory, _getLocaleFallbackWarningsForTesting, _resetBypassWarningForTesting, _resetConsolidatorConfigWarningForTesting, _resetLocaleFallbackWarningsForTesting, adaptTokenCounter, allocate as allocateTokenBudget, annotate, assessQueryDifficulty, buildAdjudicationRequest, buildExpansionRequest, buildGradeRequest, buildHydeRequest, buildInductionRequest, buildMemoryTools, buildSummarizerPrompt, capInsightsBelowFacts, checkSuccessCriteria, clearOldToolResults, composeInboundPreamble, composeLayer1, composeLayer2, composeLayer4Skills, cosineSimilarity, countMessageTokens, createBlockAppendTool, createBlockReplaceTool, createBlockRethinkTool, createConflictPipeline, createConsolidator, createConsolidatorPlaceholder, createContextEngine, createConversationSearchTool, createDeepRecallTool, createFactForgetTool, createFactHistoryTool, createFactRememberTool, createFactSearchTool, createFactSupersedeTool, createFactValidateTool, createMemory, createProviderQueryTransformer, createProviderRetrievalGrader, createProviderWorkflowInducer, createRecallEpisodesTool, defaultLocaleHeuristicStrategy, defineAutoRecallStrategy, defineBlock, defineContextLocalePack, defineLocalePack, effectiveAcceptsSensitivity, enLocalePack, evaluateMarkers, executeCompaction, explainRecall, formatRecallExplanation, fuseRrf, fuseWeighted, gatherMemoryMetadata, migrateEmbedder, normalizeEntityName, normalizeInducedProcedure, parseAdjudication, parseGrade, parseHypothetical, parseInducedProcedure, parseQueryVariants, parseTriggerSpec, partition as partitionBySensitivity, decide as privacyDecide, reanchorPersonaBlock, reanchorPinnedFacts, reanchorProjectRules, reasonFromTrigger, reconcileToConflictDecision, registerConsolidatorTriggers, renderFinalSummary, renderMessageText, renderMetadataBlock, resolveAutoCompactionDefault, resolveEntityDecision, resolveLocalePack, resolveTriggerThreshold, runConflictPipeline, runIterativeRetrieval, runWorkflowInduction, shouldFireInboundPreamble, toSpanAttributes, trajectoryFromRunState, truncateToTokens };
95
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@graphorin/memory` — seven-tier memory system for the Graphorin\n * framework (MST-13: working / session / episodic / semantic /\n * procedural / shared + the read-only insight tier from P1-1).\n *\n * Surface overview:\n *\n * - The {@link createMemory} facade that wires every tier sub-module\n * + the memory tools + the search reranker + the context-engine +\n * the consolidator.\n * - Tier sub-modules under `./tiers`: {@link WorkingMemory},\n * {@link SessionMemory}, {@link EpisodicMemory}, {@link SemanticMemory},\n * {@link ProceduralMemory}, {@link SharedMemory}, plus the read-only\n * {@link InsightMemory}.\n * - Eleven memory tools under `./tools` (plus the gated twelfth,\n * `deep_recall`, registered only when iterative retrieval is\n * configured): `block_append`, `block_replace`, `block_rethink`,\n * `fact_remember`, `fact_search`, `fact_supersede`, `fact_forget`,\n * `recall_episodes`, `conversation_search`, `fact_history` (P0-2),\n * `fact_validate` (P1-4).\n * - The hybrid search composition under `./search`, including the\n * built-in {@link RRFReranker} (k=60 default) and the\n * {@link ReRanker} contract.\n * - The embedder migration runner under `./migration`\n * ({@link migrateEmbedder} with three coexistence policies).\n * - Typed errors under `./errors`.\n *\n * Forward-looking surfaces (for ergonomic typing today):\n *\n * - {@link MemoryContextBlocks} + {@link CompileOptions} from `./context-engine`.\n * - {@link Consolidator}, {@link ConsolidatorTriggerSpec},\n * {@link ConsolidatorTier} from `./consolidator`.\n *\n * @packageDocumentation\n */\n\n/** Canonical version constant. Mirrors the `package.json` version. */\nexport const VERSION = '0.5.0';\n\nexport * from './conflict/index.js';\nexport {\n BudgetExceededError,\n buildInductionRequest,\n CONSOLIDATOR_TIER_DEFAULTS,\n type Consolidator,\n type ConsolidatorBudgetSnapshot,\n type ConsolidatorCatchupPolicy,\n type ConsolidatorCeilings,\n type ConsolidatorConfig,\n type ConsolidatorLastRuns,\n type ConsolidatorPhase,\n type ConsolidatorStatus,\n type ConsolidatorTier,\n type ConsolidatorTriggerReason,\n type ConsolidatorTriggerSpec,\n type CreateConsolidatorOptions,\n CustomTierMisconfiguredError,\n checkSuccessCriteria,\n createConsolidator,\n createConsolidatorPlaceholder,\n createProviderWorkflowInducer,\n DEFAULT_INDUCTION_MAX_TOKENS,\n INDUCTION_SYSTEM_PROMPT,\n type InducedProcedure,\n MAX_PROCEDURE_STEPS,\n MAX_TRAJECTORY_STEPS_SHOWN,\n normalizeInducedProcedure,\n type OnBudgetExceed,\n type ParsedTrigger,\n type PhaseListener,\n type PhaseOutcome,\n ProviderNotConfiguredError,\n parseInducedProcedure,\n parseTriggerSpec,\n type RegisterTriggersOptions,\n type RegisterTriggersResult,\n reasonFromTrigger,\n registerConsolidatorTriggers,\n runWorkflowInduction,\n type SchedulerLike,\n type Trajectory,\n type TrajectoryStep,\n type TriggerDeclarationLike,\n trajectoryFromRunState,\n type VerificationResult,\n type WorkflowInducer,\n type WorkflowInductionOptions,\n} from './consolidator/index.js';\nexport {\n _getLocaleFallbackWarningsForTesting,\n _resetLocaleFallbackWarningsForTesting,\n type AllocationResult,\n type AnnotatedPart,\n type AssembledPrompt,\n type AssembleInput,\n type AutoCompactionDefault,\n type AutoRecallConfig,\n type AutoRecallStrategy,\n type AutoRecallStrategyContext,\n type AutoRecallTriggerResult,\n type AutoRecallTriggers,\n adaptTokenCounter,\n allocateTokenBudget,\n annotate,\n BASE_TEMPLATE_EN_FULL,\n BASE_TEMPLATE_EN_MINIMAL,\n type BaseTemplateFragments,\n buildSummarizerPrompt,\n CLEARED_TOOL_RESULT_MARKER,\n type ClearToolResultsOptions,\n type ClearToolResultsOutcome,\n CONTENT_ORIGIN_ATTR,\n type CompactionConfig,\n type CompactionContext,\n type CompactionMetadataPayload,\n type CompactionResult,\n type CompactionSource,\n type CompactionStrategy,\n type CompactionSummarizer,\n type CompactionSummaryTemplate,\n type CompactionTriggerConfig,\n type CompileOptions,\n type CompileScope,\n type ContentAnnotation,\n type ContentOrigin,\n type ContextEngine,\n type ContextEngineConfig,\n type ContextLocalePack,\n type ContextTokenCounter,\n clearOldToolResults,\n composeInboundPreamble,\n composeLayer1,\n composeLayer2,\n composeLayer4Skills,\n countMessageTokens,\n createContextEngine,\n DEFAULT_LAYER_PRIORITY,\n DEFAULT_PRESERVE_RECENT_TURNS,\n DEFAULT_RESERVED_FOR_COMPACTION,\n DEFAULT_RESERVED_FOR_RESPONSE,\n DEFAULT_THRESHOLD_RATIO,\n defaultLocaleHeuristicStrategy,\n defineAutoRecallStrategy,\n defineContextLocalePack,\n type ExecuteCompactionInput,\n effectiveAcceptsSensitivity,\n enLocalePack,\n executeCompaction,\n gatherMemoryMetadata,\n HEURISTIC_TOKEN_COUNTER,\n INBOUND_SANITIZATION_PREAMBLE_EN,\n INBOUND_TRUST_ATTR,\n type InboundSanitizationPreamble,\n type InboundTrust,\n type LayerAllocation,\n type LayerCandidate,\n type LayerConfig,\n type LayerId,\n type LocaleResolverLogger,\n type MemoryBaseMode,\n type MemoryContextBlocks,\n type MemoryMetadataDeps,\n type NamedPostCompactionHook,\n NON_INBOUND_ORIGINS,\n type OverflowMode,\n type PartialContextLocalePack,\n type PartitionResult,\n type PostCompactionHook,\n type PostCompactionHookContext,\n type PrivacyConfig,\n type PrivacyDecision,\n type PrivacyDecisionReason,\n type PrivacyFilterContext,\n partitionBySensitivity,\n privacyDecide,\n type RenderedTemplate,\n type ResolvedContextEngineConfig,\n reanchorPersonaBlock,\n reanchorPinnedFacts,\n reanchorProjectRules,\n renderFinalSummary,\n renderMessageText,\n renderMetadataBlock,\n resolveAutoCompactionDefault,\n resolveLocalePack,\n resolveTriggerThreshold,\n type SkillMetadataCard,\n SUMMARY_TEMPLATE_NAME,\n SUMMARY_TEMPLATE_VERSION,\n shouldFireInboundPreamble,\n toSpanAttributes,\n truncateToTokens,\n} from './context-engine/index.js';\nexport * from './errors/index.js';\nexport {\n _resetConsolidatorConfigWarningForTesting,\n type CreateMemoryOptions,\n createMemory,\n type Memory,\n} from './facade.js';\nexport * from './graph/index.js';\nexport type { ContextualRetrievalMode } from './internal/contextualize.js';\nexport type {\n ConflictAuditDecision,\n ConflictAuditInputLike,\n ConflictAuditStage,\n ConflictMemoryStoreExt,\n ConsolidatorMemoryStoreExt,\n ConsolidatorRunFinish,\n ConsolidatorRunInput,\n ConsolidatorStatePatch,\n ConsolidatorStateRow,\n DecayMemoryStoreExt,\n DlqBatchInput,\n DlqBatchRow,\n EmbeddedWriteOptions,\n EmbeddingMetaRegistryLike,\n EpisodicMemoryStoreExt,\n InsightListOptions as InsightStoreListOptions,\n InsightMemoryStoreExt,\n InsightSearchStoreOptions,\n MemoryStoreAdapter,\n PendingConflictInputLike,\n PendingConflictRowLike,\n SemanticMemoryStoreExt,\n SessionMemoryStoreExt,\n SessionMessageRecord,\n} from './internal/storage-adapter.js';\nexport * from './migration/index.js';\nexport * from './search/index.js';\nexport * from './tiers/index.js';\nexport {\n type BuildMemoryToolsOptions,\n buildMemoryTools,\n createBlockAppendTool,\n createBlockReplaceTool,\n createBlockRethinkTool,\n createConversationSearchTool,\n createDeepRecallTool,\n createFactForgetTool,\n createFactHistoryTool,\n createFactRememberTool,\n createFactSearchTool,\n createFactSupersedeTool,\n createFactValidateTool,\n createRecallEpisodesTool,\n type MemoryToolDeps,\n type ScopeResolver,\n} from './tools/index.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,UAAU"}