@loreai/core 0.16.0 → 0.17.1

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 (155) hide show
  1. package/README.md +11 -0
  2. package/dist/bun/agents-file.d.ts +13 -1
  3. package/dist/bun/agents-file.d.ts.map +1 -1
  4. package/dist/bun/config.d.ts +20 -1
  5. package/dist/bun/config.d.ts.map +1 -1
  6. package/dist/bun/data.d.ts +174 -0
  7. package/dist/bun/data.d.ts.map +1 -0
  8. package/dist/bun/db.d.ts +65 -0
  9. package/dist/bun/db.d.ts.map +1 -1
  10. package/dist/bun/distillation.d.ts +49 -6
  11. package/dist/bun/distillation.d.ts.map +1 -1
  12. package/dist/bun/embedding-vendor.d.ts +66 -0
  13. package/dist/bun/embedding-vendor.d.ts.map +1 -0
  14. package/dist/bun/embedding-worker-types.d.ts +66 -0
  15. package/dist/bun/embedding-worker-types.d.ts.map +1 -0
  16. package/dist/bun/embedding-worker.d.ts +16 -0
  17. package/dist/bun/embedding-worker.d.ts.map +1 -0
  18. package/dist/bun/embedding-worker.js +100 -0
  19. package/dist/bun/embedding-worker.js.map +7 -0
  20. package/dist/bun/embedding.d.ts +91 -8
  21. package/dist/bun/embedding.d.ts.map +1 -1
  22. package/dist/bun/git.d.ts +47 -0
  23. package/dist/bun/git.d.ts.map +1 -0
  24. package/dist/bun/gradient.d.ts +19 -1
  25. package/dist/bun/gradient.d.ts.map +1 -1
  26. package/dist/bun/index.d.ts +9 -6
  27. package/dist/bun/index.d.ts.map +1 -1
  28. package/dist/bun/index.js +13029 -10885
  29. package/dist/bun/index.js.map +4 -4
  30. package/dist/bun/lat-reader.d.ts +1 -1
  31. package/dist/bun/lat-reader.d.ts.map +1 -1
  32. package/dist/bun/ltm.d.ts.map +1 -1
  33. package/dist/bun/markdown.d.ts +11 -0
  34. package/dist/bun/markdown.d.ts.map +1 -1
  35. package/dist/bun/prompt.d.ts +1 -1
  36. package/dist/bun/prompt.d.ts.map +1 -1
  37. package/dist/bun/recall.d.ts +53 -0
  38. package/dist/bun/recall.d.ts.map +1 -1
  39. package/dist/bun/search.d.ts +29 -0
  40. package/dist/bun/search.d.ts.map +1 -1
  41. package/dist/bun/temporal.d.ts +2 -0
  42. package/dist/bun/temporal.d.ts.map +1 -1
  43. package/dist/bun/types.d.ts +15 -0
  44. package/dist/bun/types.d.ts.map +1 -1
  45. package/dist/bun/worker-model.d.ts +12 -9
  46. package/dist/bun/worker-model.d.ts.map +1 -1
  47. package/dist/node/agents-file.d.ts +13 -1
  48. package/dist/node/agents-file.d.ts.map +1 -1
  49. package/dist/node/config.d.ts +20 -1
  50. package/dist/node/config.d.ts.map +1 -1
  51. package/dist/node/data.d.ts +174 -0
  52. package/dist/node/data.d.ts.map +1 -0
  53. package/dist/node/db.d.ts +65 -0
  54. package/dist/node/db.d.ts.map +1 -1
  55. package/dist/node/distillation.d.ts +49 -6
  56. package/dist/node/distillation.d.ts.map +1 -1
  57. package/dist/node/embedding-vendor.d.ts +66 -0
  58. package/dist/node/embedding-vendor.d.ts.map +1 -0
  59. package/dist/node/embedding-worker-types.d.ts +66 -0
  60. package/dist/node/embedding-worker-types.d.ts.map +1 -0
  61. package/dist/node/embedding-worker.d.ts +16 -0
  62. package/dist/node/embedding-worker.d.ts.map +1 -0
  63. package/dist/node/embedding-worker.js +100 -0
  64. package/dist/node/embedding-worker.js.map +7 -0
  65. package/dist/node/embedding.d.ts +91 -8
  66. package/dist/node/embedding.d.ts.map +1 -1
  67. package/dist/node/git.d.ts +47 -0
  68. package/dist/node/git.d.ts.map +1 -0
  69. package/dist/node/gradient.d.ts +19 -1
  70. package/dist/node/gradient.d.ts.map +1 -1
  71. package/dist/node/index.d.ts +9 -6
  72. package/dist/node/index.d.ts.map +1 -1
  73. package/dist/node/index.js +13029 -10885
  74. package/dist/node/index.js.map +4 -4
  75. package/dist/node/lat-reader.d.ts +1 -1
  76. package/dist/node/lat-reader.d.ts.map +1 -1
  77. package/dist/node/ltm.d.ts.map +1 -1
  78. package/dist/node/markdown.d.ts +11 -0
  79. package/dist/node/markdown.d.ts.map +1 -1
  80. package/dist/node/prompt.d.ts +1 -1
  81. package/dist/node/prompt.d.ts.map +1 -1
  82. package/dist/node/recall.d.ts +53 -0
  83. package/dist/node/recall.d.ts.map +1 -1
  84. package/dist/node/search.d.ts +29 -0
  85. package/dist/node/search.d.ts.map +1 -1
  86. package/dist/node/temporal.d.ts +2 -0
  87. package/dist/node/temporal.d.ts.map +1 -1
  88. package/dist/node/types.d.ts +15 -0
  89. package/dist/node/types.d.ts.map +1 -1
  90. package/dist/node/worker-model.d.ts +12 -9
  91. package/dist/node/worker-model.d.ts.map +1 -1
  92. package/dist/types/agents-file.d.ts +13 -1
  93. package/dist/types/agents-file.d.ts.map +1 -1
  94. package/dist/types/config.d.ts +20 -1
  95. package/dist/types/config.d.ts.map +1 -1
  96. package/dist/types/data.d.ts +174 -0
  97. package/dist/types/data.d.ts.map +1 -0
  98. package/dist/types/db.d.ts +65 -0
  99. package/dist/types/db.d.ts.map +1 -1
  100. package/dist/types/distillation.d.ts +49 -6
  101. package/dist/types/distillation.d.ts.map +1 -1
  102. package/dist/types/embedding-vendor.d.ts +66 -0
  103. package/dist/types/embedding-vendor.d.ts.map +1 -0
  104. package/dist/types/embedding-worker-types.d.ts +66 -0
  105. package/dist/types/embedding-worker-types.d.ts.map +1 -0
  106. package/dist/types/embedding-worker.d.ts +16 -0
  107. package/dist/types/embedding-worker.d.ts.map +1 -0
  108. package/dist/types/embedding.d.ts +91 -8
  109. package/dist/types/embedding.d.ts.map +1 -1
  110. package/dist/types/git.d.ts +47 -0
  111. package/dist/types/git.d.ts.map +1 -0
  112. package/dist/types/gradient.d.ts +19 -1
  113. package/dist/types/gradient.d.ts.map +1 -1
  114. package/dist/types/index.d.ts +9 -6
  115. package/dist/types/index.d.ts.map +1 -1
  116. package/dist/types/lat-reader.d.ts +1 -1
  117. package/dist/types/lat-reader.d.ts.map +1 -1
  118. package/dist/types/ltm.d.ts.map +1 -1
  119. package/dist/types/markdown.d.ts +11 -0
  120. package/dist/types/markdown.d.ts.map +1 -1
  121. package/dist/types/prompt.d.ts +1 -1
  122. package/dist/types/prompt.d.ts.map +1 -1
  123. package/dist/types/recall.d.ts +53 -0
  124. package/dist/types/recall.d.ts.map +1 -1
  125. package/dist/types/search.d.ts +29 -0
  126. package/dist/types/search.d.ts.map +1 -1
  127. package/dist/types/temporal.d.ts +2 -0
  128. package/dist/types/temporal.d.ts.map +1 -1
  129. package/dist/types/types.d.ts +15 -0
  130. package/dist/types/types.d.ts.map +1 -1
  131. package/dist/types/worker-model.d.ts +12 -9
  132. package/dist/types/worker-model.d.ts.map +1 -1
  133. package/package.json +5 -2
  134. package/src/agents-file.ts +87 -4
  135. package/src/config.ts +68 -5
  136. package/src/curator.ts +2 -2
  137. package/src/data.ts +768 -0
  138. package/src/db.ts +386 -7
  139. package/src/distillation.ts +178 -35
  140. package/src/embedding-vendor.ts +102 -0
  141. package/src/embedding-worker-types.ts +82 -0
  142. package/src/embedding-worker.ts +185 -0
  143. package/src/embedding.ts +607 -61
  144. package/src/git.ts +144 -0
  145. package/src/gradient.ts +174 -17
  146. package/src/index.ts +20 -0
  147. package/src/lat-reader.ts +5 -11
  148. package/src/ltm.ts +17 -44
  149. package/src/markdown.ts +15 -0
  150. package/src/prompt.ts +1 -2
  151. package/src/recall.ts +401 -70
  152. package/src/search.ts +71 -1
  153. package/src/temporal.ts +42 -35
  154. package/src/types.ts +15 -0
  155. package/src/worker-model.ts +14 -9
