@loreai/core 0.16.0 → 0.17.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.
- package/README.md +11 -0
- package/dist/bun/agents-file.d.ts +13 -1
- package/dist/bun/agents-file.d.ts.map +1 -1
- package/dist/bun/config.d.ts +20 -1
- package/dist/bun/config.d.ts.map +1 -1
- package/dist/bun/data.d.ts +174 -0
- package/dist/bun/data.d.ts.map +1 -0
- package/dist/bun/db.d.ts +65 -0
- package/dist/bun/db.d.ts.map +1 -1
- package/dist/bun/distillation.d.ts +49 -6
- package/dist/bun/distillation.d.ts.map +1 -1
- package/dist/bun/embedding-vendor.d.ts +66 -0
- package/dist/bun/embedding-vendor.d.ts.map +1 -0
- package/dist/bun/embedding-worker-types.d.ts +66 -0
- package/dist/bun/embedding-worker-types.d.ts.map +1 -0
- package/dist/bun/embedding-worker.d.ts +16 -0
- package/dist/bun/embedding-worker.d.ts.map +1 -0
- package/dist/bun/embedding-worker.js +100 -0
- package/dist/bun/embedding-worker.js.map +7 -0
- package/dist/bun/embedding.d.ts +91 -8
- package/dist/bun/embedding.d.ts.map +1 -1
- package/dist/bun/git.d.ts +47 -0
- package/dist/bun/git.d.ts.map +1 -0
- package/dist/bun/gradient.d.ts +19 -1
- package/dist/bun/gradient.d.ts.map +1 -1
- package/dist/bun/index.d.ts +9 -6
- package/dist/bun/index.d.ts.map +1 -1
- package/dist/bun/index.js +13029 -10885
- package/dist/bun/index.js.map +4 -4
- package/dist/bun/lat-reader.d.ts +1 -1
- package/dist/bun/lat-reader.d.ts.map +1 -1
- package/dist/bun/ltm.d.ts.map +1 -1
- package/dist/bun/markdown.d.ts +11 -0
- package/dist/bun/markdown.d.ts.map +1 -1
- package/dist/bun/prompt.d.ts +1 -1
- package/dist/bun/prompt.d.ts.map +1 -1
- package/dist/bun/recall.d.ts +53 -0
- package/dist/bun/recall.d.ts.map +1 -1
- package/dist/bun/search.d.ts +29 -0
- package/dist/bun/search.d.ts.map +1 -1
- package/dist/bun/temporal.d.ts +2 -0
- package/dist/bun/temporal.d.ts.map +1 -1
- package/dist/bun/types.d.ts +15 -0
- package/dist/bun/types.d.ts.map +1 -1
- package/dist/bun/worker-model.d.ts +12 -9
- package/dist/bun/worker-model.d.ts.map +1 -1
- package/dist/node/agents-file.d.ts +13 -1
- package/dist/node/agents-file.d.ts.map +1 -1
- package/dist/node/config.d.ts +20 -1
- package/dist/node/config.d.ts.map +1 -1
- package/dist/node/data.d.ts +174 -0
- package/dist/node/data.d.ts.map +1 -0
- package/dist/node/db.d.ts +65 -0
- package/dist/node/db.d.ts.map +1 -1
- package/dist/node/distillation.d.ts +49 -6
- package/dist/node/distillation.d.ts.map +1 -1
- package/dist/node/embedding-vendor.d.ts +66 -0
- package/dist/node/embedding-vendor.d.ts.map +1 -0
- package/dist/node/embedding-worker-types.d.ts +66 -0
- package/dist/node/embedding-worker-types.d.ts.map +1 -0
- package/dist/node/embedding-worker.d.ts +16 -0
- package/dist/node/embedding-worker.d.ts.map +1 -0
- package/dist/node/embedding-worker.js +100 -0
- package/dist/node/embedding-worker.js.map +7 -0
- package/dist/node/embedding.d.ts +91 -8
- package/dist/node/embedding.d.ts.map +1 -1
- package/dist/node/git.d.ts +47 -0
- package/dist/node/git.d.ts.map +1 -0
- package/dist/node/gradient.d.ts +19 -1
- package/dist/node/gradient.d.ts.map +1 -1
- package/dist/node/index.d.ts +9 -6
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +13029 -10885
- package/dist/node/index.js.map +4 -4
- package/dist/node/lat-reader.d.ts +1 -1
- package/dist/node/lat-reader.d.ts.map +1 -1
- package/dist/node/ltm.d.ts.map +1 -1
- package/dist/node/markdown.d.ts +11 -0
- package/dist/node/markdown.d.ts.map +1 -1
- package/dist/node/prompt.d.ts +1 -1
- package/dist/node/prompt.d.ts.map +1 -1
- package/dist/node/recall.d.ts +53 -0
- package/dist/node/recall.d.ts.map +1 -1
- package/dist/node/search.d.ts +29 -0
- package/dist/node/search.d.ts.map +1 -1
- package/dist/node/temporal.d.ts +2 -0
- package/dist/node/temporal.d.ts.map +1 -1
- package/dist/node/types.d.ts +15 -0
- package/dist/node/types.d.ts.map +1 -1
- package/dist/node/worker-model.d.ts +12 -9
- package/dist/node/worker-model.d.ts.map +1 -1
- package/dist/types/agents-file.d.ts +13 -1
- package/dist/types/agents-file.d.ts.map +1 -1
- package/dist/types/config.d.ts +20 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/data.d.ts +174 -0
- package/dist/types/data.d.ts.map +1 -0
- package/dist/types/db.d.ts +65 -0
- package/dist/types/db.d.ts.map +1 -1
- package/dist/types/distillation.d.ts +49 -6
- package/dist/types/distillation.d.ts.map +1 -1
- package/dist/types/embedding-vendor.d.ts +66 -0
- package/dist/types/embedding-vendor.d.ts.map +1 -0
- package/dist/types/embedding-worker-types.d.ts +66 -0
- package/dist/types/embedding-worker-types.d.ts.map +1 -0
- package/dist/types/embedding-worker.d.ts +16 -0
- package/dist/types/embedding-worker.d.ts.map +1 -0
- package/dist/types/embedding.d.ts +91 -8
- package/dist/types/embedding.d.ts.map +1 -1
- package/dist/types/git.d.ts +47 -0
- package/dist/types/git.d.ts.map +1 -0
- package/dist/types/gradient.d.ts +19 -1
- package/dist/types/gradient.d.ts.map +1 -1
- package/dist/types/index.d.ts +9 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lat-reader.d.ts +1 -1
- package/dist/types/lat-reader.d.ts.map +1 -1
- package/dist/types/ltm.d.ts.map +1 -1
- package/dist/types/markdown.d.ts +11 -0
- package/dist/types/markdown.d.ts.map +1 -1
- package/dist/types/prompt.d.ts +1 -1
- package/dist/types/prompt.d.ts.map +1 -1
- package/dist/types/recall.d.ts +53 -0
- package/dist/types/recall.d.ts.map +1 -1
- package/dist/types/search.d.ts +29 -0
- package/dist/types/search.d.ts.map +1 -1
- package/dist/types/temporal.d.ts +2 -0
- package/dist/types/temporal.d.ts.map +1 -1
- package/dist/types/types.d.ts +15 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/worker-model.d.ts +12 -9
- package/dist/types/worker-model.d.ts.map +1 -1
- package/package.json +5 -2
- package/src/agents-file.ts +87 -4
- package/src/config.ts +68 -5
- package/src/curator.ts +2 -2
- package/src/data.ts +768 -0
- package/src/db.ts +386 -7
- package/src/distillation.ts +178 -35
- package/src/embedding-vendor.ts +102 -0
- package/src/embedding-worker-types.ts +82 -0
- package/src/embedding-worker.ts +185 -0
- package/src/embedding.ts +607 -61
- package/src/git.ts +144 -0
- package/src/gradient.ts +174 -17
- package/src/index.ts +20 -0
- package/src/lat-reader.ts +5 -11
- package/src/ltm.ts +17 -44
- package/src/markdown.ts +15 -0
- package/src/prompt.ts +1 -2
- package/src/recall.ts +401 -70
- package/src/search.ts +71 -1
- package/src/temporal.ts +42 -35
- package/src/types.ts +15 -0
- package/src/worker-model.ts +14 -9
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// src/embedding-worker.ts
|
|
2
|
+
import { parentPort, workerData } from "node:worker_threads";
|
|
3
|
+
var { modelName, vendorModel } = workerData;
|
|
4
|
+
var model = null;
|
|
5
|
+
var initPromise = null;
|
|
6
|
+
var initFailed = false;
|
|
7
|
+
var initError = null;
|
|
8
|
+
async function ensureModel() {
|
|
9
|
+
if (model) return model;
|
|
10
|
+
if (initFailed) throw new Error(initError ?? "fastembed init previously failed");
|
|
11
|
+
if (!initPromise) {
|
|
12
|
+
initPromise = (async () => {
|
|
13
|
+
const fastembed = await import("fastembed");
|
|
14
|
+
const { EmbeddingModel, FlagEmbedding } = fastembed;
|
|
15
|
+
let m;
|
|
16
|
+
if (vendorModel) {
|
|
17
|
+
m = await FlagEmbedding.init({
|
|
18
|
+
model: EmbeddingModel.CUSTOM,
|
|
19
|
+
modelAbsoluteDirPath: vendorModel.modelAbsoluteDirPath,
|
|
20
|
+
modelName: vendorModel.modelName
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
const enumValue = EmbeddingModel[modelName];
|
|
24
|
+
m = await FlagEmbedding.init({
|
|
25
|
+
model: enumValue ?? modelName
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
model = m;
|
|
29
|
+
})().catch((err) => {
|
|
30
|
+
initFailed = true;
|
|
31
|
+
initError = err instanceof Error ? err.message : String(err);
|
|
32
|
+
initPromise = null;
|
|
33
|
+
post({ type: "init-error", error: initError });
|
|
34
|
+
throw err;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
await initPromise;
|
|
38
|
+
if (!model) throw new Error("model init completed but model is null");
|
|
39
|
+
return model;
|
|
40
|
+
}
|
|
41
|
+
var queue = [];
|
|
42
|
+
var processing = false;
|
|
43
|
+
function enqueue(msg) {
|
|
44
|
+
if (msg.priority === "high") {
|
|
45
|
+
let insertAt = 0;
|
|
46
|
+
while (insertAt < queue.length && queue[insertAt].priority === "high") {
|
|
47
|
+
insertAt++;
|
|
48
|
+
}
|
|
49
|
+
queue.splice(insertAt, 0, msg);
|
|
50
|
+
} else {
|
|
51
|
+
queue.push(msg);
|
|
52
|
+
}
|
|
53
|
+
drain();
|
|
54
|
+
}
|
|
55
|
+
async function drain() {
|
|
56
|
+
if (processing) return;
|
|
57
|
+
processing = true;
|
|
58
|
+
while (queue.length > 0) {
|
|
59
|
+
const req = queue.shift();
|
|
60
|
+
await processEmbed(req);
|
|
61
|
+
}
|
|
62
|
+
processing = false;
|
|
63
|
+
}
|
|
64
|
+
async function processEmbed(req) {
|
|
65
|
+
try {
|
|
66
|
+
const m = await ensureModel();
|
|
67
|
+
let vectors;
|
|
68
|
+
if (req.inputType === "query" && req.texts.length === 1) {
|
|
69
|
+
const vec = await m.queryEmbed(req.texts[0]);
|
|
70
|
+
vectors = [new Float32Array(vec)];
|
|
71
|
+
} else {
|
|
72
|
+
vectors = [];
|
|
73
|
+
for await (const batch of m.passageEmbed(req.texts)) {
|
|
74
|
+
for (const vec of batch) {
|
|
75
|
+
vectors.push(new Float32Array(vec));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
post({ type: "result", id: req.id, vectors });
|
|
80
|
+
} catch (err) {
|
|
81
|
+
if (!initFailed) {
|
|
82
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
83
|
+
post({ type: "error", id: req.id, error: msg });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function post(msg) {
|
|
88
|
+
parentPort.postMessage(msg);
|
|
89
|
+
}
|
|
90
|
+
parentPort.on("message", (msg) => {
|
|
91
|
+
switch (msg.type) {
|
|
92
|
+
case "embed":
|
|
93
|
+
enqueue(msg);
|
|
94
|
+
break;
|
|
95
|
+
case "shutdown":
|
|
96
|
+
process.exit(0);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
//# sourceMappingURL=embedding-worker.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/embedding-worker.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Embedding worker thread \u2014 runs fastembed/ONNX inference off the main thread.\n *\n * This file is the entry point for a `node:worker_threads` Worker spawned by\n * `LocalProvider` in `embedding.ts`. It owns the `FlagEmbedding` ONNX model\n * and processes embed requests sequentially from a priority queue. Moving\n * inference here keeps the main thread's event loop free \u2014 HTTP requests,\n * SSE streams, and session APIs are no longer blocked during embedding.\n *\n * Communication uses `parentPort` message passing with structured clone.\n * Float32Array vectors are sent back directly (Bun preserves identity).\n *\n * @see embedding-worker-types.ts for the message protocol.\n */\n\nimport { parentPort, workerData } from \"node:worker_threads\";\nimport type {\n WorkerInbound,\n WorkerOutbound,\n WorkerInitData,\n EmbedRequest,\n} from \"./embedding-worker-types\";\n\n// ---------------------------------------------------------------------------\n// workerData\n// ---------------------------------------------------------------------------\n\nconst { modelName, vendorModel } = workerData as WorkerInitData;\n\n// ---------------------------------------------------------------------------\n// Model lifecycle \u2014 lazy init on first embed request\n// ---------------------------------------------------------------------------\n\n/** The fastembed model, typed to the subset of methods we use. */\ntype FastembedModel = {\n queryEmbed(text: string): Promise<number[]>;\n passageEmbed(texts: string[], batchSize?: number): AsyncGenerator<number[][]>;\n};\n\nlet model: FastembedModel | null = null;\nlet initPromise: Promise<void> | null = null;\nlet initFailed = false;\nlet initError: string | null = null;\n\n/**\n * Ensure the fastembed model is loaded. Lazy \u2014 first call triggers the\n * dynamic import + FlagEmbedding.init(), subsequent calls return immediately.\n * On failure, marks the worker as permanently broken and posts `init-error`.\n */\nasync function ensureModel(): Promise<FastembedModel> {\n if (model) return model;\n if (initFailed) throw new Error(initError ?? \"fastembed init previously failed\");\n\n if (!initPromise) {\n initPromise = (async () => {\n const fastembed = await import(\"fastembed\");\n const { EmbeddingModel, FlagEmbedding } = fastembed;\n\n let m: unknown;\n if (vendorModel) {\n // Binary mode: use pre-extracted model files.\n m = await FlagEmbedding.init({\n model: EmbeddingModel.CUSTOM,\n modelAbsoluteDirPath: vendorModel.modelAbsoluteDirPath,\n modelName: vendorModel.modelName,\n });\n } else {\n // npm mode: resolve model name against fastembed's enum.\n const enumValue = (EmbeddingModel as Record<string, string>)[modelName];\n m = await FlagEmbedding.init({\n model: enumValue ?? modelName,\n } as { model: typeof EmbeddingModel.BGESmallENV15 });\n }\n model = m as FastembedModel;\n })().catch((err) => {\n initFailed = true;\n initError = err instanceof Error ? err.message : String(err);\n initPromise = null;\n // Notify main thread \u2014 all pending + future requests should fail.\n post({ type: \"init-error\", error: initError });\n throw err;\n });\n }\n\n await initPromise;\n if (!model) throw new Error(\"model init completed but model is null\");\n return model;\n}\n\n// ---------------------------------------------------------------------------\n// Priority queue \u2014 high-priority (recall) jumps ahead of normal (backfill)\n// ---------------------------------------------------------------------------\n\nconst queue: EmbedRequest[] = [];\nlet processing = false;\n\n/**\n * Enqueue an embed request. High-priority requests are inserted after any\n * existing high-priority items but before all normal-priority items (FIFO\n * within each priority level). Triggers drain if not already running.\n */\nfunction enqueue(msg: EmbedRequest): void {\n if (msg.priority === \"high\") {\n // Insert after the last \"high\" item \u2014 keeps FIFO within high priority.\n let insertAt = 0;\n while (insertAt < queue.length && queue[insertAt].priority === \"high\") {\n insertAt++;\n }\n queue.splice(insertAt, 0, msg);\n } else {\n queue.push(msg);\n }\n drain();\n}\n\n/**\n * Process queued requests one at a time. ONNX inference is synchronous\n * inside the NAPI call, so parallelism within the worker buys nothing.\n * The queue gives us a natural point to interleave high-priority requests\n * between normal-priority batches.\n */\nasync function drain(): Promise<void> {\n if (processing) return;\n processing = true;\n\n while (queue.length > 0) {\n const req = queue.shift()!;\n await processEmbed(req);\n }\n\n processing = false;\n}\n\n// ---------------------------------------------------------------------------\n// Embed processing\n// ---------------------------------------------------------------------------\n\nasync function processEmbed(req: EmbedRequest): Promise<void> {\n try {\n const m = await ensureModel();\n\n let vectors: Float32Array[];\n\n if (req.inputType === \"query\" && req.texts.length === 1) {\n // Single query \u2014 use queryEmbed for better quality.\n const vec = await m.queryEmbed(req.texts[0]);\n vectors = [new Float32Array(vec)];\n } else {\n // Batch document embedding via async generator.\n vectors = [];\n for await (const batch of m.passageEmbed(req.texts)) {\n for (const vec of batch) {\n vectors.push(new Float32Array(vec));\n }\n }\n }\n\n post({ type: \"result\", id: req.id, vectors });\n } catch (err) {\n // Don't re-post init-error \u2014 it was already sent in ensureModel().\n if (!initFailed) {\n const msg = err instanceof Error ? err.message : String(err);\n post({ type: \"error\", id: req.id, error: msg });\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Message handling\n// ---------------------------------------------------------------------------\n\nfunction post(msg: WorkerOutbound): void {\n parentPort!.postMessage(msg);\n}\n\nparentPort!.on(\"message\", (msg: WorkerInbound) => {\n switch (msg.type) {\n case \"embed\":\n enqueue(msg);\n break;\n case \"shutdown\":\n process.exit(0);\n break;\n }\n});\n"],
|
|
5
|
+
"mappings": ";AAeA,SAAS,YAAY,kBAAkB;AAYvC,IAAM,EAAE,WAAW,YAAY,IAAI;AAYnC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Eb,SAAO,MAAM,SAAS,GAAG;AACvB,UAAM,MAAM,MAAM,MAAM;AACxB,UAAM,aAAa,GAAG;AAAA,EACxB;AAEA,eAAa;AACf;AAMA,eAAe,aAAa,KAAkC;AAC5D,MAAI;AACF,UAAM,IAAI,MAAM,YAAY;AAE5B,QAAI;AAEJ,QAAI,IAAI,cAAc,WAAW,IAAI,MAAM,WAAW,GAAG;AAEvD,YAAM,MAAM,MAAM,EAAE,WAAW,IAAI,MAAM,CAAC,CAAC;AAC3C,gBAAU,CAAC,IAAI,aAAa,GAAG,CAAC;AAAA,IAClC,OAAO;AAEL,gBAAU,CAAC;AACX,uBAAiB,SAAS,EAAE,aAAa,IAAI,KAAK,GAAG;AACnD,mBAAW,OAAO,OAAO;AACvB,kBAAQ,KAAK,IAAI,aAAa,GAAG,CAAC;AAAA,QACpC;AAAA,MACF;AAAA,IACF;AAEA,SAAK,EAAE,MAAM,UAAU,IAAI,IAAI,IAAI,QAAQ,CAAC;AAAA,EAC9C,SAAS,KAAK;AAEZ,QAAI,CAAC,YAAY;AACf,YAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,WAAK,EAAE,MAAM,SAAS,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC;AAAA,IAChD;AAAA,EACF;AACF;AAMA,SAAS,KAAK,KAA2B;AACvC,aAAY,YAAY,GAAG;AAC7B;AAEA,WAAY,GAAG,WAAW,CAAC,QAAuB;AAChD,UAAQ,IAAI,MAAM;AAAA,IAChB,KAAK;AACH,cAAQ,GAAG;AACX;AAAA,IACF,KAAK;AACH,cAAQ,KAAK,CAAC;AACd;AAAA,EACJ;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/bun/embedding.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
15
|
-
|
|
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
|
|
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.
|
|
81
|
-
* 2.
|
|
82
|
-
* 3. Backfills
|
|
83
|
-
* 4.
|
|
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;
|
|
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;AAoY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AAE,CAgBb;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;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"}
|
package/dist/bun/gradient.d.ts
CHANGED
|
@@ -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;
|
|
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,MAAM,QAEjD;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI,CA8BN;AAiED,KAAK,oBAAoB,GAAG;IAC1B,4DAA4D;IAC5D,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AA8HF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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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"}
|
package/dist/bun/index.d.ts
CHANGED
|
@@ -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 {
|
|
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
|
package/dist/bun/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK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