@graphrefly/graphrefly 0.25.0 → 0.27.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 (231) hide show
  1. package/README.md +8 -0
  2. package/dist/ai-CaR_912Q.d.cts +1033 -0
  3. package/dist/ai-WlRltJV7.d.ts +1033 -0
  4. package/dist/audit-ClmqGOCx.d.cts +245 -0
  5. package/dist/audit-DRlSzBu9.d.ts +245 -0
  6. package/dist/{chunk-QOWVNWOC.js → chunk-3ZWCKRHX.js} +27 -25
  7. package/dist/{chunk-QOWVNWOC.js.map → chunk-3ZWCKRHX.js.map} +1 -1
  8. package/dist/chunk-APFNLIRG.js +62 -0
  9. package/dist/chunk-APFNLIRG.js.map +1 -0
  10. package/dist/chunk-AT5LKYNL.js +395 -0
  11. package/dist/chunk-AT5LKYNL.js.map +1 -0
  12. package/dist/{chunk-IAHGTNOZ.js → chunk-BQ6RQQFF.js} +351 -2095
  13. package/dist/chunk-BQ6RQQFF.js.map +1 -0
  14. package/dist/{chunk-L2GLW2U7.js → chunk-BVZYTZ5H.js} +9 -103
  15. package/dist/chunk-BVZYTZ5H.js.map +1 -0
  16. package/dist/{chunk-EVR6UFUV.js → chunk-DST5DKZS.js} +19 -15
  17. package/dist/{chunk-EVR6UFUV.js.map → chunk-DST5DKZS.js.map} +1 -1
  18. package/dist/{chunk-TKE3JGOH.js → chunk-GTE6PWRZ.js} +5 -692
  19. package/dist/chunk-GTE6PWRZ.js.map +1 -0
  20. package/dist/chunk-HXZEYDUR.js +94 -0
  21. package/dist/chunk-HXZEYDUR.js.map +1 -0
  22. package/dist/chunk-J22W6HV3.js +107 -0
  23. package/dist/chunk-J22W6HV3.js.map +1 -0
  24. package/dist/{chunk-PY4XCDLR.js → chunk-J2VBW3DZ.js} +6 -95
  25. package/dist/chunk-J2VBW3DZ.js.map +1 -0
  26. package/dist/{chunk-HWPIFSW2.js → chunk-JSCT3CR4.js} +6 -4
  27. package/dist/{chunk-HWPIFSW2.js.map → chunk-JSCT3CR4.js.map} +1 -1
  28. package/dist/chunk-JWBCY4NC.js +330 -0
  29. package/dist/chunk-JWBCY4NC.js.map +1 -0
  30. package/dist/chunk-K2AUJHVP.js +2251 -0
  31. package/dist/chunk-K2AUJHVP.js.map +1 -0
  32. package/dist/chunk-MJ2NKQQL.js +119 -0
  33. package/dist/chunk-MJ2NKQQL.js.map +1 -0
  34. package/dist/chunk-N6UR7YVY.js +198 -0
  35. package/dist/chunk-N6UR7YVY.js.map +1 -0
  36. package/dist/chunk-NC6S43JJ.js +456 -0
  37. package/dist/chunk-NC6S43JJ.js.map +1 -0
  38. package/dist/chunk-OFVJBJXR.js +98 -0
  39. package/dist/chunk-OFVJBJXR.js.map +1 -0
  40. package/dist/chunk-OHISZPOJ.js +97 -0
  41. package/dist/chunk-OHISZPOJ.js.map +1 -0
  42. package/dist/chunk-OU5CQKNW.js +102 -0
  43. package/dist/chunk-OU5CQKNW.js.map +1 -0
  44. package/dist/{chunk-XOFWRC73.js → chunk-PF7GRZMW.js} +316 -21
  45. package/dist/chunk-PF7GRZMW.js.map +1 -0
  46. package/dist/{chunk-5DJTTKX3.js → chunk-PHOUUNK7.js} +74 -111
  47. package/dist/chunk-PHOUUNK7.js.map +1 -0
  48. package/dist/chunk-RNHBMHKA.js +1665 -0
  49. package/dist/chunk-RNHBMHKA.js.map +1 -0
  50. package/dist/chunk-SX52TAR4.js +110 -0
  51. package/dist/chunk-SX52TAR4.js.map +1 -0
  52. package/dist/{chunk-H4RVA4VE.js → chunk-VYPWMZ6H.js} +2 -2
  53. package/dist/chunk-WBZOVTYK.js +171 -0
  54. package/dist/chunk-WBZOVTYK.js.map +1 -0
  55. package/dist/chunk-WKNUIZOY.js +354 -0
  56. package/dist/chunk-WKNUIZOY.js.map +1 -0
  57. package/dist/chunk-X3VMZYBT.js +713 -0
  58. package/dist/chunk-X3VMZYBT.js.map +1 -0
  59. package/dist/chunk-X5R3GL6H.js +525 -0
  60. package/dist/chunk-X5R3GL6H.js.map +1 -0
  61. package/dist/chunk-XGPU467M.js +136 -0
  62. package/dist/chunk-XGPU467M.js.map +1 -0
  63. package/dist/compat/index.cjs +7656 -0
  64. package/dist/compat/index.cjs.map +1 -0
  65. package/dist/compat/index.d.cts +18 -0
  66. package/dist/compat/index.d.ts +18 -0
  67. package/dist/compat/index.js +50 -0
  68. package/dist/compat/index.js.map +1 -0
  69. package/dist/compat/jotai/index.cjs +2048 -0
  70. package/dist/compat/jotai/index.cjs.map +1 -0
  71. package/dist/compat/jotai/index.d.cts +2 -0
  72. package/dist/compat/jotai/index.d.ts +2 -0
  73. package/dist/compat/jotai/index.js +9 -0
  74. package/dist/compat/jotai/index.js.map +1 -0
  75. package/dist/compat/nanostores/index.cjs +2175 -0
  76. package/dist/compat/nanostores/index.cjs.map +1 -0
  77. package/dist/compat/nanostores/index.d.cts +2 -0
  78. package/dist/compat/nanostores/index.d.ts +2 -0
  79. package/dist/compat/nanostores/index.js +23 -0
  80. package/dist/compat/nanostores/index.js.map +1 -0
  81. package/dist/compat/nestjs/index.cjs +350 -16
  82. package/dist/compat/nestjs/index.cjs.map +1 -1
  83. package/dist/compat/nestjs/index.d.cts +6 -6
  84. package/dist/compat/nestjs/index.d.ts +6 -6
  85. package/dist/compat/nestjs/index.js +11 -9
  86. package/dist/compat/react/index.cjs +141 -0
  87. package/dist/compat/react/index.cjs.map +1 -0
  88. package/dist/compat/react/index.d.cts +2 -0
  89. package/dist/compat/react/index.d.ts +2 -0
  90. package/dist/compat/react/index.js +12 -0
  91. package/dist/compat/react/index.js.map +1 -0
  92. package/dist/compat/solid/index.cjs +128 -0
  93. package/dist/compat/solid/index.cjs.map +1 -0
  94. package/dist/compat/solid/index.d.cts +2 -0
  95. package/dist/compat/solid/index.d.ts +2 -0
  96. package/dist/compat/solid/index.js +12 -0
  97. package/dist/compat/solid/index.js.map +1 -0
  98. package/dist/compat/svelte/index.cjs +131 -0
  99. package/dist/compat/svelte/index.cjs.map +1 -0
  100. package/dist/compat/svelte/index.d.cts +2 -0
  101. package/dist/compat/svelte/index.d.ts +2 -0
  102. package/dist/compat/svelte/index.js +12 -0
  103. package/dist/compat/svelte/index.js.map +1 -0
  104. package/dist/compat/vue/index.cjs +146 -0
  105. package/dist/compat/vue/index.cjs.map +1 -0
  106. package/dist/compat/vue/index.d.cts +3 -0
  107. package/dist/compat/vue/index.d.ts +3 -0
  108. package/dist/compat/vue/index.js +12 -0
  109. package/dist/compat/vue/index.js.map +1 -0
  110. package/dist/compat/zustand/index.cjs +4931 -0
  111. package/dist/compat/zustand/index.cjs.map +1 -0
  112. package/dist/compat/zustand/index.d.cts +5 -0
  113. package/dist/compat/zustand/index.d.ts +5 -0
  114. package/dist/compat/zustand/index.js +12 -0
  115. package/dist/compat/zustand/index.js.map +1 -0
  116. package/dist/composite-C7PcQvcs.d.cts +303 -0
  117. package/dist/composite-aUCvjZVR.d.ts +303 -0
  118. package/dist/core/index.cjs +53 -4
  119. package/dist/core/index.cjs.map +1 -1
  120. package/dist/core/index.d.cts +4 -3
  121. package/dist/core/index.d.ts +4 -3
  122. package/dist/core/index.js +26 -24
  123. package/dist/demo-shell-BDkOptd6.d.ts +102 -0
  124. package/dist/demo-shell-Crid1WdR.d.cts +102 -0
  125. package/dist/extra/index.cjs +222 -110
  126. package/dist/extra/index.cjs.map +1 -1
  127. package/dist/extra/index.d.cts +6 -4
  128. package/dist/extra/index.d.ts +6 -4
  129. package/dist/extra/index.js +72 -65
  130. package/dist/extra/sources.cjs +2486 -0
  131. package/dist/extra/sources.cjs.map +1 -0
  132. package/dist/extra/sources.d.cts +465 -0
  133. package/dist/extra/sources.d.ts +465 -0
  134. package/dist/extra/sources.js +57 -0
  135. package/dist/extra/sources.js.map +1 -0
  136. package/dist/graph/index.cjs +408 -14
  137. package/dist/graph/index.cjs.map +1 -1
  138. package/dist/graph/index.d.cts +5 -5
  139. package/dist/graph/index.d.ts +5 -5
  140. package/dist/graph/index.js +13 -5
  141. package/dist/{graph-D-3JIQme.d.cts → graph-CCwGKLCm.d.ts} +195 -4
  142. package/dist/{graph-B6NFqv3z.d.ts → graph-DNCrvZSn.d.cts} +195 -4
  143. package/dist/index-3lsddbbS.d.ts +86 -0
  144. package/dist/index-B1tloyhO.d.cts +34 -0
  145. package/dist/{index-CYkjxu3s.d.ts → index-B6D3QNSA.d.ts} +33 -4
  146. package/dist/index-B6EhDnjH.d.cts +37 -0
  147. package/dist/index-B9B7_HEY.d.ts +37 -0
  148. package/dist/{index-Ds23Wvou.d.ts → index-BHlKbUwO.d.cts} +131 -883
  149. package/dist/{index-DiobMNwE.d.ts → index-BPVt8kqc.d.ts} +3 -3
  150. package/dist/index-BaSM3aYt.d.ts +195 -0
  151. package/dist/index-BuEoe-Qu.d.ts +121 -0
  152. package/dist/{index-Ch0IpIO0.d.cts → index-BwfLUNw4.d.ts} +131 -883
  153. package/dist/index-ByQxazQJ.d.cts +86 -0
  154. package/dist/index-C0svESO4.d.ts +127 -0
  155. package/dist/{index-OXImXMq6.d.ts → index-C8oil6M6.d.ts} +18 -196
  156. package/dist/{index-DKE1EATr.d.cts → index-CI3DprxP.d.cts} +18 -196
  157. package/dist/{index-AMWewNDe.d.cts → index-CO8uBlUh.d.cts} +33 -4
  158. package/dist/index-CxFrXH4m.d.ts +45 -0
  159. package/dist/index-D8wS_PeY.d.cts +121 -0
  160. package/dist/index-DO_6JN9Z.d.cts +127 -0
  161. package/dist/index-DVGiGFGT.d.cts +195 -0
  162. package/dist/index-DYme44FM.d.cts +44 -0
  163. package/dist/{index-J7Kc0oIQ.d.cts → index-DlLp-2Xn.d.cts} +3 -3
  164. package/dist/index-Dzk2hrlR.d.ts +44 -0
  165. package/dist/index-VHqptjhu.d.cts +45 -0
  166. package/dist/index-VdHQMPy1.d.ts +36 -0
  167. package/dist/index-Xi3u0HCQ.d.cts +36 -0
  168. package/dist/index-wEn0eFe8.d.ts +34 -0
  169. package/dist/index.cjs +1780 -176
  170. package/dist/index.cjs.map +1 -1
  171. package/dist/index.d.cts +784 -2082
  172. package/dist/index.d.ts +784 -2082
  173. package/dist/index.js +955 -4349
  174. package/dist/index.js.map +1 -1
  175. package/dist/memory-C6Z2tGpC.d.cts +139 -0
  176. package/dist/memory-li6FL5RM.d.ts +139 -0
  177. package/dist/messaging-Gt4LPbyA.d.cts +269 -0
  178. package/dist/messaging-XDoYablx.d.ts +269 -0
  179. package/dist/{meta-DWbkoq1s.d.cts → meta-BxCA7rcr.d.cts} +1 -1
  180. package/dist/{meta-CnkLA_43.d.ts → meta-CbznRPYJ.d.ts} +1 -1
  181. package/dist/{node-B-f-Lu-k.d.cts → node-BmerH3kS.d.cts} +26 -1
  182. package/dist/{node-B-f-Lu-k.d.ts → node-BmerH3kS.d.ts} +26 -1
  183. package/dist/{observable-uP-wy_uK.d.ts → observable-BgGUwcqp.d.ts} +1 -1
  184. package/dist/{observable-DBnrwcar.d.cts → observable-DJt_AxzQ.d.cts} +1 -1
  185. package/dist/patterns/ai.cjs +7930 -0
  186. package/dist/patterns/ai.cjs.map +1 -0
  187. package/dist/patterns/ai.d.cts +10 -0
  188. package/dist/patterns/ai.d.ts +10 -0
  189. package/dist/patterns/ai.js +71 -0
  190. package/dist/patterns/ai.js.map +1 -0
  191. package/dist/patterns/audit.cjs +5805 -0
  192. package/dist/patterns/audit.cjs.map +1 -0
  193. package/dist/patterns/audit.d.cts +6 -0
  194. package/dist/patterns/audit.d.ts +6 -0
  195. package/dist/patterns/audit.js +29 -0
  196. package/dist/patterns/audit.js.map +1 -0
  197. package/dist/patterns/demo-shell.cjs +5604 -0
  198. package/dist/patterns/demo-shell.cjs.map +1 -0
  199. package/dist/patterns/demo-shell.d.cts +6 -0
  200. package/dist/patterns/demo-shell.d.ts +6 -0
  201. package/dist/patterns/demo-shell.js +15 -0
  202. package/dist/patterns/demo-shell.js.map +1 -0
  203. package/dist/patterns/memory.cjs +5283 -0
  204. package/dist/patterns/memory.cjs.map +1 -0
  205. package/dist/patterns/memory.d.cts +5 -0
  206. package/dist/patterns/memory.d.ts +5 -0
  207. package/dist/patterns/memory.js +20 -0
  208. package/dist/patterns/memory.js.map +1 -0
  209. package/dist/patterns/reactive-layout/index.cjs +355 -13
  210. package/dist/patterns/reactive-layout/index.cjs.map +1 -1
  211. package/dist/patterns/reactive-layout/index.d.cts +6 -5
  212. package/dist/patterns/reactive-layout/index.d.ts +6 -5
  213. package/dist/patterns/reactive-layout/index.js +15 -12
  214. package/dist/reactive-layout-MQP--J3F.d.cts +183 -0
  215. package/dist/reactive-layout-u5Ulnqag.d.ts +183 -0
  216. package/dist/{storage-BuTdpCI1.d.cts → storage-CMjUUuxn.d.ts} +10 -2
  217. package/dist/{storage-F2X1U1x0.d.ts → storage-DdWlZo6U.d.cts} +10 -2
  218. package/dist/sugar-CCOxXK1e.d.ts +201 -0
  219. package/dist/sugar-D02n5JjF.d.cts +201 -0
  220. package/package.json +63 -3
  221. package/dist/chunk-5DJTTKX3.js.map +0 -1
  222. package/dist/chunk-IAHGTNOZ.js.map +0 -1
  223. package/dist/chunk-L2GLW2U7.js.map +0 -1
  224. package/dist/chunk-MW4VAKAO.js +0 -47
  225. package/dist/chunk-MW4VAKAO.js.map +0 -1
  226. package/dist/chunk-PY4XCDLR.js.map +0 -1
  227. package/dist/chunk-TKE3JGOH.js.map +0 -1
  228. package/dist/chunk-XOFWRC73.js.map +0 -1
  229. package/dist/index-BJB7t9gg.d.cts +0 -392
  230. package/dist/index-C-TXEa7C.d.ts +0 -392
  231. /package/dist/{chunk-H4RVA4VE.js.map → chunk-VYPWMZ6H.js.map} +0 -0