@@ -1,6 +1,43 @@
1
1
  import { Database } from "#db/driver";
2
+ /**
3
+ * Extract the repository name from a normalized git remote URL.
4
+ *
5
+ * Examples:
6
+ * "github.com/BYK/LoreAI" → "LoreAI"
7
+ * "github.com/org/repo" → "repo"
8
+ * "github.com" → null (no path components)
9
+ * null → null
10
+ */
11
+ export declare function repoNameFromRemote(remote: string | null): string | null;
12
+ /** Return the resolved path of the SQLite database file. */
13
+ export declare function dbPath(): string;
2
14
  export declare function db(): Database;
15
+ /**
16
+ * Merge all data from `sourceId` project into `targetId` project.
17
+ *
18
+ * Moves knowledge, temporal messages, distillations, LAT sections, and
19
+ * path aliases from source to target. Registers the source project's path
20
+ * as an alias of the target. Deletes the source project row.
21
+ *
22
+ * Used internally during lazy git-remote backfill when two path-only
23
+ * projects are discovered to share the same git remote.
24
+ */
25
+ export declare function mergeProjectInternal(sourceId: string, targetId: string): void;
3
26
  export declare function close(): void;
27
+ /**
28
+ * Look up or create a project by filesystem path, with git-remote awareness.
29
+ *
30
+ * Resolution order:
31
+ * 1. Exact path match in `projects` table (fast path, O(1) index scan)
32
+ * 2. Path alias match in `project_path_aliases` (worktree/clone re-visits)
33
+ * 3. Git remote match — runs `git remote -v` (once per unique path, cached),
34
+ * finds an existing project with the same normalized remote URL
35
+ * 4. Create a new project row
36
+ *
37
+ * When a git-remote match is found (step 3), the new path is registered as
38
+ * an alias so subsequent calls skip the subprocess. If the matched project's
39
+ * git_remote was not yet populated (pre-v14 rows), it is backfilled lazily.
40
+ */
4
41
  export declare function ensureProject(path: string, name?: string): string;
