@loreai/core 0.20.1 → 0.21.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/config.d.ts +1 -0
- package/dist/bun/config.d.ts.map +1 -1
- package/dist/bun/curator.d.ts +2 -0
- package/dist/bun/curator.d.ts.map +1 -1
- package/dist/bun/db.d.ts +10 -0
- package/dist/bun/db.d.ts.map +1 -1
- package/dist/bun/distillation.d.ts +4 -0
- package/dist/bun/distillation.d.ts.map +1 -1
- package/dist/bun/gradient.d.ts +26 -4
- package/dist/bun/gradient.d.ts.map +1 -1
- package/dist/bun/index.d.ts +2 -2
- package/dist/bun/index.d.ts.map +1 -1
- package/dist/bun/index.js +150 -17
- package/dist/bun/index.js.map +3 -3
- package/dist/bun/ltm.d.ts +10 -0
- package/dist/bun/ltm.d.ts.map +1 -1
- package/dist/bun/prompt.d.ts +1 -1
- package/dist/bun/prompt.d.ts.map +1 -1
- package/dist/node/config.d.ts +1 -0
- package/dist/node/config.d.ts.map +1 -1
- package/dist/node/curator.d.ts +2 -0
- package/dist/node/curator.d.ts.map +1 -1
- package/dist/node/db.d.ts +10 -0
- package/dist/node/db.d.ts.map +1 -1
- package/dist/node/distillation.d.ts +4 -0
- package/dist/node/distillation.d.ts.map +1 -1
- package/dist/node/gradient.d.ts +26 -4
- package/dist/node/gradient.d.ts.map +1 -1
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +150 -17
- package/dist/node/index.js.map +3 -3
- package/dist/node/ltm.d.ts +10 -0
- package/dist/node/ltm.d.ts.map +1 -1
- package/dist/node/prompt.d.ts +1 -1
- package/dist/node/prompt.d.ts.map +1 -1
- package/dist/types/config.d.ts +1 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/curator.d.ts +2 -0
- package/dist/types/curator.d.ts.map +1 -1
- package/dist/types/db.d.ts +10 -0
- package/dist/types/db.d.ts.map +1 -1
- package/dist/types/distillation.d.ts +4 -0
- package/dist/types/distillation.d.ts.map +1 -1
- package/dist/types/gradient.d.ts +26 -4
- package/dist/types/gradient.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/ltm.d.ts +10 -0
- package/dist/types/ltm.d.ts.map +1 -1
- package/dist/types/prompt.d.ts +1 -1
- package/dist/types/prompt.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/config.ts +4 -2
- package/src/curator.ts +3 -0
- package/src/db.ts +52 -1
- package/src/distillation.ts +17 -1
- package/src/gradient.ts +65 -13
- package/src/index.ts +5 -0
- package/src/ltm.ts +78 -4
- package/src/prompt.ts +18 -2
package/dist/node/index.js
CHANGED
|
@@ -816,6 +816,17 @@ var MIGRATIONS = [
|
|
|
816
816
|
);
|
|
817
817
|
CREATE INDEX IF NOT EXISTS idx_dedup_feedback_project
|
|
818
818
|
ON dedup_feedback(project_id);
|
|
819
|
+
`,
|
|
820
|
+
`
|
|
821
|
+
-- Version 26: Persist sub-agent parent\u2013child session relationships.
|
|
822
|
+
-- parent_session_id: Lore internal session ID of the parent session
|
|
823
|
+
-- (resolved from the x-parent-session-id header at detection time).
|
|
824
|
+
-- NULL for root (non-sub-agent) sessions.
|
|
825
|
+
-- is_subagent: boolean flag (1 = sub-agent) so the flag survives
|
|
826
|
+
-- gateway restarts without requiring the header again.
|
|
827
|
+
ALTER TABLE session_state ADD COLUMN parent_session_id TEXT;
|
|
828
|
+
ALTER TABLE session_state ADD COLUMN is_subagent INTEGER NOT NULL DEFAULT 0;
|
|
829
|
+
CREATE INDEX IF NOT EXISTS idx_session_state_parent ON session_state(parent_session_id);
|
|
819
830
|
`
|
|
820
831
|
];
|
|
821
832
|
function dbPath() {
|
|
@@ -1226,6 +1237,14 @@ function saveSessionTracking(sessionID, state) {
|
|
|
1226
1237
|
sets.push("last_bust_at = ?");
|
|
1227
1238
|
vals.push(state.lastBustAt);
|
|
1228
1239
|
}
|
|
1240
|
+
if (state.parentSessionId !== void 0) {
|
|
1241
|
+
sets.push("parent_session_id = ?");
|
|
1242
|
+
vals.push(state.parentSessionId);
|
|
1243
|
+
}
|
|
1244
|
+
if (state.isSubagent !== void 0) {
|
|
1245
|
+
sets.push("is_subagent = ?");
|
|
1246
|
+
vals.push(state.isSubagent ? 1 : 0);
|
|
1247
|
+
}
|
|
1229
1248
|
db().query(
|
|
1230
1249
|
"UPDATE session_state SET " + sets.join(", ") + " WHERE session_id = ?"
|
|
1231
1250
|
).run(...vals, sessionID);
|
|
@@ -1238,7 +1257,8 @@ function loadSessionTracking(sessionID) {
|
|
|
1238
1257
|
fingerprint, header_session_id, header_name,
|
|
1239
1258
|
resolved_conversation_ttl, warmup_state,
|
|
1240
1259
|
dynamic_context_cap, bust_rate_ema, inter_bust_interval_ema,
|
|
1241
|
-
last_layer, last_known_input, last_turn_at, last_bust_at
|
|
1260
|
+
last_layer, last_known_input, last_turn_at, last_bust_at,
|
|
1261
|
+
parent_session_id, is_subagent
|
|
1242
1262
|
FROM session_state WHERE session_id = ?`
|
|
1243
1263
|
).get(sessionID);
|
|
1244
1264
|
if (!row) return null;
|
|
@@ -1262,7 +1282,9 @@ function loadSessionTracking(sessionID) {
|
|
|
1262
1282
|
lastLayer: row.last_layer,
|
|
1263
1283
|
lastKnownInput: row.last_known_input,
|
|
1264
1284
|
lastTurnAt: row.last_turn_at,
|
|
1265
|
-
lastBustAt: row.last_bust_at
|
|
1285
|
+
lastBustAt: row.last_bust_at,
|
|
1286
|
+
parentSessionId: row.parent_session_id,
|
|
1287
|
+
isSubagent: row.is_subagent === 1
|
|
1266
1288
|
};
|
|
1267
1289
|
}
|
|
1268
1290
|
function loadHeaderSessionIndex() {
|
|
@@ -1277,6 +1299,18 @@ function loadHeaderSessionIndex() {
|
|
|
1277
1299
|
headerName: row.header_name
|
|
1278
1300
|
}));
|
|
1279
1301
|
}
|
|
1302
|
+
function loadParentChildMap() {
|
|
1303
|
+
const rows = db().query(
|
|
1304
|
+
`SELECT session_id, parent_session_id
|
|
1305
|
+
FROM session_state
|
|
1306
|
+
WHERE parent_session_id IS NOT NULL`
|
|
1307
|
+
).all();
|
|
1308
|
+
const map5 = /* @__PURE__ */ new Map();
|
|
1309
|
+
for (const row of rows) {
|
|
1310
|
+
map5.set(row.session_id, row.parent_session_id);
|
|
1311
|
+
}
|
|
1312
|
+
return map5;
|
|
1313
|
+
}
|
|
1280
1314
|
function getKV(key) {
|
|
1281
1315
|
const row = db().query("SELECT value FROM kv_meta WHERE key = ?").get(key);
|
|
1282
1316
|
return row?.value ?? null;
|
|
@@ -12293,6 +12327,20 @@ crossProject flag:
|
|
|
12293
12327
|
- Default is true \u2014 most useful knowledge is worth sharing across projects
|
|
12294
12328
|
- Set crossProject to false for things that are meaningless outside this specific repo (e.g. a config path, a project-local naming convention that conflicts with your usual style)
|
|
12295
12329
|
|
|
12330
|
+
Confidence values (0.0\u20131.0) \u2014 determines injection priority when budget is tight:
|
|
12331
|
+
- 1.0: Unconditional directive \u2014 user used "NEVER", "ALWAYS", "from now on", or similarly
|
|
12332
|
+
absolute language. These must always be respected regardless of context.
|
|
12333
|
+
- 0.9: Strong preference \u2014 explicit user preference ("I prefer", "I want", "make sure to",
|
|
12334
|
+
"don't forget to"). Clear intent but not absolute.
|
|
12335
|
+
- 0.8: Moderate preference \u2014 inferred from repeated user behavior or gentle correction across
|
|
12336
|
+
sessions. Not explicitly stated as a rule.
|
|
12337
|
+
- 0.6: Mild/contextual preference \u2014 may not apply universally. Observed once or context-dependent.
|
|
12338
|
+
- For non-preference categories (gotcha, pattern, architecture, decision), confidence reflects
|
|
12339
|
+
how well-established the knowledge is: 1.0 = verified/confirmed, 0.8 = high confidence,
|
|
12340
|
+
0.6 = probable but unverified.
|
|
12341
|
+
- Default to 1.0 for preferences with strong directive language, 0.8 for other preferences.
|
|
12342
|
+
- Always set confidence on create ops \u2014 it determines injection priority.
|
|
12343
|
+
|
|
12296
12344
|
Produce a JSON array of operations:
|
|
12297
12345
|
[
|
|
12298
12346
|
{
|
|
@@ -12301,7 +12349,8 @@ Produce a JSON array of operations:
|
|
|
12301
12349
|
"title": "Short descriptive title",
|
|
12302
12350
|
"content": "Concise knowledge entry \u2014 under 150 words",
|
|
12303
12351
|
"scope": "project" | "global",
|
|
12304
|
-
"crossProject": true
|
|
12352
|
+
"crossProject": true,
|
|
12353
|
+
"confidence": 1.0
|
|
12305
12354
|
},
|
|
12306
12355
|
{
|
|
12307
12356
|
"op": "update",
|
|
@@ -12339,7 +12388,8 @@ IMPORTANT:
|
|
|
12339
12388
|
4. Only create a new entry for genuinely distinct knowledge with no existing home.
|
|
12340
12389
|
5. Keep all entries under 150 words. If an existing entry is too long, use an update op to trim it.
|
|
12341
12390
|
6. Pay special attention to user instructions ("always do X", "never do Y", "make sure to X").
|
|
12342
|
-
These are strong signals for "preference" entries with high confidence
|
|
12391
|
+
These are strong signals for "preference" entries with high confidence (1.0 for absolute
|
|
12392
|
+
directives like "never"/"always", 0.9 for explicit preferences like "I prefer").`;
|
|
12343
12393
|
}
|
|
12344
12394
|
var CONSOLIDATION_SYSTEM = `You are a long-term memory curator performing a consolidation pass. The knowledge base has grown too large and needs to be trimmed.
|
|
12345
12395
|
|
|
@@ -26617,8 +26667,10 @@ var LoreConfig = external_exports.object({
|
|
|
26617
26667
|
distilled: external_exports.number().min(0.05).max(0.5).default(0.25),
|
|
26618
26668
|
raw: external_exports.number().min(0.1).max(0.7).default(0.4),
|
|
26619
26669
|
output: external_exports.number().min(0.1).max(0.5).default(0.25),
|
|
26620
|
-
/** Max fraction of usable context reserved for LTM system-prompt injection. Default: 0.05 (5%). */
|
|
26670
|
+
/** Max fraction of usable context reserved for context-bound LTM system-prompt injection. Default: 0.05 (5%). */
|
|
26621
26671
|
ltm: external_exports.number().min(0.02).max(0.3).default(0.05),
|
|
26672
|
+
/** Fraction of usable context for stable LTM (preferences). Independent of `ltm`. Default: 0.02 (2%). */
|
|
26673
|
+
preferenceLtm: external_exports.number().min(0.01).max(0.1).default(0.02),
|
|
26622
26674
|
/** Per-turn cache-read cost target in dollars. Controls when layer 0 (full
|
|
26623
26675
|
* passthrough) escalates to layer 1 (compressed). The cap is derived as:
|
|
26624
26676
|
* maxLayer0Tokens = max(target / model.cost.cache.read, 40K).
|
|
@@ -26633,7 +26685,7 @@ var LoreConfig = external_exports.object({
|
|
|
26633
26685
|
targetBustCost: external_exports.number().min(0).default(1).optional(),
|
|
26634
26686
|
/** @deprecated Ignored. Tier-based bust-vs-continue replaces static cap. */
|
|
26635
26687
|
maxContextTokens: external_exports.number().min(0).optional()
|
|
26636
|
-
}).default({ distilled: 0.25, raw: 0.4, output: 0.25, ltm: 0.05, targetCacheReadCostPerTurn: 0.1 }),
|
|
26688
|
+
}).default({ distilled: 0.25, raw: 0.4, output: 0.25, ltm: 0.05, preferenceLtm: 0.02, targetCacheReadCostPerTurn: 0.1 }),
|
|
26637
26689
|
/**
|
|
26638
26690
|
* Cold-cache idle-resume handling.
|
|
26639
26691
|
*
|
|
@@ -27779,6 +27831,7 @@ __export(ltm_exports, {
|
|
|
27779
27831
|
recordDedupFeedback: () => recordDedupFeedback,
|
|
27780
27832
|
recordDedupResultFeedback: () => recordDedupResultFeedback,
|
|
27781
27833
|
remove: () => remove,
|
|
27834
|
+
rerankPreferences: () => rerankPreferences,
|
|
27782
27835
|
resolveRef: () => resolveRef2,
|
|
27783
27836
|
saveCalibratedThreshold: () => saveCalibratedThreshold,
|
|
27784
27837
|
search: () => search3,
|
|
@@ -28363,28 +28416,33 @@ function create(input) {
|
|
|
28363
28416
|
).get(pid, input.title) : db().query(
|
|
28364
28417
|
"SELECT id FROM knowledge WHERE project_id IS NULL AND LOWER(title) = LOWER(?) AND confidence > 0 LIMIT 1"
|
|
28365
28418
|
).get(input.title);
|
|
28419
|
+
const dedupUpdate = {
|
|
28420
|
+
content: input.content,
|
|
28421
|
+
...input.confidence != null ? { confidence: input.confidence } : {}
|
|
28422
|
+
};
|
|
28366
28423
|
if (existing) {
|
|
28367
|
-
update(existing.id,
|
|
28424
|
+
update(existing.id, dedupUpdate);
|
|
28368
28425
|
return existing.id;
|
|
28369
28426
|
}
|
|
28370
28427
|
const crossExisting = db().query(
|
|
28371
28428
|
"SELECT id FROM knowledge WHERE cross_project = 1 AND LOWER(title) = LOWER(?) AND confidence > 0 LIMIT 1"
|
|
28372
28429
|
).get(input.title);
|
|
28373
28430
|
if (crossExisting) {
|
|
28374
|
-
update(crossExisting.id,
|
|
28431
|
+
update(crossExisting.id, dedupUpdate);
|
|
28375
28432
|
return crossExisting.id;
|
|
28376
28433
|
}
|
|
28377
28434
|
const fuzzyMatch = findFuzzyDuplicate({ title: input.title, projectId: pid });
|
|
28378
28435
|
if (fuzzyMatch) {
|
|
28379
|
-
update(fuzzyMatch.id,
|
|
28436
|
+
update(fuzzyMatch.id, dedupUpdate);
|
|
28380
28437
|
return fuzzyMatch.id;
|
|
28381
28438
|
}
|
|
28382
28439
|
}
|
|
28383
28440
|
const id = input.id ?? uuidv72();
|
|
28384
28441
|
const now = Date.now();
|
|
28442
|
+
const confidence = input.confidence != null ? Math.max(0, Math.min(1, input.confidence)) : 1;
|
|
28385
28443
|
db().query(
|
|
28386
28444
|
`INSERT INTO knowledge (id, project_id, category, title, content, source_session, cross_project, confidence, created_at, updated_at)
|
|
28387
|
-
VALUES (?, ?, ?, ?, ?, ?, ?,
|
|
28445
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
28388
28446
|
).run(
|
|
28389
28447
|
id,
|
|
28390
28448
|
pid,
|
|
@@ -28393,6 +28451,7 @@ function create(input) {
|
|
|
28393
28451
|
input.content,
|
|
28394
28452
|
input.session ?? null,
|
|
28395
28453
|
crossProject2 ? 1 : 0,
|
|
28454
|
+
confidence,
|
|
28396
28455
|
now,
|
|
28397
28456
|
now
|
|
28398
28457
|
);
|
|
@@ -28543,6 +28602,24 @@ async function forSession(projectPath2, sessionID, maxTokens, options) {
|
|
|
28543
28602
|
ORDER BY confidence DESC, updated_at DESC`
|
|
28544
28603
|
).all(...categoryParams);
|
|
28545
28604
|
if (!crossEntries.length && !projectEntries.length) return [];
|
|
28605
|
+
const isPreferenceOnly = categoryFilter?.length === 1 && categoryFilter[0] === "preference";
|
|
28606
|
+
if (isPreferenceOnly) {
|
|
28607
|
+
const allPrefs = [...projectEntries, ...crossEntries];
|
|
28608
|
+
allPrefs.sort(
|
|
28609
|
+
(a, b) => a.confidence !== b.confidence ? b.confidence - a.confidence : b.updated_at - a.updated_at
|
|
28610
|
+
);
|
|
28611
|
+
const HEADER_OVERHEAD_TOKENS2 = 15;
|
|
28612
|
+
let used2 = HEADER_OVERHEAD_TOKENS2;
|
|
28613
|
+
const result2 = [];
|
|
28614
|
+
for (const entry of allPrefs) {
|
|
28615
|
+
if (used2 >= maxTokens) break;
|
|
28616
|
+
const cost = estimateTokens3(entry.title + entry.content) + 10;
|
|
28617
|
+
if (used2 + cost > maxTokens) continue;
|
|
28618
|
+
result2.push(entry);
|
|
28619
|
+
used2 += cost;
|
|
28620
|
+
}
|
|
28621
|
+
return result2;
|
|
28622
|
+
}
|
|
28546
28623
|
let sessionContext = "";
|
|
28547
28624
|
if (sessionID) {
|
|
28548
28625
|
const distRow = db().query(
|
|
@@ -28680,6 +28757,28 @@ function crossProject() {
|
|
|
28680
28757
|
ORDER BY confidence DESC, updated_at DESC`
|
|
28681
28758
|
).all();
|
|
28682
28759
|
}
|
|
28760
|
+
function rerankPreferences() {
|
|
28761
|
+
const prefs = db().query(`SELECT ${KNOWLEDGE_COLS} FROM knowledge WHERE category = 'preference' AND confidence = 1.0`).all();
|
|
28762
|
+
const STRONG_DIRECTIVE_RE = /\b(never|always|must not|must)\b/i;
|
|
28763
|
+
const EXPLICIT_PREF_RE = /\b(I (?:want|need|prefer|expect)|make sure to|don'?t forget)\b/i;
|
|
28764
|
+
let updated = 0;
|
|
28765
|
+
for (const entry of prefs) {
|
|
28766
|
+
const text4 = entry.title + " " + entry.content;
|
|
28767
|
+
let newConfidence;
|
|
28768
|
+
if (STRONG_DIRECTIVE_RE.test(text4)) {
|
|
28769
|
+
newConfidence = 1;
|
|
28770
|
+
} else if (EXPLICIT_PREF_RE.test(text4)) {
|
|
28771
|
+
newConfidence = 0.9;
|
|
28772
|
+
} else {
|
|
28773
|
+
newConfidence = 0.8;
|
|
28774
|
+
}
|
|
28775
|
+
if (newConfidence !== entry.confidence) {
|
|
28776
|
+
update(entry.id, { confidence: newConfidence });
|
|
28777
|
+
updated++;
|
|
28778
|
+
}
|
|
28779
|
+
}
|
|
28780
|
+
return updated;
|
|
28781
|
+
}
|
|
28683
28782
|
function searchLike2(input) {
|
|
28684
28783
|
const terms = input.query.toLowerCase().split(/\s+/).filter((t2) => t2.length > 2);
|
|
28685
28784
|
if (!terms.length) return [];
|
|
@@ -29972,13 +30071,20 @@ function getTier(tokens) {
|
|
|
29972
30071
|
function recordCacheUsage(cacheWrite, cacheRead, inputTokens, sessionID) {
|
|
29973
30072
|
if (!sessionID) return;
|
|
29974
30073
|
const state = getSessionState(sessionID);
|
|
29975
|
-
const total =
|
|
30074
|
+
const total = cacheWrite + cacheRead + inputTokens;
|
|
29976
30075
|
if (total > 0) {
|
|
29977
|
-
|
|
30076
|
+
const bustRatio = cacheWrite / total;
|
|
30077
|
+
const prev = state.consecutiveBusts;
|
|
30078
|
+
if (bustRatio > 0.5) {
|
|
29978
30079
|
state.consecutiveBusts++;
|
|
29979
30080
|
} else {
|
|
29980
30081
|
state.consecutiveBusts = 0;
|
|
29981
30082
|
}
|
|
30083
|
+
if (state.consecutiveBusts !== prev) {
|
|
30084
|
+
info(
|
|
30085
|
+
`bust-tracker: session=${sessionID.slice(0, 16)} ratio=${bustRatio.toFixed(3)} (write=${cacheWrite} read=${cacheRead} uncached=${inputTokens}) busts=${prev}\u2192${state.consecutiveBusts}`
|
|
30086
|
+
);
|
|
30087
|
+
}
|
|
29982
30088
|
}
|
|
29983
30089
|
}
|
|
29984
30090
|
var FIRST_TURN_OVERHEAD = 15e3;
|
|
@@ -30015,7 +30121,6 @@ function getSessionState(sessionID) {
|
|
|
30015
30121
|
state.lastLayer = persisted.lastLayer;
|
|
30016
30122
|
state.lastKnownInput = persisted.lastKnownInput;
|
|
30017
30123
|
state.lastTurnAt = persisted.lastTurnAt;
|
|
30018
|
-
state.consecutiveBusts = persisted.dynamicContextCap;
|
|
30019
30124
|
}
|
|
30020
30125
|
sessionStates.set(sessionID, state);
|
|
30021
30126
|
}
|
|
@@ -30074,6 +30179,7 @@ function getLtmBudget(ltmFraction) {
|
|
|
30074
30179
|
const usable = Math.max(0, contextLimit - outputReserved - overhead);
|
|
30075
30180
|
return Math.floor(usable * ltmFraction);
|
|
30076
30181
|
}
|
|
30182
|
+
var getPreferenceLtmBudget = getLtmBudget;
|
|
30077
30183
|
function calibrate(actualInput, sessionID, messageCount) {
|
|
30078
30184
|
const messageEstimate = sessionID ? getSessionState(sessionID).lastTransformEstimate : 0;
|
|
30079
30185
|
if (messageEstimate > 0 || actualInput === 0) {
|
|
@@ -30125,6 +30231,13 @@ function inspectSessionState(sessionID) {
|
|
|
30125
30231
|
consecutiveBusts: state.consecutiveBusts
|
|
30126
30232
|
};
|
|
30127
30233
|
}
|
|
30234
|
+
function getConsecutiveBusts(sessionID) {
|
|
30235
|
+
return sessionStates.get(sessionID)?.consecutiveBusts ?? 0;
|
|
30236
|
+
}
|
|
30237
|
+
var BUST_PRESSURE_THRESHOLD = 3;
|
|
30238
|
+
function effectiveMetaThreshold(busts, configThreshold) {
|
|
30239
|
+
return busts >= BUST_PRESSURE_THRESHOLD ? Math.max(3, Math.floor(configThreshold / 4)) : configThreshold;
|
|
30240
|
+
}
|
|
30128
30241
|
function setLastTurnAtForTest(sessionID, ms) {
|
|
30129
30242
|
getSessionState(sessionID).lastTurnAt = ms;
|
|
30130
30243
|
}
|
|
@@ -30634,7 +30747,8 @@ function transformInner(input) {
|
|
|
30634
30747
|
usable,
|
|
30635
30748
|
distilledBudget,
|
|
30636
30749
|
rawBudget,
|
|
30637
|
-
refreshLtm: false
|
|
30750
|
+
refreshLtm: false,
|
|
30751
|
+
unsustainable: sid ? getSessionState(sid).consecutiveBusts >= 5 : false
|
|
30638
30752
|
};
|
|
30639
30753
|
}
|
|
30640
30754
|
if (effectiveMinLayer === 0 && layer0Input > layer0Ceiling && layer0Input <= maxInput && sid) {
|
|
@@ -30706,7 +30820,15 @@ function transformInner(input) {
|
|
|
30706
30820
|
if (sid && (s > 0 || cached2.tokens === 0)) {
|
|
30707
30821
|
urgentDistillationMap.set(sid, true);
|
|
30708
30822
|
}
|
|
30709
|
-
return {
|
|
30823
|
+
return {
|
|
30824
|
+
...result,
|
|
30825
|
+
layer: stageLayer,
|
|
30826
|
+
usable,
|
|
30827
|
+
distilledBudget,
|
|
30828
|
+
rawBudget,
|
|
30829
|
+
refreshLtm: false,
|
|
30830
|
+
unsustainable: sid ? getSessionState(sid).consecutiveBusts >= 5 : false
|
|
30831
|
+
};
|
|
30710
30832
|
}
|
|
30711
30833
|
}
|
|
30712
30834
|
sessState.rawWindowCache = null;
|
|
@@ -31073,6 +31195,7 @@ function sliceTokens(messages, start, end) {
|
|
|
31073
31195
|
function splitSegments(messages, maxTokens) {
|
|
31074
31196
|
const totalTokens = messages.reduce((s, m) => s + m.tokens, 0);
|
|
31075
31197
|
if (totalTokens <= maxTokens) return [messages];
|
|
31198
|
+
if (messages.length <= 1) return [messages];
|
|
31076
31199
|
const splitIdx = findSplitIndex(messages, maxTokens);
|
|
31077
31200
|
const left = messages.slice(0, splitIdx);
|
|
31078
31201
|
const right = messages.slice(splitIdx);
|
|
@@ -31328,7 +31451,11 @@ async function runInner(input) {
|
|
|
31328
31451
|
}
|
|
31329
31452
|
}
|
|
31330
31453
|
}
|
|
31331
|
-
|
|
31454
|
+
const effectiveMetaThreshold2 = Math.max(
|
|
31455
|
+
2,
|
|
31456
|
+
input.metaThresholdOverride ?? cfg.distillation.metaThreshold
|
|
31457
|
+
);
|
|
31458
|
+
if (!input.skipMeta && gen0Count(input.projectPath, input.sessionID) >= effectiveMetaThreshold2) {
|
|
31332
31459
|
await metaDistillInner({
|
|
31333
31460
|
llm: input.llm,
|
|
31334
31461
|
projectPath: input.projectPath,
|
|
@@ -31707,7 +31834,8 @@ function applyOps(ops, input) {
|
|
|
31707
31834
|
content: content3,
|
|
31708
31835
|
session: input.sessionID,
|
|
31709
31836
|
scope: op.scope,
|
|
31710
|
-
crossProject: op.crossProject ?? true
|
|
31837
|
+
crossProject: op.crossProject ?? true,
|
|
31838
|
+
confidence: op.confidence
|
|
31711
31839
|
});
|
|
31712
31840
|
idsToSync.push(id);
|
|
31713
31841
|
created++;
|
|
@@ -33891,6 +34019,7 @@ function resolveWorkerModel(_providerID, configWorkerModel, configModel, costAwa
|
|
|
33891
34019
|
return configModel;
|
|
33892
34020
|
}
|
|
33893
34021
|
export {
|
|
34022
|
+
BUST_PRESSURE_THRESHOLD,
|
|
33894
34023
|
COMPACT_SUMMARY_TEMPLATE,
|
|
33895
34024
|
CONSOLIDATION_SYSTEM,
|
|
33896
34025
|
CURATOR_SYSTEM,
|
|
@@ -33919,6 +34048,7 @@ export {
|
|
|
33919
34048
|
dbPath,
|
|
33920
34049
|
distillation_exports as distillation,
|
|
33921
34050
|
distillationUser,
|
|
34051
|
+
effectiveMetaThreshold,
|
|
33922
34052
|
embedding_exports as embedding,
|
|
33923
34053
|
embedding_vendor_exports as embeddingVendor,
|
|
33924
34054
|
enableHostedMode,
|
|
@@ -33934,6 +34064,7 @@ export {
|
|
|
33934
34064
|
ftsQueryOr,
|
|
33935
34065
|
ftsQueryRelaxed,
|
|
33936
34066
|
getCachePricing,
|
|
34067
|
+
getConsecutiveBusts,
|
|
33937
34068
|
getGitRemote,
|
|
33938
34069
|
getInstanceId,
|
|
33939
34070
|
getKV,
|
|
@@ -33945,6 +34076,7 @@ export {
|
|
|
33945
34076
|
getLtmBudget,
|
|
33946
34077
|
getLtmTokens,
|
|
33947
34078
|
getMeta,
|
|
34079
|
+
getPreferenceLtmBudget,
|
|
33948
34080
|
getTier,
|
|
33949
34081
|
h,
|
|
33950
34082
|
importFromFile,
|
|
@@ -33965,6 +34097,7 @@ export {
|
|
|
33965
34097
|
loadAllSessionCosts,
|
|
33966
34098
|
loadForceMinLayer,
|
|
33967
34099
|
loadHeaderSessionIndex,
|
|
34100
|
+
loadParentChildMap,
|
|
33968
34101
|
loadSessionCosts,
|
|
33969
34102
|
loadSessionTracking,
|
|
33970
34103
|
log_exports as log,
|