@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
@@ -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,GAAG,IAAI,CAYxE;AA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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.ts","sourceRoot":"","sources":["../../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,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,MAAM,WAAW,kBAAkB;IACj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AAkB,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"}
@@ -1,33 +1,35 @@
1
1
  /**
2
2
  * Embedding integration for vector search.
3
3
  *
4
- * Supports multiple embedding providers (Voyage AI, OpenAI) behind a common
5
- * interface. Provides embedding generation, pure-JS cosine similarity, and
6
- * vector search over the knowledge and distillation tables. All operations
7
- * are gated behind `search.embeddings.enabled` config + the provider's API
8
- * key env var — falls back silently to FTS-only when unavailable.
4
+ * Supports multiple embedding providers behind a common interface:
5
+ * - "local" (default): @huggingface/transformers + nomic-embed-text-v1.5
6
+ * (768 dims, Matryoshka-capable). Runs ONNX inference in a worker thread.
7
+ * - "voyage": Voyage AI API (voyage-code-3, 1024 dims)
8
+ * - "openai": OpenAI API (text-embedding-3-small, 1536 dims)
9
+ *
10
+ * Provides embedding generation, pure-JS cosine similarity, and vector search
11
+ * over the knowledge and distillation tables. All operations are gated behind
12
+ * `search.embeddings.enabled` config + the provider's API key env var — falls
13
+ * back silently to FTS-only when unavailable.
9
14
  */
10
15
  export interface EmbeddingProvider {
11
16
  embed(texts: string[], inputType: "document" | "query"): Promise<Float32Array[]>;
12
17
  readonly maxBatchSize: number;
13
18
  }
14
19
  /**
15
- * Thrown when `LocalProvider` is requested but `fastembed` cannot be loaded.
16
- * `fastembed` is an optionalDependency of `@loreai/core`: if its postinstall
17
- * fails (e.g. CUDA 13 hits the upstream `onnxruntime-node` bug see #185),
18
- * the package install still succeeds but local embeddings are disabled.
19
- * Callers in `recall.ts` / `ltm.ts` / `distillation.ts` already gate on
20
- * `isAvailable()`, which flips to `false` after this error fires once.
20
+ * Thrown when `LocalProvider` cannot initialize (e.g. ONNX runtime fails
21
+ * to load). Callers in `recall.ts` / `ltm.ts` / `distillation.ts` gate
22
+ * on `isAvailable()`, which flips to `false` after this error fires once.
21
23
  */
22
24
  export declare class LocalProviderUnavailableError extends Error {
23
25
  constructor(cause?: unknown);
24
26
  }
25
- /** For tests: reset the fastembed probe cache. */
26
- export declare function _resetFastembedProbe(): void;
27
- /** For tests: simulate fastembed being unresolvable, without mocking the
28
- * dynamic import. After this call, `tryLoadFastembed()` short-circuits to
29
- * `null` and `isAvailable()` returns false for the local provider. */
30
- export declare function _markFastembedUnavailable(): void;
27
+ /** For tests: reset the local provider probe state. */
28
+ export declare function _resetLocalProviderProbe(): void;
29
+ /** For tests: simulate the local provider being unavailable, without
30
+ * actually spawning a worker. After this call, `isAvailable()` returns
31
+ * false for the local provider. */
32
+ export declare function _markLocalProviderUnavailable(): void;
31
33
  /** Reset cached provider — called when config changes.
32
34
  * Shuts down the worker thread if the current provider is a LocalProvider.
33
35
  * Returns a promise that resolves once any worker has fully exited.
@@ -50,7 +52,7 @@ export declare function _saveAndClearProvider(): unknown;
50
52
  /** Restore a provider previously saved by `_saveAndClearProvider()`. Any
51
53
  * provider created between save and restore is discarded (callers must
52
54
  * ensure it's not a LocalProvider with a live worker — those suites only
53
- * use `_markFastembedUnavailable()` so no worker is spawned). */
55
+ * use `_markLocalProviderUnavailable()` so no worker is spawned). */
54
56
  export declare function _restoreProvider(token: unknown): void;
55
57
  /**
56
58
  * Build a remote `EmbeddingProvider` from whichever API key is in env.
@@ -69,14 +71,14 @@ export declare function pickRemoteFallback(): {
69
71
  * Active when the configured provider's API key is set, unless explicitly
70
72
  * disabled via `search.embeddings.enabled: false` in .lore.json.
71
73
  *
72
- * For the `local` provider, also returns false once we've discovered the
73
- * optional `fastembed` peer is missing — callers (recall, ltm, distillation)
74
- * use this gate to skip embedding work and fall back to FTS-only search. */
74
+ * For the `local` provider, also returns false once the worker has reported
75
+ * an init failure — callers (recall, ltm, distillation) use this gate to
76
+ * skip embedding work and fall back to FTS-only search. */
75
77
  export declare function isAvailable(): boolean;
