@loreai/core 0.17.1 → 0.19.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 (248) hide show
  1. package/dist/bun/agents-file.d.ts +4 -0
  2. package/dist/bun/agents-file.d.ts.map +1 -1
  3. package/dist/bun/config.d.ts +2 -0
  4. package/dist/bun/config.d.ts.map +1 -1
  5. package/dist/bun/curator.d.ts +45 -0
  6. package/dist/bun/curator.d.ts.map +1 -1
  7. package/dist/bun/data-dir.d.ts +18 -0
  8. package/dist/bun/data-dir.d.ts.map +1 -0
  9. package/dist/bun/db.d.ts +85 -0
  10. package/dist/bun/db.d.ts.map +1 -1
  11. package/dist/bun/distillation.d.ts +2 -13
  12. package/dist/bun/distillation.d.ts.map +1 -1
  13. package/dist/bun/embedding-vendor.d.ts +22 -38
  14. package/dist/bun/embedding-vendor.d.ts.map +1 -1
  15. package/dist/bun/embedding-worker-types.d.ts +17 -12
  16. package/dist/bun/embedding-worker-types.d.ts.map +1 -1
  17. package/dist/bun/embedding-worker.d.ts +9 -2
  18. package/dist/bun/embedding-worker.d.ts.map +1 -1
  19. package/dist/bun/embedding-worker.js +38864 -33
  20. package/dist/bun/embedding-worker.js.map +4 -4
  21. package/dist/bun/embedding.d.ts +35 -23
  22. package/dist/bun/embedding.d.ts.map +1 -1
  23. package/dist/bun/gradient.d.ts +17 -1
  24. package/dist/bun/gradient.d.ts.map +1 -1
  25. package/dist/bun/import/detect.d.ts +14 -0
  26. package/dist/bun/import/detect.d.ts.map +1 -0
  27. package/dist/bun/import/extract.d.ts +43 -0
  28. package/dist/bun/import/extract.d.ts.map +1 -0
  29. package/dist/bun/import/history.d.ts +40 -0
  30. package/dist/bun/import/history.d.ts.map +1 -0
  31. package/dist/bun/import/index.d.ts +17 -0
  32. package/dist/bun/import/index.d.ts.map +1 -0
  33. package/dist/bun/import/providers/aider.d.ts +2 -0
  34. package/dist/bun/import/providers/aider.d.ts.map +1 -0
  35. package/dist/bun/import/providers/claude-code.d.ts +2 -0
  36. package/dist/bun/import/providers/claude-code.d.ts.map +1 -0
  37. package/dist/bun/import/providers/cline.d.ts +2 -0
  38. package/dist/bun/import/providers/cline.d.ts.map +1 -0
  39. package/dist/bun/import/providers/codex.d.ts +2 -0
  40. package/dist/bun/import/providers/codex.d.ts.map +1 -0
  41. package/dist/bun/import/providers/continue.d.ts +2 -0
  42. package/dist/bun/import/providers/continue.d.ts.map +1 -0
  43. package/dist/bun/import/providers/index.d.ts +19 -0
  44. package/dist/bun/import/providers/index.d.ts.map +1 -0
  45. package/dist/bun/import/providers/opencode.d.ts +2 -0
  46. package/dist/bun/import/providers/opencode.d.ts.map +1 -0
  47. package/dist/bun/import/providers/pi.d.ts +2 -0
  48. package/dist/bun/import/providers/pi.d.ts.map +1 -0
  49. package/dist/bun/import/types.d.ts +82 -0
  50. package/dist/bun/import/types.d.ts.map +1 -0
  51. package/dist/bun/index.d.ts +5 -2
  52. package/dist/bun/index.d.ts.map +1 -1
  53. package/dist/bun/index.js +3150 -439
  54. package/dist/bun/index.js.map +4 -4
  55. package/dist/bun/instruction-detect.d.ts +66 -0
  56. package/dist/bun/instruction-detect.d.ts.map +1 -0
  57. package/dist/bun/log.d.ts +9 -0
  58. package/dist/bun/log.d.ts.map +1 -1
  59. package/dist/bun/ltm.d.ts +139 -5
  60. package/dist/bun/ltm.d.ts.map +1 -1
  61. package/dist/bun/pattern-extract.d.ts +7 -0
  62. package/dist/bun/pattern-extract.d.ts.map +1 -1
  63. package/dist/bun/prompt.d.ts +1 -1
  64. package/dist/bun/prompt.d.ts.map +1 -1
  65. package/dist/bun/recall.d.ts.map +1 -1
  66. package/dist/bun/search.d.ts +5 -3
  67. package/dist/bun/search.d.ts.map +1 -1
  68. package/dist/bun/session-limiter.d.ts +26 -0
  69. package/dist/bun/session-limiter.d.ts.map +1 -0
  70. package/dist/bun/temporal.d.ts +2 -0
  71. package/dist/bun/temporal.d.ts.map +1 -1
  72. package/dist/bun/types.d.ts +1 -1
  73. package/dist/node/agents-file.d.ts +4 -0
  74. package/dist/node/agents-file.d.ts.map +1 -1
  75. package/dist/node/config.d.ts +2 -0
  76. package/dist/node/config.d.ts.map +1 -1
  77. package/dist/node/curator.d.ts +45 -0
  78. package/dist/node/curator.d.ts.map +1 -1
  79. package/dist/node/data-dir.d.ts +18 -0
  80. package/dist/node/data-dir.d.ts.map +1 -0
  81. package/dist/node/db.d.ts +85 -0
  82. package/dist/node/db.d.ts.map +1 -1
  83. package/dist/node/distillation.d.ts +2 -13
  84. package/dist/node/distillation.d.ts.map +1 -1
  85. package/dist/node/embedding-vendor.d.ts +22 -38
  86. package/dist/node/embedding-vendor.d.ts.map +1 -1
  87. package/dist/node/embedding-worker-types.d.ts +17 -12
  88. package/dist/node/embedding-worker-types.d.ts.map +1 -1
  89. package/dist/node/embedding-worker.d.ts +9 -2
  90. package/dist/node/embedding-worker.d.ts.map +1 -1
  91. package/dist/node/embedding-worker.js +38864 -33
  92. package/dist/node/embedding-worker.js.map +4 -4
  93. package/dist/node/embedding.d.ts +35 -23
  94. package/dist/node/embedding.d.ts.map +1 -1
  95. package/dist/node/gradient.d.ts +17 -1
  96. package/dist/node/gradient.d.ts.map +1 -1
  97. package/dist/node/import/detect.d.ts +14 -0
  98. package/dist/node/import/detect.d.ts.map +1 -0
  99. package/dist/node/import/extract.d.ts +43 -0
  100. package/dist/node/import/extract.d.ts.map +1 -0
  101. package/dist/node/import/history.d.ts +40 -0
  102. package/dist/node/import/history.d.ts.map +1 -0
  103. package/dist/node/import/index.d.ts +17 -0
  104. package/dist/node/import/index.d.ts.map +1 -0
  105. package/dist/node/import/providers/aider.d.ts +2 -0
  106. package/dist/node/import/providers/aider.d.ts.map +1 -0
  107. package/dist/node/import/providers/claude-code.d.ts +2 -0
  108. package/dist/node/import/providers/claude-code.d.ts.map +1 -0
  109. package/dist/node/import/providers/cline.d.ts +2 -0
  110. package/dist/node/import/providers/cline.d.ts.map +1 -0
  111. package/dist/node/import/providers/codex.d.ts +2 -0
  112. package/dist/node/import/providers/codex.d.ts.map +1 -0
  113. package/dist/node/import/providers/continue.d.ts +2 -0
  114. package/dist/node/import/providers/continue.d.ts.map +1 -0
  115. package/dist/node/import/providers/index.d.ts +19 -0
  116. package/dist/node/import/providers/index.d.ts.map +1 -0
  117. package/dist/node/import/providers/opencode.d.ts +2 -0
  118. package/dist/node/import/providers/opencode.d.ts.map +1 -0
  119. package/dist/node/import/providers/pi.d.ts +2 -0
  120. package/dist/node/import/providers/pi.d.ts.map +1 -0
  121. package/dist/node/import/types.d.ts +82 -0
  122. package/dist/node/import/types.d.ts.map +1 -0
  123. package/dist/node/index.d.ts +5 -2
  124. package/dist/node/index.d.ts.map +1 -1
  125. package/dist/node/index.js +3150 -439
  126. package/dist/node/index.js.map +4 -4
  127. package/dist/node/instruction-detect.d.ts +66 -0
  128. package/dist/node/instruction-detect.d.ts.map +1 -0
  129. package/dist/node/log.d.ts +9 -0
  130. package/dist/node/log.d.ts.map +1 -1
  131. package/dist/node/ltm.d.ts +139 -5
  132. package/dist/node/ltm.d.ts.map +1 -1
  133. package/dist/node/pattern-extract.d.ts +7 -0
  134. package/dist/node/pattern-extract.d.ts.map +1 -1
  135. package/dist/node/prompt.d.ts +1 -1
  136. package/dist/node/prompt.d.ts.map +1 -1
  137. package/dist/node/recall.d.ts.map +1 -1
  138. package/dist/node/search.d.ts +5 -3
  139. package/dist/node/search.d.ts.map +1 -1
  140. package/dist/node/session-limiter.d.ts +26 -0
  141. package/dist/node/session-limiter.d.ts.map +1 -0
  142. package/dist/node/temporal.d.ts +2 -0
  143. package/dist/node/temporal.d.ts.map +1 -1
  144. package/dist/node/types.d.ts +1 -1
  145. package/dist/types/agents-file.d.ts +4 -0
  146. package/dist/types/agents-file.d.ts.map +1 -1
  147. package/dist/types/config.d.ts +2 -0
  148. package/dist/types/config.d.ts.map +1 -1
  149. package/dist/types/curator.d.ts +45 -0
  150. package/dist/types/curator.d.ts.map +1 -1
  151. package/dist/types/data-dir.d.ts +18 -0
  152. package/dist/types/data-dir.d.ts.map +1 -0
  153. package/dist/types/db.d.ts +85 -0
  154. package/dist/types/db.d.ts.map +1 -1
  155. package/dist/types/distillation.d.ts +2 -13
  156. package/dist/types/distillation.d.ts.map +1 -1
  157. package/dist/types/embedding-vendor.d.ts +22 -38
  158. package/dist/types/embedding-vendor.d.ts.map +1 -1
  159. package/dist/types/embedding-worker-types.d.ts +17 -12
  160. package/dist/types/embedding-worker-types.d.ts.map +1 -1
  161. package/dist/types/embedding-worker.d.ts +9 -2
  162. package/dist/types/embedding-worker.d.ts.map +1 -1
  163. package/dist/types/embedding.d.ts +35 -23
  164. package/dist/types/embedding.d.ts.map +1 -1
  165. package/dist/types/gradient.d.ts +17 -1
  166. package/dist/types/gradient.d.ts.map +1 -1
  167. package/dist/types/import/detect.d.ts +14 -0
  168. package/dist/types/import/detect.d.ts.map +1 -0
  169. package/dist/types/import/extract.d.ts +43 -0
  170. package/dist/types/import/extract.d.ts.map +1 -0
  171. package/dist/types/import/history.d.ts +40 -0
  172. package/dist/types/import/history.d.ts.map +1 -0
  173. package/dist/types/import/index.d.ts +17 -0
  174. package/dist/types/import/index.d.ts.map +1 -0
  175. package/dist/types/import/providers/aider.d.ts +2 -0
  176. package/dist/types/import/providers/aider.d.ts.map +1 -0
  177. package/dist/types/import/providers/claude-code.d.ts +2 -0
  178. package/dist/types/import/providers/claude-code.d.ts.map +1 -0
  179. package/dist/types/import/providers/cline.d.ts +2 -0
  180. package/dist/types/import/providers/cline.d.ts.map +1 -0
  181. package/dist/types/import/providers/codex.d.ts +2 -0
  182. package/dist/types/import/providers/codex.d.ts.map +1 -0
  183. package/dist/types/import/providers/continue.d.ts +2 -0
  184. package/dist/types/import/providers/continue.d.ts.map +1 -0
  185. package/dist/types/import/providers/index.d.ts +19 -0
  186. package/dist/types/import/providers/index.d.ts.map +1 -0
  187. package/dist/types/import/providers/opencode.d.ts +2 -0
  188. package/dist/types/import/providers/opencode.d.ts.map +1 -0
  189. package/dist/types/import/providers/pi.d.ts +2 -0
  190. package/dist/types/import/providers/pi.d.ts.map +1 -0
  191. package/dist/types/import/types.d.ts +82 -0
  192. package/dist/types/import/types.d.ts.map +1 -0
  193. package/dist/types/index.d.ts +5 -2
  194. package/dist/types/index.d.ts.map +1 -1
  195. package/dist/types/instruction-detect.d.ts +66 -0
  196. package/dist/types/instruction-detect.d.ts.map +1 -0
  197. package/dist/types/log.d.ts +9 -0
  198. package/dist/types/log.d.ts.map +1 -1
  199. package/dist/types/ltm.d.ts +139 -5
  200. package/dist/types/ltm.d.ts.map +1 -1
  201. package/dist/types/pattern-extract.d.ts +7 -0
  202. package/dist/types/pattern-extract.d.ts.map +1 -1
  203. package/dist/types/prompt.d.ts +1 -1
  204. package/dist/types/prompt.d.ts.map +1 -1
  205. package/dist/types/recall.d.ts.map +1 -1
  206. package/dist/types/search.d.ts +5 -3
  207. package/dist/types/search.d.ts.map +1 -1
  208. package/dist/types/session-limiter.d.ts +26 -0
  209. package/dist/types/session-limiter.d.ts.map +1 -0
  210. package/dist/types/temporal.d.ts +2 -0
  211. package/dist/types/temporal.d.ts.map +1 -1
  212. package/dist/types/types.d.ts +1 -1
  213. package/package.json +3 -4
  214. package/src/agents-file.ts +41 -13
  215. package/src/config.ts +31 -18
  216. package/src/curator.ts +163 -75
  217. package/src/data-dir.ts +76 -0
  218. package/src/db.ts +457 -11
  219. package/src/distillation.ts +65 -16
  220. package/src/embedding-vendor.ts +23 -40
  221. package/src/embedding-worker-types.ts +19 -11
  222. package/src/embedding-worker.ts +111 -47
  223. package/src/embedding.ts +224 -174
  224. package/src/gradient.ts +192 -75
  225. package/src/import/detect.ts +37 -0
  226. package/src/import/extract.ts +137 -0
  227. package/src/import/history.ts +99 -0
  228. package/src/import/index.ts +45 -0
  229. package/src/import/providers/aider.ts +207 -0
  230. package/src/import/providers/claude-code.ts +339 -0
  231. package/src/import/providers/cline.ts +324 -0
  232. package/src/import/providers/codex.ts +369 -0
  233. package/src/import/providers/continue.ts +304 -0
  234. package/src/import/providers/index.ts +32 -0
  235. package/src/import/providers/opencode.ts +272 -0
  236. package/src/import/providers/pi.ts +332 -0
  237. package/src/import/types.ts +91 -0
  238. package/src/index.ts +13 -0
  239. package/src/instruction-detect.ts +275 -0
  240. package/src/log.ts +91 -3
  241. package/src/ltm.ts +789 -41
  242. package/src/pattern-extract.ts +41 -0
  243. package/src/prompt.ts +7 -1
  244. package/src/recall.ts +43 -5
  245. package/src/search.ts +7 -5
  246. package/src/session-limiter.ts +47 -0
  247. package/src/temporal.ts +18 -6
  248. package/src/types.ts +1 -1
