@loreai/core 0.14.1 → 0.16.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/dist/bun/db.d.ts CHANGED
@@ -19,4 +19,15 @@ export declare function loadForceMinLayer(sessionID: string): number;
19
19
  * (consumed) to avoid unbounded growth.
20
20
  */
21
21
  export declare function saveForceMinLayer(sessionID: string, layer: number): void;
22
+ /** Get a metadata value by key. Returns null if not found. */
23
+ export declare function getMeta(key: string): string | null;
24
+ /** Set a metadata value (upsert). */
25
+ export declare function setMeta(key: string, value: string): void;
26
+ /**
27
+ * Get or create the installation instance ID.
28
+ *
29
+ * Generated once (UUID v4) on first call, then persisted in the metadata
30
+ * table across process restarts and upgrades.
31
+ */
32
+ export declare function getInstanceId(): string;
22
33
  //# sourceMappingURL=db.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA0WtC,wBAAgB,EAAE,IAAI,QAAQ,CAkC7B;AAmGD,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"}
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,CAMxD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAMtC"}
@@ -10,7 +10,7 @@ export { runRecall, RECALL_TOOL_DESCRIPTION, RECALL_PARAM_DESCRIPTIONS, type Rec
10
10
  export type { LoreMessage, LoreUserMessage, LoreAssistantMessage, LorePart, LoreTextPart, LoreReasoningPart, LoreToolPart, LoreGenericPart, LoreToolState, LoreToolStatePending, LoreToolStateRunning, LoreToolStateCompleted, LoreToolStateError, LoreMessageWithParts, LLMClient, } from "./types";
11
11
  export { isTextPart, isReasoningPart, isToolPart } from "./types";
12
12
  export { load, config, type LoreConfig } from "./config";
13
- export { db, ensureProject, isFirstRun, projectId, projectName, loadForceMinLayer, saveForceMinLayer, close, } from "./db";
13
+ export { db, ensureProject, isFirstRun, projectId, projectName, loadForceMinLayer, saveForceMinLayer, getMeta, setMeta, getInstanceId, close, } from "./db";
14
14
  export { transform, setModelLimits, setMaxLayer0Tokens, computeLayer0Cap, needsUrgentDistillation, calibrate, setLtmTokens, getLtmTokens, getLtmBudget, setForceMinLayer, getLastTransformedCount, getLastTransformEstimate, toolStripAnnotation, onIdleResume, getLastTurnAt, consumeCameOutOfIdle, setLastTurnAtForTest, inspectSessionState, } from "./gradient";
15
15
  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
16
  export { shouldImport, importFromFile, exportToFile, exportLoreFile, importLoreFile, shouldImportLoreFile, loreFileExists, LORE_FILE, } from "./agents-file";
@@ -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,GAAG,MAAM,OAAO,CAAC;AAE7B,OAAO,EACL,SAAS,EACT,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,kBAAkB,G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@ -491,6 +491,18 @@ var MIGRATIONS = [
491
491
  -- Both columns are nullable REALs \u2014 cheap to add, no backfill needed.
492
492
  ALTER TABLE distillations ADD COLUMN r_compression REAL;
493
493
  ALTER TABLE distillations ADD COLUMN c_norm REAL;
494
+ `,
495
+ `
496
+ -- Version 13: Installation metadata table for telemetry and diagnostics.
497
+ --
498
+ -- Separate from kv_meta (plugin state) \u2014 this holds installation-scoped
499
+ -- values: instance_id, release_channel, etc. Has updated_at for tracking
500
+ -- when values last changed.
501
+ CREATE TABLE IF NOT EXISTS metadata (
502
+ key TEXT PRIMARY KEY,
503
+ value TEXT NOT NULL,
504
+ updated_at INTEGER NOT NULL
505
+ );
494
506
  `
495
507
  ];
496
508
  function dataDir() {
@@ -566,6 +578,11 @@ function recoverMissingObjects(database) {
566
578
  key TEXT PRIMARY KEY,
567
579
  value TEXT NOT NULL
568
580
  );
581
+ CREATE TABLE IF NOT EXISTS metadata (
582
+ key TEXT PRIMARY KEY,
583
+ value TEXT NOT NULL,
584
+ updated_at INTEGER NOT NULL
585
+ );
569
586
  `);
570
587
  }