5
42
  export declare function projectId(path: string): string | undefined;
6
43
  /** Look up a project's display name by its internal ID. */
@@ -19,6 +56,34 @@ export declare function loadForceMinLayer(sessionID: string): number;
19
56
  * (consumed) to avoid unbounded growth.
20
57
  */
21
58
  export declare function saveForceMinLayer(sessionID: string, layer: number): void;
59
+ /** Persisted cost snapshot for a session. */
60
+ export type SessionCostSnapshot = {
61
+ conversationCost: number;
62
+ workerCost: number;
63
+ conversationTurns: number;
64
+ cacheReadTokens: number;
65
+ cacheWriteTokens: number;
66
+ warmupSavings: number;
67
+ warmupHits: number;
68
+ ttlSavings: number;
69
+ ttlHits: number;
70
+ batchSavings: number;
71
+ };
72
+ /**
73
+ * Persist a session's cost snapshot. Uses INSERT OR REPLACE so it works
74
+ * whether or not a row already exists (forceMinLayer may have created one).
75
+ */
76
+ export declare function saveSessionCosts(sessionID: string, costs: SessionCostSnapshot): void;
77
+ /**
78
+ * Load persisted cost snapshot for a session. Returns null if not stored
79
+ * or if all cost columns are zero (pre-migration row from forceMinLayer only).
80
+ */
81
+ export declare function loadSessionCosts(sessionID: string): SessionCostSnapshot | null;
82
+ /**
83
+ * Load cost snapshots for all sessions that have non-zero cost data.
84
+ * Returns a map of sessionID → SessionCostSnapshot.
85
+ */
86
+ export declare function loadAllSessionCosts(): Map<string, SessionCostSnapshot>;
22
87
  /** Get a metadata value by key. Returns null if not found. */
23
88
  export declare function getMeta(key: string): string | null;
24
89
  /** 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;AAsXtC,wBAAgB,EAAE,IAAI,QAAQ,CAkC7B;AAwGD,wBAAgB,KAAK,SAKpB;AAGD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAYjE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAK1D;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;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,CAMx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AAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,IAAI,CA2BpF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI,CAiC9E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAsCtE;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"}
@@ -15,20 +15,58 @@ type TemporalMessage = temporal.TemporalMessage;
15
15
  * use as a diagnostic signal, not a hard gate.
16
16
  */
17
17
  export declare function compressionRatio(distilledTokens: number, sourceTokens: number): number;
18
+ /**
19
+ * Maximum allowed expansion for distillation output.
20
+ *
21
+ * Tiny segments can't meaningfully compress — distillation adds metadata
22
+ * (timestamps, importance markers, cross-references) that necessarily
23
+ * exceeds the source. Allow generous expansion for small segments while
24
+ * still enforcing compression on large ones.
25
+ *
26
+ * @returns Maximum allowed distilled tokens for a given source token count.
27
+ */
28
+ export declare function maxAllowedExpansion(sourceTokens: number): number;
18
29
  /**
19
30
  * Segment detection: group related messages into distillation-sized chunks.
20
31
  *
21
- * When the message count exceeds `maxSegment`, prefers splitting at the
32
+ * When the total token count exceeds `maxTokens`, prefers splitting at the
22
33
  * largest inter-message time gap (if it's ≥ 3× the median gap) to respect
23
- * natural conversation boundaries. Falls back to count-based splitting at
24
- * `maxSegment` when timestamps are uniform.
34
+ * natural conversation boundaries. Falls back to token-boundary splitting
35
+ * when timestamps are uniform.
25
36
  *
26
- * Trailing segments with < 3 messages are merged into the previous segment
27
- * to avoid tiny distillation inputs with too little context.
37
+ * Trailing segments whose token sum is below {@link MIN_SEGMENT_TOKENS}
38
+ * are merged into the previous segment to avoid tiny distillation inputs
39
+ * with too little context.
28
40
  *
29
41
  * Exported for testing; `run()` is the production caller.
30
42
  */