package/dist/node/db.d.ts CHANGED
@@ -47,6 +47,16 @@ export declare function projectName(id: string): string | null;
47
47
  * Must be called before ensureProject() to get an accurate result.
48
48
  */
49
49
  export declare function isFirstRun(): boolean;
50
+ /**
51
+ * Get the timestamp of the last conversation import offer/run for a project.
52
+ * Returns null if import has never been offered for this project.
53
+ */
54
+ export declare function getLastImportAt(projectPath: string): number | null;
55
+ /**
56
+ * Record that conversation import was offered/run for a project.
57
+ * Prevents auto-import from re-prompting, and enables incremental imports.
58
+ */
59
+ export declare function setLastImportAt(projectPath: string, timestamp: number): void;
50
60
  /**
51
61
  * Load persisted forceMinLayer for a session. Returns 0 if none stored.
52
62
  */
@@ -68,6 +78,8 @@ export type SessionCostSnapshot = {
68
78
  ttlSavings: number;
69
79
  ttlHits: number;
70
80
  batchSavings: number;
81
+ avoidedCompactions: number;
82
+ avoidedCompactionCost: number;
71
83
  };
72
84
  /**
73
85
  * Persist a session's cost snapshot. Uses INSERT OR REPLACE so it works
@@ -84,6 +96,79 @@ export declare function loadSessionCosts(sessionID: string): SessionCostSnapshot
84
96
  * Returns a map of sessionID → SessionCostSnapshot.
85
97
  */