@@ -0,0 +1,139 @@
1
+ import { N as Node } from './node-BmerH3kS.cjs';
2
+ import { a as Graph } from './graph-DNCrvZSn.cjs';
3
+
4
+ /**
5
+ * Memory patterns (roadmap §4.3).
6
+ *
7
+ * Domain-layer helpers composed from GraphRefly primitives. `vectorIndex` uses
8
+ * an exact-search backend by default; an HNSW adapter can be injected as an
9
+ * optional dependency.
10
+ */
11
+
12
+ type CollectionPolicy = "fifo" | "lru";
13
+ type VectorBackend = "flat" | "hnsw";
14
+ type LightCollectionEntry<T> = {
15
+ readonly id: string;
16
+ readonly value: T;
17
+ readonly createdAtNs: number;
18
+ readonly lastAccessNs: number;
19
+ };
20
+ type LightCollectionOptions = {
21
+ name?: string;
22
+ maxSize?: number;
23
+ policy?: CollectionPolicy;
24
+ };
25
+ type LightCollectionBundle<T> = {
26
+ readonly entries: Node<ReadonlyMap<string, LightCollectionEntry<T>>>;
27
+ upsert: (id: string, value: T) => void;
28
+ remove: (id: string) => void;
29
+ clear: () => void;
30
+ get: (id: string) => T | undefined;
31
+ has: (id: string) => boolean;
32
+ };
33
+ type CollectionEntry<T> = LightCollectionEntry<T> & {
34
+ readonly baseScore: number;
35
+ };
36
+ type RankedCollectionEntry<T> = CollectionEntry<T> & {
37
+ readonly score: number;
38
+ };
39
+ type CollectionOptions<T> = {
40
+ maxSize?: number;
41
+ policy?: CollectionPolicy;
42
+ /**
43
+ * Produces a base score at insert/update time.
44
+ */
45
+ score?: (value: T) => number;
46
+ /**
47
+ * Exponential decay rate per second. 0 disables decay.
48
+ */
49
+ decayRate?: number;
50
+ /**
51
+ * Minimum score floor after decay.
52
+ */
53
+ minScore?: number;
54
+ };
55
+ type CollectionGraph<T> = Graph & {
56
+ upsert: (id: string, value: T, opts?: {
57
+ score?: number;
58
+ }) => void;
59
+ remove: (id: string) => void;
60
+ clear: () => void;
61
+ getItem: (id: string) => CollectionEntry<T> | undefined;
62
+ };
63
+ type VectorRecord<TMeta> = {
64
+ readonly id: string;
65
+ readonly vector: readonly number[];
66
+ readonly meta?: TMeta;
67
+ };
68
+ type VectorSearchResult<TMeta> = {
69
+ readonly id: string;
70
+ readonly score: number;
71
+ readonly meta?: TMeta;
72
+ };
73
+ type HnswAdapter<TMeta> = {
74
+ upsert: (id: string, vector: readonly number[], meta?: TMeta) => void;
75
+ remove: (id: string) => void;
76
+ clear: () => void;
77
+ search: (query: readonly number[], k: number) => ReadonlyArray<VectorSearchResult<TMeta>>;
78
+ };
79
+ type VectorIndexOptions<TMeta> = {
80
+ backend?: VectorBackend;
81
+ dimension?: number;
82
+ /**
83
+ * Optional dependency seam for HNSW.
84
+ */
85
+ hnswFactory?: () => HnswAdapter<TMeta>;
86
+ };
87
+ type VectorIndexBundle<TMeta> = {
88
+ readonly backend: VectorBackend;
89
+ readonly entries: Node<ReadonlyMap<string, VectorRecord<TMeta>>>;
90
+ upsert: (id: string, vector: readonly number[], meta?: TMeta) => void;
91
+ remove: (id: string) => void;
92
+ clear: () => void;
93
+ search: (query: readonly number[], k?: number) => ReadonlyArray<VectorSearchResult<TMeta>>;
94
+ };
95
+ type KnowledgeEdge<TRelation extends string = string> = {
96
+ readonly from: string;
97
+ readonly to: string;
98
+ readonly relation: TRelation;
99
+ readonly weight: number;
100
+ };
101
+ type KnowledgeGraphGraph<TEntity, TRelation extends string = string> = Graph & {
102
+ upsertEntity: (id: string, value: TEntity) => void;
103
+ removeEntity: (id: string) => void;
104
+ link: (from: string, to: string, relation: TRelation, weight?: number) => void;
105
+ unlink: (from: string, to: string, relation?: TRelation) => void;
106
+ related: (id: string, relation?: TRelation) => ReadonlyArray<KnowledgeEdge<TRelation>>;
107
+ };
108
+ declare function decay(baseScore: number, ageSeconds: number, ratePerSecond: number, minScore?: number): number;
109
+ declare function lightCollection<T>(opts?: LightCollectionOptions): LightCollectionBundle<T>;
110
+ declare function collection<T>(name: string, opts?: CollectionOptions<T>): CollectionGraph<T>;
111
+ declare function vectorIndex<TMeta>(opts?: VectorIndexOptions<TMeta>): VectorIndexBundle<TMeta>;
112
+ declare function knowledgeGraph<TEntity, TRelation extends string = string>(name: string): KnowledgeGraphGraph<TEntity, TRelation>;
113
+
114
+ type memory_CollectionEntry<T> = CollectionEntry<T>;
115
+ type memory_CollectionGraph<T> = CollectionGraph<T>;
116
+ type memory_CollectionOptions<T> = CollectionOptions<T>;
117
+ type memory_CollectionPolicy = CollectionPolicy;
118
+ type memory_HnswAdapter<TMeta> = HnswAdapter<TMeta>;
119
+ type memory_KnowledgeEdge<TRelation extends string = string> = KnowledgeEdge<TRelation>;
120
+ type memory_KnowledgeGraphGraph<TEntity, TRelation extends string = string> = KnowledgeGraphGraph<TEntity, TRelation>;
121
+ type memory_LightCollectionBundle<T> = LightCollectionBundle<T>;
122
+ type memory_LightCollectionEntry<T> = LightCollectionEntry<T>;
123
+ type memory_LightCollectionOptions = LightCollectionOptions;
124
+ type memory_RankedCollectionEntry<T> = RankedCollectionEntry<T>;
125
+ type memory_VectorBackend = VectorBackend;
126
+ type memory_VectorIndexBundle<TMeta> = VectorIndexBundle<TMeta>;
127
+ type memory_VectorIndexOptions<TMeta> = VectorIndexOptions<TMeta>;
128
+ type memory_VectorRecord<TMeta> = VectorRecord<TMeta>;
129
+ type memory_VectorSearchResult<TMeta> = VectorSearchResult<TMeta>;
130
+ declare const memory_collection: typeof collection;
131
+ declare const memory_decay: typeof decay;
132
+ declare const memory_knowledgeGraph: typeof knowledgeGraph;
133
+ declare const memory_lightCollection: typeof lightCollection;
134
+ declare const memory_vectorIndex: typeof vectorIndex;
135
+ declare namespace memory {
136
+ export { type memory_CollectionEntry as CollectionEntry, type memory_CollectionGraph as CollectionGraph, type memory_CollectionOptions as CollectionOptions, type memory_CollectionPolicy as CollectionPolicy, type memory_HnswAdapter as HnswAdapter, type memory_KnowledgeEdge as KnowledgeEdge, type memory_KnowledgeGraphGraph as KnowledgeGraphGraph, type memory_LightCollectionBundle as LightCollectionBundle, type memory_LightCollectionEntry as LightCollectionEntry, type memory_LightCollectionOptions as LightCollectionOptions, type memory_RankedCollectionEntry as RankedCollectionEntry, type memory_VectorBackend as VectorBackend, type memory_VectorIndexBundle as VectorIndexBundle, type memory_VectorIndexOptions as VectorIndexOptions, type memory_VectorRecord as VectorRecord, type memory_VectorSearchResult as VectorSearchResult, memory_collection as collection, memory_decay as decay, memory_knowledgeGraph as knowledgeGraph, memory_lightCollection as lightCollection, memory_vectorIndex as vectorIndex };
137
+ }
138
+
139
+ export { type CollectionEntry as C, type HnswAdapter as H, type KnowledgeGraphGraph as K, type LightCollectionBundle as L, type RankedCollectionEntry as R, type VectorIndexBundle as V, type VectorSearchResult as a, type CollectionGraph as b, type CollectionOptions as c, type CollectionPolicy as d, type KnowledgeEdge as e, type LightCollectionEntry as f, type LightCollectionOptions as g, type VectorBackend as h, type VectorIndexOptions as i, type VectorRecord as j, collection as k, decay as l, memory as m, knowledgeGraph as n, lightCollection as o, vectorIndex as v };
@@ -0,0 +1,139 @@
1
+ import { N as Node } from './node-BmerH3kS.js';
2
+ import { a as Graph } from './graph-CCwGKLCm.js';
3
+
4
+ /**
5
+ * Memory patterns (roadmap §4.3).
6
+ *
7
+ * Domain-layer helpers composed from GraphRefly primitives. `vectorIndex` uses
8
+ * an exact-search backend by default; an HNSW adapter can be injected as an
9
+ * optional dependency.
10
+ */
11
+
12
+ type CollectionPolicy = "fifo" | "lru";
13
+ type VectorBackend = "flat" | "hnsw";
14
+ type LightCollectionEntry<T> = {
15
+ readonly id: string;
16
+ readonly value: T;
17
+ readonly createdAtNs: number;
18
+ readonly lastAccessNs: number;
19
+ };
20
+ type LightCollectionOptions = {
21
+ name?: string;
22
+ maxSize?: number;
23
+ policy?: CollectionPolicy;
24
+ };
25
+ type LightCollectionBundle<T> = {
26
+ readonly entries: Node<ReadonlyMap<string, LightCollectionEntry<T>>>;
27
+ upsert: (id: string, value: T) => void;
28
+ remove: (id: string) => void;
29
+ clear: () => void;
30
+ get: (id: string) => T | undefined;
31
+ has: (id: string) => boolean;
32
+ };
33
+ type CollectionEntry<T> = LightCollectionEntry<T> & {
34
+ readonly baseScore: number;
35
+ };
36
+ type RankedCollectionEntry<T> = CollectionEntry<T> & {
37
+ readonly score: number;
38
+ };
39
+ type CollectionOptions<T> = {
40
+ maxSize?: number;
41
+ policy?: CollectionPolicy;
42
+ /**
43
+ * Produces a base score at insert/update time.
44
+ */
45
+ score?: (value: T) => number;
46
+ /**
47
+ * Exponential decay rate per second. 0 disables decay.
48
+ */
49
+ decayRate?: number;
50
+ /**
51
+ * Minimum score floor after decay.
52
+ */
53
+ minScore?: number;
54
+ };
55
+ type CollectionGraph<T> = Graph & {
56
+ upsert: (id: string, value: T, opts?: {
57
+ score?: number;
58
+ }) => void;
59
+ remove: (id: string) => void;
60
+ clear: () => void;
61
+ getItem: (id: string) => CollectionEntry<T> | undefined;
62
+ };
63
+ type VectorRecord<TMeta> = {
64
+ readonly id: string;
65
+ readonly vector: readonly number[];
66
+ readonly meta?: TMeta;
67
+ };
68
+ type VectorSearchResult<TMeta> = {
69
+ readonly id: string;
70
+ readonly score: number;
71
+ readonly meta?: TMeta;
72
+ };
73
+ type HnswAdapter<TMeta> = {
74
+ upsert: (id: string, vector: readonly number[], meta?: TMeta) => void;
75
+ remove: (id: string) => void;
76
+ clear: () => void;
77
+ search: (query: readonly number[], k: number) => ReadonlyArray<VectorSearchResult<TMeta>>;
78
+ };
79
+ type VectorIndexOptions<TMeta> = {
80
+ backend?: VectorBackend;
81
+ dimension?: number;
82
+ /**
83
+ * Optional dependency seam for HNSW.
84
+ */
85
+ hnswFactory?: () => HnswAdapter<TMeta>;
86
+ };
87
+ type VectorIndexBundle<TMeta> = {
88
+ readonly backend: VectorBackend;
89
+ readonly entries: Node<ReadonlyMap<string, VectorRecord<TMeta>>>;
90
+ upsert: (id: string, vector: readonly number[], meta?: TMeta) => void;
91
+ remove: (id: string) => void;
92
+ clear: () => void;
93
+ search: (query: readonly number[], k?: number) => ReadonlyArray<VectorSearchResult<TMeta>>;
94
+ };
95
+ type KnowledgeEdge<TRelation extends string = string> = {
96
+ readonly from: string;
97
+ readonly to: string;
98
+ readonly relation: TRelation;
99
+ readonly weight: number;
100
+ };
101
+ type KnowledgeGraphGraph<TEntity, TRelation extends string = string> = Graph & {
102
+ upsertEntity: (id: string, value: TEntity) => void;
103
+ removeEntity: (id: string) => void;
104
+ link: (from: string, to: string, relation: TRelation, weight?: number) => void;
105
+ unlink: (from: string, to: string, relation?: TRelation) => void;
106
+ related: (id: string, relation?: TRelation) => ReadonlyArray<KnowledgeEdge<TRelation>>;
107
+ };
108
+ declare function decay(baseScore: number, ageSeconds: number, ratePerSecond: number, minScore?: number): number;
109
+ declare function lightCollection<T>(opts?: LightCollectionOptions): LightCollectionBundle<T>;
110
+ declare function collection<T>(name: string, opts?: CollectionOptions<T>): CollectionGraph<T>;
111
+ declare function vectorIndex<TMeta>(opts?: VectorIndexOptions<TMeta>): VectorIndexBundle<TMeta>;
112
+ declare function knowledgeGraph<TEntity, TRelation extends string = string>(name: string): KnowledgeGraphGraph<TEntity, TRelation>;
113
+
114
+ type memory_CollectionEntry<T> = CollectionEntry<T>;
115
+ type memory_CollectionGraph<T> = CollectionGraph<T>;
116
+ type memory_CollectionOptions<T> = CollectionOptions<T>;
117
+ type memory_CollectionPolicy = CollectionPolicy;
118
+ type memory_HnswAdapter<TMeta> = HnswAdapter<TMeta>;
119
+ type memory_KnowledgeEdge<TRelation extends string = string> = KnowledgeEdge<TRelation>;
120
+ type memory_KnowledgeGraphGraph<TEntity, TRelation extends string = string> = KnowledgeGraphGraph<TEntity, TRelation>;
121
+ type memory_LightCollectionBundle<T> = LightCollectionBundle<T>;
122
+ type memory_LightCollectionEntry<T> = LightCollectionEntry<T>;
123
+ type memory_LightCollectionOptions = LightCollectionOptions;
124
+ type memory_RankedCollectionEntry<T> = RankedCollectionEntry<T>;
125
+ type memory_VectorBackend = VectorBackend;
126
+ type memory_VectorIndexBundle<TMeta> = VectorIndexBundle<TMeta>;
127
+ type memory_VectorIndexOptions<TMeta> = VectorIndexOptions<TMeta>;
128
+ type memory_VectorRecord<TMeta> = VectorRecord<TMeta>;
129
+ type memory_VectorSearchResult<TMeta> = VectorSearchResult<TMeta>;
130
+ declare const memory_collection: typeof collection;
131
+ declare const memory_decay: typeof decay;
132
+ declare const memory_knowledgeGraph: typeof knowledgeGraph;
133
+ declare const memory_lightCollection: typeof lightCollection;
134
+ declare const memory_vectorIndex: typeof vectorIndex;
135
+ declare namespace memory {
136
+ export { type memory_CollectionEntry as CollectionEntry, type memory_CollectionGraph as CollectionGraph, type memory_CollectionOptions as CollectionOptions, type memory_CollectionPolicy as CollectionPolicy, type memory_HnswAdapter as HnswAdapter, type memory_KnowledgeEdge as KnowledgeEdge, type memory_KnowledgeGraphGraph as KnowledgeGraphGraph, type memory_LightCollectionBundle as LightCollectionBundle, type memory_LightCollectionEntry as LightCollectionEntry, type memory_LightCollectionOptions as LightCollectionOptions, type memory_RankedCollectionEntry as RankedCollectionEntry, type memory_VectorBackend as VectorBackend, type memory_VectorIndexBundle as VectorIndexBundle, type memory_VectorIndexOptions as VectorIndexOptions, type memory_VectorRecord as VectorRecord, type memory_VectorSearchResult as VectorSearchResult, memory_collection as collection, memory_decay as decay, memory_knowledgeGraph as knowledgeGraph, memory_lightCollection as lightCollection, memory_vectorIndex as vectorIndex };
137
+ }
138
+
139
+ export { type CollectionEntry as C, type HnswAdapter as H, type KnowledgeGraphGraph as K, type LightCollectionBundle as L, type RankedCollectionEntry as R, type VectorIndexBundle as V, type VectorSearchResult as a, type CollectionGraph as b, type CollectionOptions as c, type CollectionPolicy as d, type KnowledgeEdge as e, type LightCollectionEntry as f, type LightCollectionOptions as g, type VectorBackend as h, type VectorIndexOptions as i, type VectorRecord as j, collection as k, decay as l, memory as m, knowledgeGraph as n, lightCollection as o, vectorIndex as v };
@@ -0,0 +1,269 @@
1
+ import { N as Node } from './node-BmerH3kS.cjs';
2
+ import { a as Graph, G as GraphOptions } from './graph-DNCrvZSn.cjs';
3
+
4
+ /**
5
+ * Messaging patterns (roadmap §4.2).
6
+ *
7
+ * Pulsar-inspired messaging features modeled as graph factories:
8
+ * - `topic()` for append-only topic streams
9
+ * - `subscription()` for cursor-based consumers
10
+ * - `jobQueue()` for queue claim/ack flow
11
+ */
12
+
13
+ type TopicOptions = {
14
+ graph?: GraphOptions;
15
+ retainedLimit?: number;
16
+ };
17
+ declare class TopicGraph<T> extends Graph {
18
+ private readonly _log;
19
+ readonly events: Node<readonly T[]>;
20
+ /**
21
+ * Most recently published value, or `null` when the topic has no entries
22
+ * yet. Spec §5.12 reserves `undefined` as the protocol-internal "never
23
+ * sent DATA" sentinel — `null` is the idiomatic "empty / no value" signal
24
+ * for domain nodes. F7.
25
+ *
26
+ * **Caveat when `T` itself includes `null`** (e.g., `topic<number | null>`):
27
+ * `latest === null` is ambiguous — it could mean "no publish yet" OR "a
28
+ * `null` value was published". Use {@link hasLatest} to disambiguate, or
29
+ * observe {@link events} directly and track length yourself.
30
+ */
31
+ readonly latest: Node<T | null>;
32
+ /**
33
+ * Reactive `true` once the topic has at least one published entry.
34
+ * Disambiguates "`null` never published" from "`null` was published" when
35
+ * `T` includes `null`.
36
+ */
37
+ readonly hasLatest: Node<boolean>;
38
+ constructor(name: string, opts?: TopicOptions);
39
+ publish(value: T): void;
40
+ retained(): readonly T[];
41
+ }
42
+ type SubscriptionOptions = {
43
+ graph?: GraphOptions;
44
+ cursor?: number;
45
+ };
46
+ declare class SubscriptionGraph<T> extends Graph {
47
+ readonly source: Node<readonly T[]>;
48
+ readonly cursor: Node<number>;
49
+ readonly available: Node<readonly T[]>;
50
+ /**
51
+ * Reference to the upstream topic graph. Intentionally NOT mounted
52
+ * under this subscription: a subscription is a VIEW over an
53
+ * externally-owned topic. Double-mounting (e.g. hub-owned topic +
54
+ * sub-mount here) would make either-side teardown leave the other
55
+ * holding a dead reference. Node-level `derived([topicEvents], …)`
56
+ * still wires the data dependency across graph boundaries. D1(e).
57
+ */
58
+ readonly topic: TopicGraph<T>;
59
+ constructor(name: string, topicGraph: TopicGraph<T>, opts?: SubscriptionOptions);
60
+ ack(count?: number): number;
61
+ pull(limit?: number, opts?: {
62
+ ack?: boolean;
63
+ }): readonly T[];
64
+ }
65
+ type JobState = "queued" | "inflight";
66
+ type JobEnvelope<T> = {
67
+ id: string;
68
+ payload: T;
69
+ attempts: number;
70
+ metadata: Readonly<Record<string, unknown>>;
71
+ state: JobState;
72
+ };
73
+ type JobQueueOptions = {
74
+ graph?: GraphOptions;
75
+ };
76
+ declare class JobQueueGraph<T> extends Graph {
77
+ private readonly _pending;
78
+ private readonly _jobs;
79
+ private _seq;
80
+ readonly pending: Node<readonly string[]>;
81
+ readonly jobs: Node<ReadonlyMap<string, JobEnvelope<T>>>;
82
+ readonly depth: Node<number>;
83
+ constructor(name: string, opts?: JobQueueOptions);
84
+ enqueue(payload: T, opts?: {
85
+ id?: string;
86
+ metadata?: Record<string, unknown>;
87
+ }): string;
88
+ claim(limit?: number): readonly JobEnvelope<T>[];
89
+ ack(id: string): boolean;
90
+ nack(id: string, opts?: {
91
+ requeue?: boolean;
92
+ }): boolean;
93
+ }
94
+ type JobFlowOptions = {
95
+ graph?: GraphOptions;
96
+ stages?: readonly string[];
97
+ maxPerPump?: number;
98
+ };
99
+ declare class JobFlowGraph<T> extends Graph {
100
+ private readonly _stageNames;
101
+ private readonly _queues;
102
+ private readonly _completed;
103
+ readonly completed: Node<readonly JobEnvelope<T>[]>;
104
+ readonly completedCount: Node<number>;
105
+ constructor(name: string, opts?: JobFlowOptions);
106
+ stages(): readonly string[];
107
+ queue(stage: string): JobQueueGraph<T>;
108
+ enqueue(payload: T, opts?: {
109
+ id?: string;
110
+ metadata?: Record<string, unknown>;
111
+ }): string;
112
+ retainedCompleted(): readonly JobEnvelope<T>[];
113
+ }
114
+ type TopicBridgeOptions<TIn, TOut> = {
115
+ graph?: GraphOptions;
116
+ cursor?: number;
117
+ maxPerPump?: number;
118
+ map?: (value: TIn) => TOut | undefined;
119
+ };
120
+ declare class TopicBridgeGraph<TIn, TOut = TIn> extends Graph {
121
+ private readonly _sourceSub;
122
+ private readonly _target;
123
+ readonly bridgedCount: Node<number>;
124
+ constructor(name: string, sourceTopic: TopicGraph<TIn>, targetTopic: TopicGraph<TOut>, opts?: TopicBridgeOptions<TIn, TOut>);
125
+ }
126
+ type MessagingHubOptions = {
127
+ graph?: GraphOptions;
128
+ /**
129
+ * Default `TopicOptions` applied to every topic created via `topic(name)`
130
+ * without explicit options. Per-call opts override. Default: `{}`
131
+ * (unbounded retention per topic unless `retainedLimit` is set per call).
132
+ */
133
+ defaultTopicOptions?: TopicOptions;
134
+ };
135
+ /**
136
+ * Lazy Pulsar-inspired topic registry. Manages a named set of {@link TopicGraph}
137
+ * instances with retention + cursor semantics. Topics are created on first
138
+ * access; `removeTopic(name)` unmounts and tears down via {@link Graph.remove}.
139
+ *
140
+ * **Relationship to `pubsub()` in `src/extra/pubsub.ts`:** `pubsub` is a
141
+ * lightweight last-value state hub (no retention, no cursors). `MessagingHubGraph`
142
+ * is the full messaging hub — retained message logs, cursor-based subscriptions,
143
+ * and pattern-layer lifecycle management.
144
+ *
145
+ * @category patterns
146
+ */
147
+ declare class MessagingHubGraph extends Graph {
148
+ private readonly _topics;
149
+ private _version;
150
+ private readonly _defaultTopicOptions;
151
+ constructor(name: string, opts?: MessagingHubOptions);
152
+ /** Monotonic counter advancing on topic create/remove. */
153
+ get version(): number;
154
+ /** Number of topics currently in the hub. */
155
+ get size(): number;
156
+ /** Checks topic existence without creating. */
157
+ has(name: string): boolean;
158
+ /** Iterator over topic names. */
159
+ topicNames(): IterableIterator<string>;
160
+ /**
161
+ * Returns the {@link TopicGraph} for `name`, creating lazily on first call.
162
+ * Subsequent calls with the same name return the same instance (options on
163
+ * repeat calls are ignored — the topic is already configured).
164
+ */
165
+ topic<T = unknown>(name: string, opts?: TopicOptions): TopicGraph<T>;
166
+ /**
167
+ * Publishes a value to the topic, lazily creating it on first publish.
168
+ *
169
+ * **Late-subscriber caveat:** the topic is created lazily, so subscribers
170
+ * that attach AFTER a publish only see the retained window (governed by
171
+ * `retainedLimit` on `TopicOptions` / `defaultTopicOptions`). If
172
+ * `retainedLimit === 0` is set explicitly, early publishes are
173
+ * effectively dropped — prefer an unset `retainedLimit` (unbounded
174
+ * retention) or subscribe before publishing when late-subscribers matter.
175
+ */
176
+ publish<T = unknown>(name: string, value: T): void;
177
+ /**
178
+ * Bulk publish — issues all publishes inside one outer batch. New topics
179
+ * are created on demand. No-op if `entries` yields nothing.
180
+ *
181
+ * **Iterable consumption (F6):** `entries` is consumed once (single-pass)
182
+ * INSIDE the batch frame. If the iterator throws mid-way, the batch is
183
+ * discarded and NO publishes are visible to subscribers (all-or-nothing).
184
+ * Pass an array or `Set` for multi-shot callers.
185
+ */
186
+ publishMany(entries: Iterable<[string, unknown]>): void;
187
+ /**
188
+ * Creates a {@link SubscriptionGraph} over a named topic. The topic is
189
+ * lazily created if missing. Subscription lifecycle is owned by the caller —
190
+ * the hub does NOT mount the subscription.
191
+ *
192
+ * @param subName - Local name for the subscription graph.
193
+ * @param topicName - Hub topic to subscribe to.
194
+ * @param opts - `SubscriptionOptions` (initial cursor, etc.).
195
+ */
196
+ subscribe<T = unknown>(subName: string, topicName: string, opts?: SubscriptionOptions): SubscriptionGraph<T>;
197
+ /**
198
+ * Unmounts and tears down the topic's graph. Returns `true` if the topic
199
+ * existed. Subscribers receive `TEARDOWN` via {@link Graph.remove}.
200
+ */
201
+ removeTopic(name: string): boolean;
202
+ }
203
+ /**
204
+ * Creates a Pulsar-inspired topic graph (append-only retained stream + latest value).
205
+ */
206
+ declare function topic<T>(name: string, opts?: TopicOptions): TopicGraph<T>;
207
+ /**
208
+ * Creates a lazy Pulsar-inspired messaging hub. Topics are created on first access
209
+ * via `hub.topic(name)`; `hub.publish(name, value)` shortcuts through the registry.
210
+ *
211
+ * @example
212
+ * ```ts
213
+ * import { messagingHub } from "@graphrefly/graphrefly-ts";
214
+ *
215
+ * const hub = messagingHub("main", { defaultTopicOptions: { retainedLimit: 256 } });
216
+ * hub.publish("orders", { id: 1 });
217
+ * hub.publishMany([["shipments", { id: 1 }], ["orders", { id: 2 }]]);
218
+ * const sub = hub.subscribe("orders-worker", "orders", { cursor: 0 });
219
+ * ```
220
+ */
221
+ declare function messagingHub(name: string, opts?: MessagingHubOptions): MessagingHubGraph;
222
+ /**
223
+ * Creates a cursor-based subscription graph over a topic.
224
+ */
225
+ declare function subscription<T>(name: string, topicGraph: TopicGraph<T>, opts?: SubscriptionOptions): SubscriptionGraph<T>;
226
+ /**
227
+ * Creates a Pulsar-inspired job queue graph with claim/ack/nack workflow.
228
+ */
229
+ declare function jobQueue<T>(name: string, opts?: JobQueueOptions): JobQueueGraph<T>;
230
+ /**
231
+ * Creates an autonomous multi-stage queue chain graph.
232
+ */
233
+ declare function jobFlow<T>(name: string, opts?: JobFlowOptions): JobFlowGraph<T>;
234
+ /**
235
+ * Creates an autonomous cursor-based topic relay graph.
236
+ */
237
+ declare function topicBridge<TIn, TOut = TIn>(name: string, sourceTopic: TopicGraph<TIn>, targetTopic: TopicGraph<TOut>, opts?: TopicBridgeOptions<TIn, TOut>): TopicBridgeGraph<TIn, TOut>;
238
+
239
+ type messaging_JobEnvelope<T> = JobEnvelope<T>;
240
+ type messaging_JobFlowGraph<T> = JobFlowGraph<T>;
241
+ declare const messaging_JobFlowGraph: typeof JobFlowGraph;
242
+ type messaging_JobFlowOptions = JobFlowOptions;
243
+ type messaging_JobQueueGraph<T> = JobQueueGraph<T>;
244
+ declare const messaging_JobQueueGraph: typeof JobQueueGraph;
245
+ type messaging_JobQueueOptions = JobQueueOptions;
246
+ type messaging_JobState = JobState;
247
+ type messaging_MessagingHubGraph = MessagingHubGraph;
248
+ declare const messaging_MessagingHubGraph: typeof MessagingHubGraph;
249
+ type messaging_MessagingHubOptions = MessagingHubOptions;
250
+ type messaging_SubscriptionGraph<T> = SubscriptionGraph<T>;
251
+ declare const messaging_SubscriptionGraph: typeof SubscriptionGraph;
252
+ type messaging_SubscriptionOptions = SubscriptionOptions;
253
+ type messaging_TopicBridgeGraph<TIn, TOut = TIn> = TopicBridgeGraph<TIn, TOut>;
254
+ declare const messaging_TopicBridgeGraph: typeof TopicBridgeGraph;
255
+ type messaging_TopicBridgeOptions<TIn, TOut> = TopicBridgeOptions<TIn, TOut>;
256
+ type messaging_TopicGraph<T> = TopicGraph<T>;
257
+ declare const messaging_TopicGraph: typeof TopicGraph;
258
+ type messaging_TopicOptions = TopicOptions;
259
+ declare const messaging_jobFlow: typeof jobFlow;
260
+ declare const messaging_jobQueue: typeof jobQueue;
261
+ declare const messaging_messagingHub: typeof messagingHub;
262
+ declare const messaging_subscription: typeof subscription;
263
+ declare const messaging_topic: typeof topic;
264
+ declare const messaging_topicBridge: typeof topicBridge;
265
+ declare namespace messaging {
266
+ export { type messaging_JobEnvelope as JobEnvelope, messaging_JobFlowGraph as JobFlowGraph, type messaging_JobFlowOptions as JobFlowOptions, messaging_JobQueueGraph as JobQueueGraph, type messaging_JobQueueOptions as JobQueueOptions, type messaging_JobState as JobState, messaging_MessagingHubGraph as MessagingHubGraph, type messaging_MessagingHubOptions as MessagingHubOptions, messaging_SubscriptionGraph as SubscriptionGraph, type messaging_SubscriptionOptions as SubscriptionOptions, messaging_TopicBridgeGraph as TopicBridgeGraph, type messaging_TopicBridgeOptions as TopicBridgeOptions, messaging_TopicGraph as TopicGraph, type messaging_TopicOptions as TopicOptions, messaging_jobFlow as jobFlow, messaging_jobQueue as jobQueue, messaging_messagingHub as messagingHub, messaging_subscription as subscription, messaging_topic as topic, messaging_topicBridge as topicBridge };
267
+ }
268
+
269
+ export { TopicGraph as T, messaging as m };