31
- export declare function detectSegments(messages: TemporalMessage[], maxSegment: number): TemporalMessage[][];
43
+ export declare function detectSegments(messages: TemporalMessage[], maxTokens: number): TemporalMessage[][];
44
+ /**
45
+ * Compute the max_tokens budget for a worker LLM call.
46
+ *
47
+ * @param inputTokens Estimated source token count
48
+ * @param ratio Compression ratio (0.0–1.0) — output ≈ ratio × input
49
+ * @param floor Minimum output tokens
50
+ * @param cap Maximum output tokens
51
+ */
52
+ export declare function workerTokenBudget(inputTokens: number, ratio: number, floor: number, cap: number): number;
53
+ /**
54
+ * Compute the max_tokens budget for gen-0 distillation of raw messages.
55
+ *
56
+ * Uses a √N-based formula (8 × √N) instead of a linear ratio so that the
57
+ * budget grows sub-linearly with input size. This naturally constrains the
58
+ * LLM to produce output at ~R ≈ 2–4 (the square-root boundary) and avoids
59
+ * expansion on small segments where a linear 0.25 ratio + 1024 floor gave
60
+ * the model far too much room.
61
+ *
62
+ * The multiplier (8) gives ~4× headroom above the R=2.0 target, accounting
63
+ * for the detailed observation format (emoji markers, timestamps, entity
64
+ * tags, exact numbers) required by the distillation prompt.
65
+ *
66
+ * @param sourceTokens Estimated source token count from raw messages
67
+ * @returns Token budget clamped to [256, 4096]
68
+ */
69
+ export declare function distillTokenBudget(sourceTokens: number): number;
32
70
  /**
33
71
  * Truncate tool outputs within a `TemporalMessage.content` string (produced
34
72
  * by `temporal.partsToText`). Plain text and `[reasoning]` chunks pass
@@ -100,6 +138,7 @@ export type Distillation = {
100
138
  * rare callers that explicitly want all rows.
101
139
  */
102
140
  export declare function loadForSession(projectPath: string, sessionID: string, includeArchived?: boolean): Distillation[];