86
98
  export declare function loadAllSessionCosts(): Map<string, SessionCostSnapshot>;
99
+ /** Fields that can be persisted for session tracking state. */
100
+ export type SessionTrackingState = {
101
+ lastCuratedAt?: number;
102
+ messageCount?: number;
103
+ turnsSinceCuration?: number;
104
+ consecutiveTextOnlyTurns?: number;
105
+ ltmCacheText?: string | null;
106
+ ltmCacheTokens?: number | null;
107
+ ltmPinText?: string | null;
108
+ ltmPinTokens?: number | null;
109
+ fingerprint?: string;
110
+ headerSessionId?: string | null;
111
+ headerName?: string | null;
112
+ resolvedConversationTTL?: string;
113
+ warmupState?: string | null;
114
+ dynamicContextCap?: number;
115
+ bustRateEMA?: number;
116
+ interBustIntervalEMA?: number;
117
+ lastLayer?: number;
118
+ lastKnownInput?: number;
119
+ lastTurnAt?: number;
120
+ lastBustAt?: number;
121
+ };
122
+ /**
123
+ * Persist session tracking state. Ensures the row exists, then updates
124
+ * only the fields that are explicitly provided (not undefined).
125
+ */
126
+ export declare function saveSessionTracking(sessionID: string, state: SessionTrackingState): void;
127
+ /** Loaded session tracking state. */
128
+ export type LoadedSessionTracking = {
129
+ lastCuratedAt: number;
130
+ messageCount: number;
131
+ turnsSinceCuration: number;
132
+ consecutiveTextOnlyTurns: number;
133
+ ltmCacheText: string | null;
134
+ ltmCacheTokens: number | null;
135
+ ltmPinText: string | null;
136
+ ltmPinTokens: number | null;
137
+ fingerprint: string;
138
+ headerSessionId: string | null;
139
+ headerName: string | null;
140
+ resolvedConversationTTL: string;
141
+ warmupState: string | null;
142
+ dynamicContextCap: number;
143
+ bustRateEMA: number;
144
+ interBustIntervalEMA: number;
145
+ lastLayer: number;
146
+ lastKnownInput: number;
147
+ lastTurnAt: number;
148
+ lastBustAt: number;
149
+ };
150
+ /**
151
+ * Load persisted session tracking state. Returns null if no row exists.
152
+ */
153
+ export declare function loadSessionTracking(sessionID: string): LoadedSessionTracking | null;
154
+ /**
155
+ * Load all persisted header → session ID mappings from the session_state table.
156
+ *
157
+ * Used on gateway startup (in initIfNeeded) to pre-populate the in-memory
158
+ * headerSessionIndex so Tier 1 session identification works immediately
159
+ * after a process restart — without this, the first post-restart request
160
+ * with a known session header would generate a new session ID and orphan
161
+ * the old session's persisted state.
162
+ */
163
+ export declare function loadHeaderSessionIndex(): Array<{
164
+ sessionId: string;
165
+ headerSessionId: string;
166
+ headerName: string;
167
+ }>;
168
+ /** Get a kv_meta value by key. Returns null if not found. */
169
+ export declare function getKV(key: string): string | null;
170
+ /** Set a kv_meta value (upsert). */
171
+ export declare function setKV(key: string, value: string): void;
87
172
  /** Get a metadata value by key. Returns null if not found. */