76
78
  /**
77
79
  * Generate embeddings for the given texts using the configured provider.
78
80
  *
79
- * If the configured provider is `local` and `fastembed` turns out to be
81
+ * If the configured provider is `local` and the local provider turns out to be
80
82
  * unavailable at runtime (failed install, vendor extraction blocked, etc.),
81
83
  * automatically swap to a remote provider when `VOYAGE_API_KEY` or
82
84
  * `OPENAI_API_KEY` is set in env. The swap is permanent for the rest of
@@ -108,14 +110,24 @@ type VectorHit = {
108
110
  * Search all knowledge entries with embeddings by cosine similarity.
109
111
  * Returns top-k entries sorted by similarity descending.
110
112
  * Pure brute-force — fine for <100 entries (microseconds).
113
+ *
114
+ * @param excludeCategories Optional category names to exclude from results.
115
+ * Useful when preferences are injected in a separate system block and
116
+ * shouldn't compete for vector search slots with context-bound entries.
111
117
  */
112
- export declare function vectorSearch(queryEmbedding: Float32Array, limit?: number): VectorHit[];
118
+ export declare function vectorSearch(queryEmbedding: Float32Array, limit?: number, excludeCategories?: string[]): VectorHit[];
113
119
  /**
114
120
  * Search non-archived distillations with embeddings by cosine similarity.
115
121
  * Returns top-k entries sorted by similarity descending.
116
122
  * Pure brute-force — fine for ~50 entries.
117
123
  */
118
124
  export declare function vectorSearchDistillations(queryEmbedding: Float32Array, limit?: number): VectorHit[];
125
+ export type DistillationVectorHit = {
126
+ id: string;
127
+ session_id: string;
128
+ similarity: number;
129
+ };
130
+ export declare function vectorSearchAllDistillations(queryEmbedding: Float32Array, projectId: string, limit?: number): DistillationVectorHit[];
119
131
  /**
120
132
  * Embed a knowledge entry and store the result in the DB.
121
133
  * Fire-and-forget — errors are logged, never thrown.
@@ -1 +1 @@
1
- {"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../src/embedding.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAqBH,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IACjF,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAgHD;;;;;;;GAOG;AACH,qBAAa,6BAA8B,SAAQ,KAAK;gBAC1C,KAAK,CAAC,EAAE,OAAO;CAS5B;AASD,kDAAkD;AAClD,wBAAgB,oBAAoB,IAAI,IAAI,CAK3C;AAED;;uEAEuE;AACvE,wBAAgB,yBAAyB,IAAI,IAAI,CAKhD;AAoYD;;;wEAGwE;AACxE,wBAAgB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAQ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B,CACvC,cAAc,EAAE,YAAY,EAC5B,KAAK,SAAK,GACT,SAAS,EAAE,CAgBb;AAMD,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAiBF,wBAAgB,4BAA4B,CAC1C,cAAc,EAAE,YAAY,EAC5B,SAAS,EAAE,MAAM,EACjB,KAAK,SAAK,GACT,qBAAqB,EAAE,CAgBzB;AAMD;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GACd,IAAI,CAWN;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,MAAM,EACV,YAAY,EAAE,MAAM,GACnB,IAAI,CAUN;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,GACd,IAAI,CAcN;AAMD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,YAAY,EAC5B,SAAS,EAAE,MAAM,EACjB,KAAK,SAAK,EACV,SAAS,CAAC,EAAE,MAAM,GACjB,SAAS,EAAE,CAmBb;AAkBD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAwC3C;AAgBD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAsExD;AAsDD;;;;;;GAMG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CA4C1D;AAMD;;;;GAIG;AACH,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,MAAM,CAAC,CAsDtE"}
@@ -54,8 +54,15 @@ type DistillationSnapshot = {
54
54
  *
55
55
  * Set `thresholdMs <= 0` to disable. Returns true if a reset fired so the
56
56
  * caller can log/observe.
57
+ *
58
+ * @param skipCompact When true, perform all idle-resume housekeeping
59
+ * (clear caches, set cameOutOfIdle) but do NOT set postIdleCompact.
60
+ * Used when the caller knows the upstream prompt cache is still warm
61
+ * (e.g. cache warmer recently refreshed it) — compacting would produce
62
+ * a different prompt body that doesn't match the warmed prefix, causing
63
+ * a cache bust and wasting the warming cost.
57
64
  */