141
+ export declare function gen0Count(projectPath: string, sessionID: string): number;
103
142
  export declare function run(input: {
104
143
  llm: LLMClient;
105
144
  projectPath: string;
@@ -121,6 +160,9 @@ export declare function run(input: {
121
160
  * where the caller is blocking on the result. Background/idle distillation
122
161
  * should leave this false to benefit from batch API 50% cost savings. */
123
162
  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
+ callType?: "batch" | "direct";
124
166
  }): Promise<{
125
167
  rounds: number;
126
168
  distilled: number;
@@ -142,6 +184,7 @@ export declare function metaDistill(input: {
142
184
  modelID: string;
143
185
  };
144
186
  urgent?: boolean;
187
+ callType?: "batch" | "direct";
145
188
  }): Promise<DistillationResult | null>;
146
189
  /**
147
190
  * Backfill `r_compression` and `c_norm` for distillations that were created
@@ -1 +1 @@
1
- {"version":3,"file":"distillation.d.ts","sourceRoot":"","sources":["../../src/distillation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AAavC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,KAAK,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC;AAEhD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,GACnB,MAAM,CAGR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,eAAe,EAAE,EAC3B,UAAU,EAAE,MAAM,GACjB,eAAe,EAAE,EAAE,CAGrB;AAwGD;;;;;;;;;;;;GAYG;AACH,wBAAgB,4B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G;AACH,wBAAgB,eAAe,IAAI,MAAM,CAkDxC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Vendored bge-small registration for the standalone Lore binary.
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.
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`).
25
+ *
26
+ * 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.
29
+ */
30
+ /** What the binary wrapper writes to globalThis after extracting model files. */
31
+ 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;
39
+ /** Target identifier the binary was built for, e.g. "linux-x64".
40
+ * Diagnostic only — the runtime doesn't branch on it. */
41
+ target: string;
42
+ /** Lore CLI version that produced the binary. Diagnostic only. */
43
+ version: string;
44
+ }
45
+ /** Test-only: programmatically set/clear the registration to exercise
46
+ * both binary-mode and npm-mode code paths without spinning up a real
47
+ * compiled binary. */
48
+ 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`. */
52
+ export interface VendorModelInfo {
53
+ modelAbsoluteDirPath: string;
54
+ modelName: string;
55
+ }
56
+ /**
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.
60
+ */
61
+ export declare function vendorModelInfo(): VendorModelInfo | null;
62
+ /** True iff this process is running inside a vendored Lore binary. */
63
+ export declare function isVendoredBinary(): boolean;
64
+ /** The full registration, for diagnostics (`lore --print-vendor-info`). */
65
+ export declare function vendorRegistration(): VendorRegistration | null;
66
+ //# sourceMappingURL=embedding-vendor.d.ts.map
@@ -0,0 +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;IACjC;;8DAE0D;IAC1D,oBAAoB,EAAE,MAAM,CAAC;IAC7B;yCACqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB;8DAC0D;IAC1D,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;CACjB;AAUD;;uBAEuB;AACvB,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,kBAAkB,GAAG,IAAI,GAAG,IAAI,CAI3E;AAMD;;oCAEoC;AACpC,MAAM,WAAW,eAAe;IAC9B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,eAAe,GAAG,IAAI,CAOxD;AAED,sEAAsE;AACtE,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED,2EAA2E;AAC3E,wBAAgB,kBAAkB,IAAI,kBAAkB,GAAG,IAAI,CAE9D"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Shared message types for the embedding worker thread.
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.
8
+ *
9
+ * Imported by both sides — keep this file free of runtime dependencies.
10
+ */
11
+ /** Request an embedding batch. */
12
+ export interface EmbedRequest {
13
+ type: "embed";
14
+ /** Monotonic request ID for correlating responses. */
15
+ id: number;
16
+ /** Texts to embed. */
17
+ texts: string[];
18
+ /** "document" for storage, "query" for search. */
19
+ inputType: "document" | "query";
20
+ /** "high" = recall queries (jump the queue), "normal" = backfill. */
21
+ priority: "high" | "normal";
22
+ }
23
+ /** Ask the worker to exit cleanly. */
24
+ export interface ShutdownRequest {
25
+ type: "shutdown";
26
+ }
27
+ export type WorkerInbound = EmbedRequest | ShutdownRequest;
28
+ /** Embedding result — vectors are Float32Array[], sent via structured clone. */
29
+ export interface EmbedResult {
30
+ type: "result";
31
+ /** Matches the request ID. */
32
+ id: number;
33
+ /** One Float32Array per input text. Sent via structured clone
34
+ * (Bun preserves Float32Array identity across threads). */
35
+ vectors: Float32Array[];
36
+ }
37
+ /** A single embed request failed (ONNX error, etc.). */
38
+ export interface EmbedError {
39
+ type: "error";
40
+ /** Matches the request ID. */
41
+ id: number;
42
+ /** Human-readable error message. */
43
+ error: string;
44
+ }
45
+ /** Model initialization failed inside the worker. All pending and future
46
+ * requests should be rejected — the worker is unusable. */
47
+ export interface InitError {
48
+ type: "init-error";
49
+ /** Human-readable error message. */
50
+ error: string;
51
+ }
52
+ export type WorkerOutbound = EmbedResult | EmbedError | InitError;
53
+ /** Passed to the worker via `workerData` at construction time. */
54
+ export interface WorkerInitData {
55
+ /** fastembed model name, e.g. "BGESmallENV15". */
56
+ modelName: string;
57
+ /** 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()`. */
61
+ vendorModel: {
62
+ modelAbsoluteDirPath: string;
63
+ modelName: string;
64
+ } | null;
65
+ }
66
+ //# sourceMappingURL=embedding-worker-types.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Embedding worker thread — runs fastembed/ONNX inference off the main thread.
3
+ *
4
+ * 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
+ * and processes embed requests sequentially from a priority queue. Moving
7
+ * inference here keeps the main thread's event loop free — HTTP requests,
8
+ * SSE streams, and session APIs are no longer blocked during embedding.
9
+ *
10
+ * Communication uses `parentPort` message passing with structured clone.
11
+ * Float32Array vectors are sent back directly (Bun preserves identity).
12
+ *
13
+ * @see embedding-worker-types.ts for the message protocol.
14
+ */
15
+ export {};
16
+ //# sourceMappingURL=embedding-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embedding-worker.d.ts","sourceRoot":"","sources":["../../src/embedding-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
@@ -11,19 +11,83 @@ export interface EmbeddingProvider {
11
11
  embed(texts: string[], inputType: "document" | "query"): Promise<Float32Array[]>;
12
12
  readonly maxBatchSize: number;
13
13
  }