571
588
  function close() {
@@ -608,6 +625,22 @@ function saveForceMinLayer(sessionID, layer) {
608
625
  ).run(sessionID, layer, Date.now());
609
626
  }
610
627
  }
628
+ function getMeta(key) {
629
+ const row = db().query("SELECT value FROM metadata WHERE key = ?").get(key);
630
+ return row?.value ?? null;
631
+ }
632
+ function setMeta(key, value) {
633
+ db().query(
634
+ "INSERT INTO metadata (key, value, updated_at) VALUES (?, ?, ?) ON CONFLICT(key) DO UPDATE SET value = ?, updated_at = ?"
635
+ ).run(key, value, Date.now(), value, Date.now());
636
+ }
637
+ function getInstanceId() {
638
+ const existing = getMeta("instance_id");
639
+ if (existing) return existing;
640
+ const id = crypto.randomUUID();
641
+ setMeta("instance_id", id);
642
+ return id;
643
+ }
611
644
 
612
645
  // ../../node_modules/.bun/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js
613
646
  var emptyOptions = {};
@@ -28955,208 +28988,10 @@ function importLoreFile(projectPath) {
28955
28988
  // src/worker-model.ts
28956
28989
  var worker_model_exports = {};
28957
28990
  __export(worker_model_exports, {
28958
- WORKER_JUDGE_SYSTEM: () => WORKER_JUDGE_SYSTEM,
28959
- clearValidatedWorkerModel: () => clearValidatedWorkerModel,
28960
- computeModelFingerprint: () => computeModelFingerprint,
28961
- getValidatedWorkerModel: () => getValidatedWorkerModel,
28962
- isValidationStale: () => isValidationStale,
28963
- parseJudgeScore: () => parseJudgeScore,
28964
- resolveWorkerModel: () => resolveWorkerModel,
28965
- runValidation: () => runValidation,
28966
- selectWorkerCandidates: () => selectWorkerCandidates,
28967
- storeValidatedWorkerModel: () => storeValidatedWorkerModel,
28968
- structuralCheck: () => structuralCheck,
28969
- workerJudgeUser: () => workerJudgeUser
28991
+ resolveWorkerModel: () => resolveWorkerModel
28970
28992
  });
28971
- var KV_PREFIX = "lore:worker_model:";
28972
- function selectWorkerCandidates(sessionModel, providerModels) {
28973
- const eligible = providerModels.filter(
28974
- (m) => m.providerID === sessionModel.providerID && m.status === "active" && m.capabilities.input.text
28975
- );
28976
- if (eligible.length === 0) return [];
28977
- const sorted = [...eligible].sort((a, b) => {
28978
- const costDiff = a.cost.input - b.cost.input;
28979
- if (costDiff !== 0) return costDiff;
28980
- const aReasoning = a.capabilities.reasoning ? 1 : 0;
28981
- const bReasoning = b.capabilities.reasoning ? 1 : 0;
28982
- return aReasoning - bReasoning;
28983
- });
28984
- const cheapest = sorted[0];
28985
- const belowSession = sorted.filter((m) => m.cost.input < sessionModel.cost.input).pop();
28986
- const candidates = /* @__PURE__ */ new Map();
28987
- candidates.set(cheapest.id, cheapest);
28988
- if (belowSession && belowSession.id !== cheapest.id) {
28989
- candidates.set(belowSession.id, belowSession);
28990
- }
28991
- if (cheapest.id === sessionModel.id || cheapest.cost.input >= sessionModel.cost.input) {
28992
- return [cheapest];
28993
- }
28994
- return [...candidates.values()];
28995
- }
28996
- function computeModelFingerprint(providerID, sessionModelID, activeModelIDs) {
28997
- const sorted = [...activeModelIDs].sort();
28998
- return sha256(
28999
- JSON.stringify({ providerID, sessionModelID, modelIDs: sorted })
29000
- );
29001
- }
29002
- function getValidatedWorkerModel(providerID) {
29003
- const row = db().query("SELECT value FROM kv_meta WHERE key = ?").get(`${KV_PREFIX}${providerID}`);
29004
- if (!row) return null;
29005
- try {
29006
- return JSON.parse(row.value);
29007
- } catch {
29008
- return null;
29009
- }
29010
- }
29011
- function storeValidatedWorkerModel(result) {
29012
- const key = `${KV_PREFIX}${result.providerID}`;
29013
- const value = JSON.stringify(result);
29014
- db().query(
29015
- "INSERT INTO kv_meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = ?"
29016
- ).run(key, value, value);
29017
- }
29018
- function clearValidatedWorkerModel(providerID) {
29019
- db().query("DELETE FROM kv_meta WHERE key = ?").run(`${KV_PREFIX}${providerID}`);
29020
- }
29021
- function isValidationStale(stored, currentFingerprint) {
29022
- if (!stored) return true;
29023
- return stored.fingerprint !== currentFingerprint;
29024
- }
29025
- function structuralCheck(candidateObservations, referenceObservations) {
29026
- if (candidateObservations == null || candidateObservations.length === 0) {
29027
- return { passed: false, observationCount: 0, tokenCount: 0, reason: candidateObservations === null ? "parse_failed" : "empty" };
29028
- }
29029
- const countObs = (text4) => text4.split("\n").filter((l) => l.trim().length > 0).length;
29030
- const refCount = countObs(referenceObservations);
29031
- const candCount = countObs(candidateObservations);
29032
- const candTokens = Math.ceil(candidateObservations.length / 3);
29033
- if (refCount > 0 && (candCount < refCount * 0.5 || candCount > refCount * 1.5)) {
29034
- return {
29035
- passed: false,
29036
- observationCount: candCount,
29037
- tokenCount: candTokens,
29038
- reason: `observation_count_${candCount}_vs_ref_${refCount}`
29039
- };
29040
- }
29041
- const refTokens = Math.ceil(referenceObservations.length / 3);
29042
- if (candTokens === 0) {
29043
- return { passed: false, observationCount: candCount, tokenCount: candTokens, reason: "empty" };
29044
- }
29045
- if (refTokens > 0 && candTokens > refTokens * 3) {
29046
- return {
29047
- passed: false,
29048
- observationCount: candCount,
29049
- tokenCount: candTokens,
29050
- reason: `token_count_${candTokens}_vs_ref_${refTokens}_3x`
29051
- };
29052
- }
29053
- return { passed: true, observationCount: candCount, tokenCount: candTokens };
29054
- }
29055
- var WORKER_JUDGE_SYSTEM = `You are evaluating distillation quality. You will be given a REFERENCE distillation (produced by a capable model) and a CANDIDATE distillation (produced by a cheaper model) of the same conversation segment.
29056
-
29057
- Rate the candidate on a scale of 1-5:
29058
- 5 = Captures all key facts and decisions, equivalent to reference
29059
- 4 = Captures most facts, minor omissions
29060
- 3 = Captures the essential facts, some detail loss acceptable
29061
- 2 = Missing important facts or technical details
29062
- 1 = Significantly incomplete or inaccurate
29063
-
29064
- Respond with ONLY a single digit (1-5).`;
29065
- function workerJudgeUser(reference, candidate) {
29066
- return `<reference>
29067
- ${reference}
29068
- </reference>
29069
-
29070
- <candidate>
29071
- ${candidate}
29072
- </candidate>`;
29073
- }
29074
- function parseJudgeScore(response) {
29075
- const match = response.trim().match(/^([1-5])/);
29076
- if (!match) return null;
29077
- return parseInt(match[1], 10);
29078
- }
29079
- async function runValidation(input) {
29080
- const { llm, candidates, referenceObservations, sourceMessagesText, date: date5 } = input;
29081
- const userPrompt = distillationUser({
29082
- messages: sourceMessagesText,
29083
- date: date5
29084
- });
29085
- for (const candidate of candidates) {
29086
- if (candidate.id === input.sessionModelID) continue;
29087
- let candidateObservations = null;
29088
- try {
29089
- const raw = await llm.prompt(DISTILLATION_SYSTEM, userPrompt, {
29090
- model: { providerID: candidate.providerID, modelID: candidate.id },
29091
- workerID: "lore-distill",
29092
- thinking: false
29093
- });
29094
- if (raw) {
29095
- const match = raw.match(/<observations>([\s\S]*?)<\/observations>/);
29096
- candidateObservations = match ? match[1].trim() : raw.trim();
29097
- }
29098
- } catch (e) {
29099
- warn(`worker model validation: candidate ${candidate.id} failed:`, e);
29100
- continue;
29101
- }
29102
- const structural = structuralCheck(candidateObservations, referenceObservations);
29103
- if (!structural.passed) {
29104
- info(
29105
- `worker model validation: ${candidate.id} failed structural check: ${structural.reason}`
29106
- );
29107
- continue;
29108
- }
29109
- let judgeScore = null;
29110
- try {
29111
- const judgeResponse = await llm.prompt(
29112
- WORKER_JUDGE_SYSTEM,
29113
- workerJudgeUser(referenceObservations, candidateObservations),
29114
- { workerID: "lore-distill", thinking: false }
29115
- // use session model (no model override)
29116
- );
29117
- if (judgeResponse) {
29118
- judgeScore = parseJudgeScore(judgeResponse);
29119
- }
29120
- } catch (e) {
29121
- warn(`worker model validation: judge call failed for ${candidate.id}:`, e);
29122
- }
29123
- if (judgeScore !== null && judgeScore < 3) {
29124
- info(
29125
- `worker model validation: ${candidate.id} failed judge (score=${judgeScore})`
29126
- );
29127
- continue;
29128
- }
29129
- const fingerprint = computeModelFingerprint(
29130
- input.providerID,
29131
- input.sessionModelID,
29132
- candidates.map((c) => c.id)
29133
- );
29134
- const result = {
29135
- modelID: candidate.id,
29136
- providerID: candidate.providerID,
29137
- fingerprint,
29138
- validatedAt: Date.now(),
29139
- judgeScore
29140
- };
29141
- storeValidatedWorkerModel(result);
29142
- info(
29143
- `worker model validated: ${candidate.id} (judge=${judgeScore}) for provider ${input.providerID}`
29144
- );
29145
- return result;
29146
- }
29147
- clearValidatedWorkerModel(input.providerID);
29148
- info(
29149
- `worker model validation: no candidate passed for ${input.providerID} \u2014 cleared stale entry`
29150
- );
29151
- return null;
29152
- }
29153
- function resolveWorkerModel(providerID, configWorkerModel, configModel) {
28993
+ function resolveWorkerModel(_providerID, configWorkerModel, configModel) {
29154
28994
  if (configWorkerModel) return configWorkerModel;
29155
- const validated = getValidatedWorkerModel(providerID);
29156
- const MAX_AGE_MS = 24 * 60 * 60 * 1e3;
29157
- if (validated && Date.now() - validated.validatedAt <= MAX_AGE_MS) {
29158
- return { providerID: validated.providerID, modelID: validated.modelID };
29159
- }
29160
28995
  return configModel;
29161
28996
  }
29162
28997
  export {
@@ -29193,11 +29028,13 @@ export {
29193
29028
  formatKnowledge,
29194
29029
  ftsQuery,
29195
29030
  ftsQueryOr,
29031
+ getInstanceId,
29196
29032
  getLastTransformEstimate,
29197
29033
  getLastTransformedCount,
29198
29034
  getLastTurnAt,
29199
29035
  getLtmBudget,
29200
29036
  getLtmTokens,
29037
+ getMeta,
29201
29038
  h,
29202
29039
  importFromFile,
29203
29040
  importLoreFile,
@@ -29234,6 +29071,7 @@ export {
29234
29071
  setLastTurnAtForTest,
29235
29072
  setLtmTokens,
29236
29073
  setMaxLayer0Tokens,
29074
+ setMeta,
29237
29075
  setModelLimits,
29238
29076
  shouldImport,
29239
29077
  shouldImportLoreFile,