58
- export declare function onIdleResume(sessionID: string, thresholdMs: number, now?: number): {
65
+ export declare function onIdleResume(sessionID: string, thresholdMs: number, now?: number, skipCompact?: boolean): {
59
66
  triggered: false;
60
67
  } | {
61
68
  triggered: true;
@@ -141,6 +148,14 @@ export declare function inspectSessionState(sessionID: string): {
141
148
  * tests don't need to seed it via a transform() call.
142
149
  */
143
150
  export declare function setLastTurnAtForTest(sessionID: string, ms: number): void;
151
+ /**
152
+ * Persist gradient calibration state to the session_state table.
153
+ *
154
+ * Designed to be called periodically (e.g. every 30s from the idle scheduler
155
+ * tick) rather than on every mutation, to avoid write amplification on the
156
+ * hot path. Max data loss on crash is one tick interval (~30s).
157
+ */
158
+ export declare function saveGradientState(sessionID: string): void;
144
159
  type Distillation = {
145
160
  id: string;
146
161
  observations: string;
@@ -199,6 +214,7 @@ export type TransformResult = {
199
214
  usable: number;
200
215
  distilledBudget: number;
201
216
  rawBudget: number;
217
+ refreshLtm: boolean;
202
218
  };
203
219
  export declare function needsUrgentDistillation(sessionID: string): boolean;
204
220
  export declare function transform(input: {
@@ -1 +1 @@
1
- {"version":3,"file":"gradient.d.ts","sourceRoot":"","sources":["../../src/gradient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,oBAAoB,EAAqE,MAAM,SAAS,CAAC;AAQ9I,KAAK,gBAAgB,GAAG,oBAAoB,CAAC;AA0D7C,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,MAAM,EACtB,sBAAsB,EAAE,MAAM,GAC7B,MAAM,CAGR;AAED;;0CAE0C;AAC1C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE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CA+FpB;AAiTD,wBAAgB,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,QAOlD;AAGD,wBAAgB,yBAAyB,CAAC,SAAS,CAAC,EAAE,MAAM,QAO3D;AAgCD,wBAAgB,mBAAmB,CAAC,SAAS,CAAC,EAAE,MAAM,QAOrD;AAuHD,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAqB5C,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,KAAK,EAAE,WAAW,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IAEpB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAIlB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAMF,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAIlE;AAgVD,wBAAgB,SAAS,CAAC,KAAK,EAAE;IAC/B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,eAAe,CAwClB;AAGD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAErE"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Detection orchestrator — scans all registered providers for conversation
3
+ * history matching a given project path.
4
+ */
5
+ import type { DetectionResult } from "./types";
6
+ /**
7
+ * Scan all registered providers for conversation history matching the
8
+ * given project path.
9
+ *
10
+ * @returns Results from all providers that found data, sorted by
11
+ * total messages descending (richest source first).
12
+ */
13
+ export declare function detectAll(projectPath: string): DetectionResult[];
14
+ //# sourceMappingURL=detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../src/import/detect.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,eAAe,EAAE,CAsBhE"}
@@ -0,0 +1,43 @@
1
+ import type { LLMClient } from "../types";
2
+ import type { ConversationChunk } from "./types";
3
+ export type ExtractionProgress = {
4
+ /** Current chunk being processed (1-based) */
5
+ current: number;
6
+ /** Total chunks to process */
7
+ total: number;
8
+ /** Knowledge entries created so far */
9
+ created: number;
10
+ /** Knowledge entries updated (dedup hit) so far */
11
+ updated: number;
12
+ };
13
+ export type ExtractionResult = {
14
+ /** Total knowledge entries created */
15
+ created: number;
16
+ /** Total entries that hit dedup (updated existing) */
17
+ updated: number;
18
+ /** Total entries deleted */
19
+ deleted: number;
20
+ /** Chunks processed successfully */
21
+ chunksProcessed: number;
22
+ /** Chunks that failed (LLM error) */
23
+ chunksFailed: number;
24
+ };
25
+ /**
26
+ * Extract knowledge entries from conversation chunks via the curator LLM.
27
+ *
28
+ * Processes chunks sequentially (not parallel) to avoid rate limits
29
+ * and to let later chunks see entries created by earlier chunks
30
+ * (better dedup via the existing entries list in the prompt).
31
+ */
32
+ export declare function extractKnowledge(input: {
33
+ llm: LLMClient;
34
+ projectPath: string;
35
+ chunks: ConversationChunk[];
36
+ sessionID?: string;
37
+ model?: {
38
+ providerID: string;
39
+ modelID: string;
40
+ };
41
+ onProgress?: (progress: ExtractionProgress) => void;
42
+ }): Promise<ExtractionResult>;
43
+ //# sourceMappingURL=extract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../../src/import/extract.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAoBjD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE;IAC5C,GAAG,EAAE,SAAS,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACrD,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAmE5B"}