14
- /** Reset cached provider — called when config changes. */
15
- export declare function resetProvider(): void;
14
+ /**
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.
21
+ */
22
+ export declare class LocalProviderUnavailableError extends Error {
23
+ constructor(cause?: unknown);
24
+ }
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;
31
+ /** Reset cached provider — called when config changes.
32
+ * Shuts down the worker thread if the current provider is a LocalProvider.
33
+ * Returns a promise that resolves once any worker has fully exited.
34
+ * Callers that need clean teardown (tests) should await the result. */
35
+ export declare function resetProvider(): Promise<void>;
36
+ /** Shut down the current provider and prevent any new provider from being
37
+ * created. After this call, `embed()` throws and `isAvailable()` returns
38
+ * false. Test-only: prevents fire-and-forget embeds (queued by other test
39
+ * files) from spawning a new worker after cleanup. */
40
+ export declare function _shutdownAndDisable(): Promise<void>;
41
+ /** Save the current cached provider reference (including the live worker)
42
+ * and clear the cache so the next `getProvider()` call creates a fresh one.
43
+ * Returns an opaque token that must be passed to `_restoreProvider()` to
44
+ * put the original provider back — without this, the worker is orphaned and
45
+ * a second ONNX load in the same Bun process will crash.
46
+ *
47
+ * Test-only helper: lets suites temporarily swap in a mock/unavailable
48
+ * provider without killing the real worker. */
49
+ export declare function _saveAndClearProvider(): unknown;
50
+ /** Restore a provider previously saved by `_saveAndClearProvider()`. Any
51
+ * provider created between save and restore is discarded (callers must
52
+ * ensure it's not a LocalProvider with a live worker — those suites only
53
+ * use `_markFastembedUnavailable()` so no worker is spawned). */
54
+ export declare function _restoreProvider(token: unknown): void;
55
+ /**
56
+ * Build a remote `EmbeddingProvider` from whichever API key is in env.
57
+ * Returns `null` when neither `VOYAGE_API_KEY` nor `OPENAI_API_KEY` is set,
58
+ * which is the signal for callers to fall through to FTS-only behaviour.
59
+ *
60
+ * Voyage wins ties because it's the higher-quality option for code search;
61
+ * users who want OpenAI specifically can pin `search.embeddings.provider`
62
+ * in `.lore.json` and skip the fallback path entirely.
63
+ */
64
+ export declare function pickRemoteFallback(): {
65
+ name: "voyage" | "openai";
66
+ provider: EmbeddingProvider;
67
+ } | null;
16
68
  /** Returns true if embedding is available.
17
69
  * Active when the configured provider's API key is set, unless explicitly
18
- * disabled via `search.embeddings.enabled: false` in .lore.json. */
70
+ * disabled via `search.embeddings.enabled: false` in .lore.json.
71
+ *
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. */
19
75
  export declare function isAvailable(): boolean;
20
76
  /**
21
77
  * Generate embeddings for the given texts using the configured provider.
22
78
  *
79
+ * If the configured provider is `local` and `fastembed` turns out to be
80
+ * unavailable at runtime (failed install, vendor extraction blocked, etc.),
81
+ * automatically swap to a remote provider when `VOYAGE_API_KEY` or
82
+ * `OPENAI_API_KEY` is set in env. The swap is permanent for the rest of
83
+ * the process — `cachedProvider` is replaced so subsequent calls skip the
84
+ * local-then-fail path.
85
+ *
23
86
  * @param texts Array of texts to embed
24
87
  * @param inputType "document" for storage, "query" for search
25
88
  * @returns Float32Array per input text
26
- * @throws On API errors or missing provider
89
+ * @throws On API errors or when no provider (local or remote) is
90
+ * available
27
91
  */
28
92
  export declare function embed(texts: string[], inputType: "document" | "query"): Promise<Float32Array[]>;
29
93
  /**
@@ -64,6 +128,24 @@ export declare function embedKnowledgeEntry(id: string, title: string, content:
64
128
  * The distillation remains searchable via FTS even if embedding fails.
65
129
  */
66
130
  export declare function embedDistillation(id: string, observations: string): void;