88
173
  export declare function getMeta(key: string): string | null;
89
174
  /** Set a metadata value (upsert). */
@@ -1 +1 @@
1
- {"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMtC;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAMvE;AA0bD,4DAA4D;AAC5D,wBAAgB,MAAM,IAAI,MAAM,CAI/B;AAID,wBAAgB,EAAE,IAAI,QAAQ,CA8C7B;AAsHD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,IAAI,CAoCN;AAED,wBAAgB,KAAK,SAKpB;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAiEjE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAW1D;AAED,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKrD;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAKpC;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAK3D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM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I,CAKhD;AAED,oCAAoC;AACpC,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAMtD;AAMD,8DAA8D;AAC9D,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKlD;AAED,qCAAqC;AACrC,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAMxD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAMtC"}
@@ -147,21 +147,9 @@ export declare function run(input: {
147
147
  providerID: string;
148
148
  modelID: string;
149
149
  };
150
- /** Skip minMessages threshold check — distill whatever is pending */
151
150
  force?: boolean;
152
- /** Skip meta-distillation even when gen-0 count exceeds the threshold.
153
- * Used when the upstream prompt cache is likely still warm — meta-distillation
154
- * rewrites distillation row IDs, which invalidates the distilled prefix cache
155
- * and causes a cache bust on the next turn. Callers should set this to true
156
- * when `Date.now() - getLastTurnAt(sessionID) < cacheTTL`. */
157
151
  skipMeta?: boolean;
158
- /** When true, all LLM calls in this run are marked urgent and bypass the
159
- * batch queue (if one is active). Use for compaction and overflow recovery
160
- * where the caller is blocking on the result. Background/idle distillation
161
- * should leave this false to benefit from batch API 50% cost savings. */
162
152
  urgent?: boolean;
163
- /** Whether the LLM call will use batch or direct pricing. Recorded on the
164
- * distillation row for accurate historical cost estimates. */
165
153
  callType?: "batch" | "direct";
166
154
  }): Promise<{
167
155
  rounds: number;
@@ -173,7 +161,8 @@ export declare function run(input: {
173
161
  * via `<previous-meta-summary>` so the LLM updates in place rather than
174
162
  * re-deriving from scratch.
175
163
  *
176
- * Exported for tests; `run()` is the production entry point.
164
+ * Serialized per session via the same p-limit(1) as `run()`. Exported for
165
+ * the idle handler which calls metaDistill() independently of run().
177
166
  */
178
167
  export declare function metaDistill(input: {
179
168
  llm: LLMClient;
@@ -1 +1 @@
1
- {"version":3,"file":"distillation.d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AAM,EACjB,eAAe,UAAQ,GACtB,YAAY,EAAE,CAuBhB;AAyCD,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CASxE;AAkGD,wBAAsB,GAAG,CAAC,KAAK,EAAE;IAC/B,GAAG,EAAE,SAAS,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC/B,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAEjD;AA8OD;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE;IACvC,GAAG,EAAE,SAAS,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC/B,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAErC;AAuHD;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAkDxC"}
@@ -1,41 +1,26 @@
1
1
  /**
2
- * Vendored bge-small registration for the standalone Lore binary.
2
+ * Vendored model registration for the standalone Lore binary.
3
3
  *
4
- * The Bun-compiled `lore` binary uses `bun build --compile` to bundle
5
- * `fastembed` + `onnxruntime-node` + `@anush008/tokenizers-<platform>`
6
- * directly into the executable including the platform-specific
7
- * `.node` addons which Bun embeds and dlopens from `$bunfs` at runtime.
4
+ * The Bun-compiled `lore` binary bundles `@huggingface/transformers`
5
+ * (which includes ONNX Runtime) into the executable. The model weights
6
+ * and tokenizer files (nomic-embed-text-v1.5, INT8 quantized) are
7
+ * embedded as Bun assets and extracted to a cache dir on first run.
8
8
  *
9
- * Two pieces don't fit into Bun's automatic bundling and need our help:
10
- *
11
- * 1. **Side-load shared libraries**. `onnxruntime_binding.node` does a
12
- * runtime `dlopen("libonnxruntime.so.1")` (or the .dylib / .dll
13
- * equivalent) for the actual ONNX Runtime computation library. Bun
14
- * doesn't follow this kind of dependency. The binary's wrapper
15
- * pre-loads these libs via `bun:ffi` *before* fastembed evaluates,
16
- * so when the addon's dlopen fires it finds the cached handle.
17
- *
18
- * 2. **Model weights + tokenizer**. fastembed downloads from the HF
19
- * Hub on first use; we want zero network on first run. The wrapper
20
- * embeds the bge-small INT8 files as Bun assets, writes them to a
21
- * real disk dir on first run, and sets `globalThis.__LORE_VENDOR_MODEL__`
22
- * to that path. This module exposes that registration to the
23
- * LocalProvider so it can hand the path to fastembed's CUSTOM-mode
24
- * init (`modelAbsoluteDirPath` + `modelName`).
9
+ * The binary's wrapper sets `globalThis.__LORE_VENDOR_MODEL__` to the
10
+ * extraction path. This module exposes that registration to the
11
+ * `LocalProvider` so it can configure the transformers.js `env` to
12
+ * load from the local path instead of downloading from HuggingFace Hub.
25
13
  *
26
14
  * In npm-mode usage from `@loreai/opencode` / `@loreai/pi` the global
27
- * is unset and `vendorModelInfo()` returns `null`, so the LocalProvider
28
- * falls through to fastembed's default Qdrant repo + cache.
15
+ * is unset and `vendorModelInfo()` returns `null`, so transformers.js
16
+ * downloads the model from HF Hub on first use and caches it locally.
29
17
  */
30
18
  /** What the binary wrapper writes to globalThis after extracting model files. */
31
19
  export interface VendorRegistration {
32
- /** Absolute path to the dir containing the bge-small files
33
- * (config.json, tokenizer.json, model_quantized.onnx, …). Pass to
34
- * fastembed as `modelAbsoluteDirPath` in CUSTOM init. */
35
- modelAbsoluteDirPath: string;
36
- /** Filename of the ONNX weights inside that dir. Pass to fastembed
37
- * as `modelName` in CUSTOM init. */
38
- modelName: string;
20
+ /** Absolute path to the dir containing the model files in HF layout
21
+ * (config.json, tokenizer.json, onnx/model_quantized.onnx, …).
22
+ * Passed to transformers.js as `env.localModelPath`. */
23
+ localModelPath: string;
39
24
  /** Target identifier the binary was built for, e.g. "linux-x64".
40
25
  * Diagnostic only — the runtime doesn't branch on it. */
41
26
  target: string;
@@ -46,17 +31,16 @@ export interface VendorRegistration {
46
31
  * both binary-mode and npm-mode code paths without spinning up a real
47
32
  * compiled binary. */
48
33
  export declare function _setVendorRegistration(reg: VendorRegistration | null): void;
49
- /** Subset of the registration fastembed needs. Stripped of the
50
- * diagnostic fields so the LocalProvider has exactly what it should
51
- * hand to `FlagEmbedding.init`. */
34
+ /** Subset of the registration the LocalProvider needs. */
52
35
  export interface VendorModelInfo {
53
- modelAbsoluteDirPath: string;
54
- modelName: string;
36
+ /** Absolute path to the dir containing the model in HF layout.
37
+ * Set as `env.localModelPath` in the worker thread. */
38
+ localModelPath: string;
55
39
  }
56
40
  /**
57
- * Resolve the bundled-model arguments for fastembed CUSTOM init. Returns
58
- * `null` when no vendor is registered (npm-mode), so the caller can fall
59
- * through to fastembed's default cacheDir/HF Hub flow.
41
+ * Resolve the vendored model path for transformers.js local loading.
42
+ * Returns `null` when no vendor is registered (npm-mode), so the caller
43
+ * falls through to transformers.js's default HF Hub download + cache.
60
44
  */
61
45
  export declare function vendorModelInfo(): VendorModelInfo | null;
62
46
  /** True iff this process is running inside a vendored Lore binary. */
@@ -1 +1 @@
1
- {"version":3,"file":"embedding-vendor.d.ts","sourceRoot":"","sources":["../../src/embedding-vendor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAMH,iFAAiF;AACjF,M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AAgB,kBAAkB,IAAI,kBAAkB,GAAG,IAAI,CAE9D"}
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * Shared message types for the embedding worker thread.
3
3
  *
4
- * The embedding worker (`embedding-worker.ts`) runs fastembed/ONNX inference
5
- * in a separate `node:worker_threads` Worker so the main thread's event loop
6
- * stays free during inference. This file defines the message protocol between
7
- * the main thread (`LocalProvider` in `embedding.ts`) and the worker.
4
+ * The embedding worker (`embedding-worker.ts`) runs ONNX inference via
5
+ * `@huggingface/transformers` in a separate `node:worker_threads` Worker
6
+ * so the main thread's event loop stays free during inference. This file
7
+ * defines the message protocol between the main thread (`LocalProvider`
8
+ * in `embedding.ts`) and the worker.
8
9
  *
9
10
  * Imported by both sides — keep this file free of runtime dependencies.
10
11
  */
@@ -13,7 +14,7 @@ export interface EmbedRequest {
13
14
  type: "embed";
14
15
  /** Monotonic request ID for correlating responses. */
15
16
  id: number;
16
- /** Texts to embed. */
17
+ /** Texts to embed (already prefixed with task instruction by the caller). */
17
18
  texts: string[];
18
19
  /** "document" for storage, "query" for search. */
19
20
  inputType: "document" | "query";
@@ -52,15 +53,19 @@ export interface InitError {
52
53
  export type WorkerOutbound = EmbedResult | EmbedError | InitError;
53
54
  /** Passed to the worker via `workerData` at construction time. */
54
55
  export interface WorkerInitData {
55
- /** fastembed model name, e.g. "BGESmallENV15". */
56
- modelName: string;
56
+ /** HuggingFace model ID, e.g. "nomic-ai/nomic-embed-text-v1.5". */
57
+ modelId: string;
58
+ /** Target embedding dimensions. For Nomic v1.5 with Matryoshka,
59
+ * this controls how many leading dims to keep (64–768). */
60
+ dimensions: number;
57
61
  /** Vendored model info for binary mode, or null for npm mode.
58
- * Mirrors the `globalThis.__LORE_VENDOR_MODEL__` registration which
59
- * only exists on the main thread passed explicitly so the worker
60
- * can hand it to `FlagEmbedding.init()`. */
62
+ * In binary mode, model files are pre-extracted to a local dir
63
+ * and we point transformers.js at that path instead of downloading
64
+ * from HuggingFace Hub. */
61
65
  vendorModel: {
62
- modelAbsoluteDirPath: string;
63
- modelName: string;
66
+ /** Absolute path to the dir containing model files
67
+ * (config.json, tokenizer.json, onnx/model_quantized.onnx, …). */
68
+ localModelPath: string;
64
69
  } | null;
65
70
  }
66
71
  //# sourceMappingURL=embedding-worker-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"embedding-worker-types.d.ts","sourceRoot":"","sources":["../../src/embedding-worker-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,kCAAkC;AAClC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,sDAAsD;IACtD,EAAE,EAAE,MAAM,CAAC;IACX,sBAAsB;IACtB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,kDAAkD;IAClD,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC;IAChC,qEAAqE;IACrE,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC;CAC7B;AAED,sCAAsC;AACtC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,eAAe,CAAC;AAM3D,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,8BAA8B;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX;gEAC4D;IAC5D,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,wDAAwD;AACxD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,8BAA8B;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;4DAC4D;AAC5D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,YAAY,CAAC;IACnB,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAMlE,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC7B,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB;;;iDAG6C;IAC7C,WAAW,EAAE;QAAE,oBAAoB,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CACzE"}
1
+ {"version":3,"file":"embedding-worker-types.d.ts","sourceRoot":"","sources":["../../src/embedding-worker-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,kCAAkC;AAClC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,sDAAsD;IACtD,EAAE,EAAE,MAAM,CAAC;IACX,6EAA6E;IAC7E,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,kDAAkD;IAClD,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC;IAChC,qEAAqE;IACrE,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC;CAC7B;AAED,sCAAsC;AACtC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,eAAe,CAAC;AAM3D,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,8BAA8B;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX;gEAC4D;IAC5D,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,wDAAwD;AACxD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,8BAA8B;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;4DAC4D;AAC5D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,YAAY,CAAC;IACnB,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAMlE,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC7B,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;IAChB;gEAC4D;IAC5D,UAAU,EAAE,MAAM,CAAC;IACnB;;;gCAG4B;IAC5B,WAAW,EAAE;QACX;2EACmE;QACnE,cAAc,EAAE,MAAM,CAAC;KACxB,GAAG,IAAI,CAAC;CACV"}
@@ -1,8 +1,9 @@
1
1
  /**
2
- * Embedding worker thread — runs fastembed/ONNX inference off the main thread.
2
+ * Embedding worker thread — runs ONNX inference via @huggingface/transformers
3
+ * off the main thread.
3
4
  *
4
5
  * This file is the entry point for a `node:worker_threads` Worker spawned by
5
- * `LocalProvider` in `embedding.ts`. It owns the `FlagEmbedding` ONNX model
6
+ * `LocalProvider` in `embedding.ts`. It owns the transformers.js pipeline
6
7
  * and processes embed requests sequentially from a priority queue. Moving
7
8
  * inference here keeps the main thread's event loop free — HTTP requests,
8
9
  * SSE streams, and session APIs are no longer blocked during embedding.
@@ -10,6 +11,12 @@
10
11
  * Communication uses `parentPort` message passing with structured clone.
11
12
  * Float32Array vectors are sent back directly (Bun preserves identity).
12
13
  *
14
+ * The worker applies Nomic's recommended post-processing:
15
+ * 1. Mean pooling (via pipeline option)
16
+ * 2. Layer normalization
17
+ * 3. Matryoshka dimension truncation (if dimensions < full 768)
18
+ * 4. L2 normalization
19
+ *
13
20
  * @see embedding-worker-types.ts for the message protocol.
14
21
  */
15
22
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"embedding-worker.d.ts","sourceRoot":"","sources":["../../src/embedding-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
1
+ {"version":3,"file":"embedding-worker.d.ts","sourceRoot":"","sources":["../../src/embedding-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG"}