131
+ /**
132
+ * Embed a temporal message and store the result in the DB.
133
+ * Fire-and-forget — errors are logged, never thrown.
134
+ * Only called for undistilled messages; once distilled, the embedding
135
+ * is NULLed (semantic content captured by distillation embedding).
136
+ */
137
+ export declare function embedTemporalMessage(id: string, content: string): void;
138
+ /**
139
+ * Search undistilled temporal messages with embeddings by cosine similarity.
140
+ * Returns top-k entries sorted by similarity descending.
141
+ *
142
+ * Only scans undistilled messages (distilled=0) — once a message is
143
+ * distilled, its semantic content is captured by the distillation
144
+ * embedding and the temporal embedding is cleared.
145
+ *
146
+ * Scoped to a single project. Optionally scoped to a single session.
147
+ */
148
+ export declare function vectorSearchTemporal(queryEmbedding: Float32Array, projectId: string, limit?: number, sessionId?: string): VectorHit[];
67
149
  /**
68
150
  * Check if embedding config has changed since the last backfill.
69
151
  * If so, clear all existing embeddings (they're incompatible) and
@@ -77,10 +159,11 @@ export declare function checkConfigChange(): boolean;
77
159
  *
78
160
  * This is the canonical entry point that every host adapter (OpenCode, Pi,
79
161
  * future ACP) should call once during init. It:
80
- * 1. Detects config changes (provider swap) and clears stale embeddings
81
- * 2. Backfills knowledge entries missing embeddings
82
- * 3. Backfills non-archived distillations missing embeddings
83
- * 4. Logs a one-line coverage summary to stderr (always visible, not gated)
162
+ * 1. Waits a short grace period so first-connect HTTP requests can finish
163
+ * 2. Detects config changes (provider swap) and clears stale embeddings
164
+ * 3. Backfills knowledge entries missing embeddings
165
+ * 4. Backfills non-archived distillations missing embeddings
166
+ * 5. Logs a one-line coverage summary to stderr (always visible, not gated)
84
167
  *
85
168
  * Fire-and-forget: callers should `.catch()` — embedding failures must not
86
169
  * block plugin initialization.
@@ -1 +1 @@
1
- {"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../src/embedding.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAeH,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO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AkBD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAwC3C;AAgBD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAsExD;AAgBD;;;;;;GAMG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAuC1D;AAMD;;;;GAIG;AACH,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,MAAM,CAAC,CAiDtE"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * git.ts — Git repository identification utilities.
3
+ *
4
+ * Extracts and normalizes git remote URLs to identify projects by their
5
+ * repository identity rather than filesystem path. This enables:
6
+ * - Worktree awareness: main checkout and worktrees share one project
7
+ * - Clone deduplication: same repo cloned to different paths is one project
8
+ * - Fork awareness: prefers `upstream` remote to unify forks with their source
9
+ *
10
+ * Remote URL normalization strips protocol, auth, and `.git` suffix to produce
11
+ * a stable canonical identifier (e.g. "github.com/user/repo") regardless of
12
+ * how the remote was configured (SSH, HTTPS, git://).
13
+ */
14
+ /**
15
+ * Normalize a git remote URL to a canonical form for comparison.
16
+ *
17
+ * Strips protocol, auth, `.git` suffix, and normalizes SSH ↔ HTTPS
18
+ * to produce a stable identifier regardless of how the remote was
19
+ * configured.
20
+ *
21
+ * Examples:
22
+ * git@github.com:user/repo.git → github.com/user/repo
23
+ * https://github.com/user/repo.git → github.com/user/repo
24
+ * ssh://git@github.com/user/repo → github.com/user/repo
25
+ * git://github.com/user/repo.git → github.com/user/repo
26
+ * https://user:token@github.com/user/repo → github.com/user/repo
27
+ */
28
+ export declare function normalizeRemoteUrl(url: string): string;
29
+ /**
30
+ * Clear the in-memory git remote cache.
31
+ *
32
+ * Intended for test harnesses that need deterministic behavior across
33
+ * test cases without leaking cached results.
34
+ */
35
+ export declare function clearGitRemoteCache(): void;
36
+ /**
37
+ * Get the canonical git remote URL for a repository at the given path.
38
+ *
39
+ * Prefers `upstream` remote (for forks) over `origin`, then falls back
40
+ * to any other remote. Returns null if the path is not in a git repo
41
+ * or has no remotes configured.
42
+ *
43
+ * Results are cached in-memory for the process lifetime to avoid repeated
44
+ * subprocess calls — `git remote -v` only runs once per unique path.
45
+ */
46
+ export declare function getGitRemote(path: string): string | null;
47
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/git.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA6BtD;AAaD;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA+CxD"}
@@ -1,5 +1,23 @@
1
1
  import type { LoreMessageWithParts } from "./types";
2
2
  type MessageWithParts = LoreMessageWithParts;
3
+ /** Compute the context ceiling from a per-bust cost target and cache-write price per token. */
4
+ export declare function computeContextCap(targetBustCost: number, cacheWriteCostPerToken: number): number;
5
+ /** Set the static context ceiling. Called by the host adapter after computing
6
+ * from model pricing. The effective per-session cap may be lower due to
7
+ * dynamic adaptation (bust rate EMA). */
8
+ export declare function setMaxContextTokens(tokens: number): void;
9
+ /** Returns the current static ceiling (for external callers / tests). */
10
+ export declare function getMaxContextTokens(): number;
11
+ /**
12
+ * Feed cache usage data after each API response. Updates the per-session
13
+ * bust rate EMA and inter-bust interval, which adjust the effective context
14
+ * cap dynamically.
15
+ *
16
+ * @param cacheWrite - cache_creation_input_tokens from the API response
17
+ * @param cacheRead - cache_read_input_tokens from the API response
18
+ * @param sessionID - session that produced this response
19
+ */
20
+ export declare function updateBustRate(cacheWrite: number, cacheRead: number, sessionID?: string): void;
3
21
  type DistillationSnapshot = {
4
22
  /** Cached distillation rows from the most recent DB read */
5
23
  rows: Distillation[];
@@ -182,7 +200,7 @@ export type TransformResult = {
182
200
  distilledBudget: number;
183
201
  rawBudget: number;
184
202
  };
185
- export declare function needsUrgentDistillation(): boolean;
203
+ export declare function needsUrgentDistillation(sessionID: string): boolean;
186
204
  export declare function transform(input: {
187
205
  messages: MessageWithParts[];
188
206
  projectPath: string;
@@ -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;AAkE7C,KAAK,oBAAoB,GAAG;IAC1B,4DAA4D;IAC5D,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AA6GF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,GAAG,GAAE,MAAmB,GACvB;IAAE,SAAS,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAY5D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAK/D;AAOD,wBAAgB,cAAc,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,QASzE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,QAEhD;AAED,sFAAsF;AACtF,wBAAgB,gBAAgB,CAC9B,iBAAiB,EAAE,MAAM,EACzB,qBAAqB,EAAE,MAAM,GAC5B,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Ac,EAAE,MAAM,GACrB,gBAAgB,EAAE,CA+FpB;AAmQD,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;AAE5C,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;CACnB,CAAC;AAMF,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAIlE;AAmVD,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"}
@@ -1,21 +1,24 @@
1
1
  export * as temporal from "./temporal";
2
2
  export * as ltm from "./ltm";
3
+ export * as data from "./data";
3
4
  export * as distillation from "./distillation";
4
5
  export * as curator from "./curator";
5
6
  export * as embedding from "./embedding";
7
+ export * as embeddingVendor from "./embedding-vendor";
6
8
  export * as latReader from "./lat-reader";
7
9
  export * as patternExtract from "./pattern-extract";
8
10
  export * as log from "./log";
9
- export { runRecall, RECALL_TOOL_DESCRIPTION, RECALL_PARAM_DESCRIPTIONS, type RecallInput, type RecallResult, type RecallScope, type ScoredDistillation, } from "./recall";
11
+ export { runRecall, searchRecall, recallById, RECALL_TOOL_DESCRIPTION, RECALL_PARAM_DESCRIPTIONS, type RecallInput, type RecallResult, type RecallScope, type ScoredDistillation, type TaggedResult, type ScoredTaggedResult, } from "./recall";
10
12
  export type { LoreMessage, LoreUserMessage, LoreAssistantMessage, LorePart, LoreTextPart, LoreReasoningPart, LoreToolPart, LoreGenericPart, LoreToolState, LoreToolStatePending, LoreToolStateRunning, LoreToolStateCompleted, LoreToolStateError, LoreMessageWithParts, LLMClient, } from "./types";
11
13
  export { isTextPart, isReasoningPart, isToolPart } from "./types";
12
14
  export { load, config, type LoreConfig } from "./config";
13
- export { db, ensureProject, isFirstRun, projectId, projectName, loadForceMinLayer, saveForceMinLayer, getMeta, setMeta, getInstanceId, close, } from "./db";
14
- export { transform, setModelLimits, setMaxLayer0Tokens, computeLayer0Cap, needsUrgentDistillation, calibrate, setLtmTokens, getLtmTokens, getLtmBudget, setForceMinLayer, getLastTransformedCount, getLastTransformEstimate, toolStripAnnotation, onIdleResume, getLastTurnAt, consumeCameOutOfIdle, setLastTurnAtForTest, inspectSessionState, } from "./gradient";
15
+ export { db, dbPath, ensureProject, isFirstRun, projectId, projectName, mergeProjectInternal, loadForceMinLayer, saveForceMinLayer, saveSessionCosts, loadSessionCosts, loadAllSessionCosts, type SessionCostSnapshot, getMeta, setMeta, getInstanceId, close, } from "./db";
16
+ export { normalizeRemoteUrl, getGitRemote, clearGitRemoteCache } from "./git";
17
+ export { transform, setModelLimits, setMaxLayer0Tokens, computeLayer0Cap, setMaxContextTokens, computeContextCap, getMaxContextTokens, updateBustRate, needsUrgentDistillation, calibrate, setLtmTokens, getLtmTokens, getLtmBudget, setForceMinLayer, getLastTransformedCount, getLastTransformEstimate, toolStripAnnotation, onIdleResume, getLastTurnAt, consumeCameOutOfIdle, setLastTurnAtForTest, inspectSessionState, } from "./gradient";
15
18
  export { formatKnowledge, formatDistillations, DISTILLATION_SYSTEM, distillationUser, RECURSIVE_SYSTEM, recursiveUser, CURATOR_SYSTEM, curatorUser, CONSOLIDATION_SYSTEM, consolidationUser, QUERY_EXPANSION_SYSTEM, COMPACT_SUMMARY_TEMPLATE, buildCompactPrompt, } from "./prompt";
16
- export { shouldImport, importFromFile, exportToFile, exportLoreFile, importLoreFile, shouldImportLoreFile, loreFileExists, LORE_FILE, } from "./agents-file";
19
+ export { shouldImport, importFromFile, exportToFile, exportLoreFile, importLoreFile, shouldImportLoreFile, loreFileExists, clearLoreFileCache, LORE_FILE, } from "./agents-file";
17
20
  export { workerSessionIDs, isWorkerSession } from "./worker";
18
21
  export * as workerModel from "./worker-model";
19
- export { ftsQuery, ftsQueryOr, EMPTY_QUERY, reciprocalRankFusion, expandQuery, extractTopTerms, exactTermMatchRank, } from "./search";
20
- export { serialize, inline, h, p, ul, lip, liph, t, root, strong, normalize, sanitizeSurrogates, unescapeMarkdown, } from "./markdown";
22
+ export { ftsQuery, ftsQueryOr, ftsQueryRelaxed, EMPTY_QUERY, reciprocalRankFusion, expandQuery, extractTopTerms, exactTermMatchRank, } from "./search";
23
+ export { serialize, inline, h, p, ul, lip, liph, t, root, strong, normalize, sanitizeSurrogates, unescapeMarkdown, renderMarkdown, } from "./markdown";
21
24
  //# sourceMappingURL=index.d.ts.map