@loreai/core 0.20.2 → 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.map +1 -1
- package/dist/bun/gradient.d.ts +7 -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 +124 -14
- 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.map +1 -1
- package/dist/node/gradient.d.ts +7 -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 +124 -14
- 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.map +1 -1
- package/dist/types/gradient.d.ts +7 -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 +5 -0
- package/src/gradient.ts +27 -12
- package/src/index.ts +2 -0
- package/src/ltm.ts +78 -4
- package/src/prompt.ts +18 -2
package/dist/bun/ltm.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export declare function create(input: {
|
|
|
21
21
|
crossProject?: boolean;
|
|
22
22
|
/** Explicit ID to use — for cross-machine import via agents-file. Defaults to a new UUIDv7. */
|
|
23
23
|
id?: string;
|
|
24
|
+
/** Initial confidence (0.0–1.0). Default 1.0. Controls injection priority for preferences. */
|
|
25
|
+
confidence?: number;
|
|
24
26
|
}): string;
|
|
25
27
|
export declare function update(id: string, input: {
|
|
26
28
|
content?: string;
|
|
@@ -91,6 +93,14 @@ export declare function forSession(projectPath: string, sessionID: string | unde
|
|
|
91
93
|
export declare function all(): KnowledgeEntry[];
|
|
92
94
|
/** Return all cross-project and global (user-level) knowledge entries. */
|
|
93
95
|
export declare function crossProject(): KnowledgeEntry[];
|
|
96
|
+
/**
|
|
97
|
+
* Re-score confidence on preference entries using directive-detection patterns.
|
|
98
|
+
* Only touches entries with confidence = 1.0 (legacy/unscored). Entries already
|
|
99
|
+
* scored by the curator (confidence < 1.0) are left untouched.
|
|
100
|
+
*
|
|
101
|
+
* @returns Count of entries updated.
|
|
102
|
+
*/
|
|
103
|
+
export declare function rerankPreferences(): number;
|
|
94
104
|
export declare function search(input: {
|
|
95
105
|
query: string;
|
|
96
106
|
projectPath?: string;
|
package/dist/bun/ltm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ltm.d.ts","sourceRoot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AS,EAAE,MAAM,GAAG,IAAI,GACvB,KAAK,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAelE;AAED,kDAAkD;AAClD,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAWtE;AAKD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAwBjE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CA2C/E;AAED,sDAAsD;AACtD,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,IAAI,CAGN;AAED,8EAA8E;AAC9E,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAU/E"}
|
package/dist/bun/prompt.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const RECURSIVE_SYSTEM = "You are a memory reflector. You are giv
|
|
|
8
8
|
export declare function recursiveUser(distillations: Array<{
|
|
9
9
|
observations: string;
|
|
10
10
|
}>, previousMeta?: string): string;
|
|
11
|
-
export declare const CURATOR_SYSTEM = "You are a long-term memory curator. Your job is to extract durable knowledge from a conversation that should persist across sessions.\n\nFocus ONLY on knowledge that helps a coding agent work effectively on THIS codebase:\n- Architectural decisions and their rationale (why something was built a certain way)\n- Non-obvious implementation patterns and conventions specific to the project\n- Recurring gotchas, constraints, or traps in the codebase\n- Environment/tooling setup details that affect development\n- Important relationships between components that aren't obvious from reading the code\n- User preferences and working style specific to how they use this project\n- Repeated user instructions \u2014 when the user says things like \"always\", \"never\",\n \"make sure to\", \"don't forget to\", these are high-value preference candidates.\n If you see instruction-like language, prioritize extracting it as a \"preference\" entry.\n These instructions represent how the user wants to work and should persist across sessions.\n\nDo NOT extract:\n- Task-specific details (file currently being edited, current bug being fixed)\n- Temporary state (current branch, in-progress work)\n- Information that will change frequently\n- Ecosystem descriptions, product announcements, or marketing content\n- Business strategy, roadmap, or organizational information\n- Information that's readily available in public documentation or READMEs\n- Knowledge about unrelated projects or repositories unless explicitly cross-project\n- Restatements of what the code obviously does (e.g. \"the auth module handles authentication\")\n\nBREVITY IS CRITICAL \u2014 each entry must be concise:\n- content MUST be under 150 words (~600 characters). Capture ONE specific actionable\n insight in 2-3 sentences. Prefer terse technical language.\n- Each \"gotcha\": one specific trap + its fix in 1-2 sentences\n- Each \"architecture\": one design decision and its key constraint\n- Focus on the actionable insight, not the full story behind it\n- If a pattern requires more detail, split into multiple focused entries (each under 150 words)\n- Omit code examples unless a single short snippet is essential\n- Never include full file contents, large diffs, or complete command outputs\n\nPREFER UPDATES OVER CREATES:\n- Before creating a new entry, always check if an existing entry covers the same system\n or component. Update the existing entry rather than creating a new one.\n- When updating, REPLACE the full content with a concise rewrite \u2014 do not append to\n the existing content or repeat what was already there.\n- If multiple existing entries cover the same system from different angles (e.g. different\n bugs in the same module), consolidate them: update one with merged insights, delete the\n rest. Fewer, denser entries are better than many scattered ones.\n\nCROSS-REFERENCES between entries:\n- When an entry relates to another entry, reference it with [[entry-uuid]] using the entry's ID\n from the existing entries list. This creates navigable links between entries.\n- Only reference entries you can see in the existing entries list \u2014 don't guess IDs.\n- Example: \"Uses the gradient system [[019c904b-791e-772a-ab2b-93ac892a960c]] for context management.\"\n\ncrossProject flag:\n- Default is true \u2014 most useful knowledge is worth sharing across projects\n- 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)\n\nProduce a JSON array of operations:\n[\n {\n \"op\": \"create\",\n \"category\": \"decision\" | \"pattern\" | \"preference\" | \"architecture\" | \"gotcha\",\n \"title\": \"Short descriptive title\",\n \"content\": \"Concise knowledge entry \u2014 under 150 words\",\n \"scope\": \"project\" | \"global\",\n \"crossProject\": true\n },\n {\n \"op\": \"update\",\n \"id\": \"existing-entry-id\",\n \"content\": \"Updated content \u2014 under 150 words\",\n \"confidence\": 0.0-1.0\n },\n {\n \"op\": \"delete\",\n \"id\": \"existing-entry-id\",\n \"reason\": \"Why this is no longer relevant\"\n }\n]\n\nIf nothing warrants extraction, return an empty array: []\n\nOutput ONLY valid JSON. No markdown fences, no explanation, no preamble.";
|
|
11
|
+
export declare const CURATOR_SYSTEM = "You are a long-term memory curator. Your job is to extract durable knowledge from a conversation that should persist across sessions.\n\nFocus ONLY on knowledge that helps a coding agent work effectively on THIS codebase:\n- Architectural decisions and their rationale (why something was built a certain way)\n- Non-obvious implementation patterns and conventions specific to the project\n- Recurring gotchas, constraints, or traps in the codebase\n- Environment/tooling setup details that affect development\n- Important relationships between components that aren't obvious from reading the code\n- User preferences and working style specific to how they use this project\n- Repeated user instructions \u2014 when the user says things like \"always\", \"never\",\n \"make sure to\", \"don't forget to\", these are high-value preference candidates.\n If you see instruction-like language, prioritize extracting it as a \"preference\" entry.\n These instructions represent how the user wants to work and should persist across sessions.\n\nDo NOT extract:\n- Task-specific details (file currently being edited, current bug being fixed)\n- Temporary state (current branch, in-progress work)\n- Information that will change frequently\n- Ecosystem descriptions, product announcements, or marketing content\n- Business strategy, roadmap, or organizational information\n- Information that's readily available in public documentation or READMEs\n- Knowledge about unrelated projects or repositories unless explicitly cross-project\n- Restatements of what the code obviously does (e.g. \"the auth module handles authentication\")\n\nBREVITY IS CRITICAL \u2014 each entry must be concise:\n- content MUST be under 150 words (~600 characters). Capture ONE specific actionable\n insight in 2-3 sentences. Prefer terse technical language.\n- Each \"gotcha\": one specific trap + its fix in 1-2 sentences\n- Each \"architecture\": one design decision and its key constraint\n- Focus on the actionable insight, not the full story behind it\n- If a pattern requires more detail, split into multiple focused entries (each under 150 words)\n- Omit code examples unless a single short snippet is essential\n- Never include full file contents, large diffs, or complete command outputs\n\nPREFER UPDATES OVER CREATES:\n- Before creating a new entry, always check if an existing entry covers the same system\n or component. Update the existing entry rather than creating a new one.\n- When updating, REPLACE the full content with a concise rewrite \u2014 do not append to\n the existing content or repeat what was already there.\n- If multiple existing entries cover the same system from different angles (e.g. different\n bugs in the same module), consolidate them: update one with merged insights, delete the\n rest. Fewer, denser entries are better than many scattered ones.\n\nCROSS-REFERENCES between entries:\n- When an entry relates to another entry, reference it with [[entry-uuid]] using the entry's ID\n from the existing entries list. This creates navigable links between entries.\n- Only reference entries you can see in the existing entries list \u2014 don't guess IDs.\n- Example: \"Uses the gradient system [[019c904b-791e-772a-ab2b-93ac892a960c]] for context management.\"\n\ncrossProject flag:\n- Default is true \u2014 most useful knowledge is worth sharing across projects\n- 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)\n\nConfidence values (0.0\u20131.0) \u2014 determines injection priority when budget is tight:\n- 1.0: Unconditional directive \u2014 user used \"NEVER\", \"ALWAYS\", \"from now on\", or similarly\n absolute language. These must always be respected regardless of context.\n- 0.9: Strong preference \u2014 explicit user preference (\"I prefer\", \"I want\", \"make sure to\",\n \"don't forget to\"). Clear intent but not absolute.\n- 0.8: Moderate preference \u2014 inferred from repeated user behavior or gentle correction across\n sessions. Not explicitly stated as a rule.\n- 0.6: Mild/contextual preference \u2014 may not apply universally. Observed once or context-dependent.\n- For non-preference categories (gotcha, pattern, architecture, decision), confidence reflects\n how well-established the knowledge is: 1.0 = verified/confirmed, 0.8 = high confidence,\n 0.6 = probable but unverified.\n- Default to 1.0 for preferences with strong directive language, 0.8 for other preferences.\n- Always set confidence on create ops \u2014 it determines injection priority.\n\nProduce a JSON array of operations:\n[\n {\n \"op\": \"create\",\n \"category\": \"decision\" | \"pattern\" | \"preference\" | \"architecture\" | \"gotcha\",\n \"title\": \"Short descriptive title\",\n \"content\": \"Concise knowledge entry \u2014 under 150 words\",\n \"scope\": \"project\" | \"global\",\n \"crossProject\": true,\n \"confidence\": 1.0\n },\n {\n \"op\": \"update\",\n \"id\": \"existing-entry-id\",\n \"content\": \"Updated content \u2014 under 150 words\",\n \"confidence\": 0.0-1.0\n },\n {\n \"op\": \"delete\",\n \"id\": \"existing-entry-id\",\n \"reason\": \"Why this is no longer relevant\"\n }\n]\n\nIf nothing warrants extraction, return an empty array: []\n\nOutput ONLY valid JSON. No markdown fences, no explanation, no preamble.";
|
|
12
12
|
export declare function curatorUser(input: {
|
|
13
13
|
messages: string;
|
|
14
14
|
existing: Array<{
|
package/dist/bun/prompt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/prompt.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,mBAAmB,s1OAmHhB,CAAC;AAEjB,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAaT;AAUD,eAAO,MAAM,gBAAgB,mkGAsC2C,CAAC;AAEzE,wBAAgB,aAAa,CAC3B,aAAa,EAAE,KAAK,CAAC;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,EAC9C,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAoBR;AAED,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/prompt.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,mBAAmB,s1OAmHhB,CAAC;AAEjB,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAaT;AAUD,eAAO,MAAM,gBAAgB,mkGAsC2C,CAAC;AAEzE,wBA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,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,EACpE,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAwCR;AAMD,eAAO,MAAM,sBAAsB,ggBASwE,CAAC"}
|
package/dist/node/config.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare const LoreConfig: z.ZodObject<{
|
|
|
13
13
|
raw: z.ZodDefault<z.ZodNumber>;
|
|
14
14
|
output: z.ZodDefault<z.ZodNumber>;
|
|
15
15
|
ltm: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
preferenceLtm: z.ZodDefault<z.ZodNumber>;
|
|
16
17
|
targetCacheReadCostPerTurn: z.ZodDefault<z.ZodNumber>;
|
|
17
18
|
maxLayer0Tokens: z.ZodOptional<z.ZodNumber>;
|
|
18
19
|
targetBustCost: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwOrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAIpD,wBAAgB,MAAM,IAAI,UAAU,CAEnC;AAED,wBAAsB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAajE"}
|
package/dist/node/curator.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curator.d.ts","sourceRoot":"","sources":["../../src/curator.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C,MAAM,MAAM,SAAS,GACjB;IACE,EAAE,EAAE,QAAQ,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"curator.d.ts","sourceRoot":"","sources":["../../src/curator.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C,MAAM,MAAM,SAAS,GACjB;IACE,EAAE,EAAE,QAAQ,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iFAAiF;IACjF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACD;IAAE,EAAE,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GACnE;IAAE,EAAE,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,CAkBlD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,SAAS,EAAE,EAChB,KAAK,EAAE;IACL,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GACA;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAqDvD;AAmBD,wBAAsB,GAAG,CAAC,KAAK,EAAE;IAC/B,GAAG,EAAE,SAAS,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBjE;AA2FD,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,QAMtD;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE;IACvC,GAAG,EAAE,SAAS,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAkChD"}
|
package/dist/node/db.d.ts
CHANGED
|
@@ -130,6 +130,8 @@ export type SessionTrackingState = {
|
|
|
130
130
|
lastKnownInput?: number;
|
|
131
131
|
lastTurnAt?: number;
|
|
132
132
|
lastBustAt?: number;
|
|
133
|
+
parentSessionId?: string | null;
|
|
134
|
+
isSubagent?: boolean;
|
|
133
135
|
};
|
|
134
136
|
/**
|
|
135
137
|
* Persist session tracking state. Ensures the row exists, then updates
|
|
@@ -158,6 +160,8 @@ export type LoadedSessionTracking = {
|
|
|
158
160
|
lastKnownInput: number;
|
|
159
161
|
lastTurnAt: number;
|
|
160
162
|
lastBustAt: number;
|
|
163
|
+
parentSessionId: string | null;
|
|
164
|
+
isSubagent: boolean;
|
|
161
165
|
};
|
|
162
166
|
/**
|
|
163
167
|
* Load persisted session tracking state. Returns null if no row exists.
|
|
@@ -177,6 +181,12 @@ export declare function loadHeaderSessionIndex(): Array<{
|
|
|
177
181
|
headerSessionId: string;
|
|
178
182
|
headerName: string;
|
|
179
183
|
}>;
|
|
184
|
+
/**
|
|
185
|
+
* Load parent→child session mappings from the DB.
|
|
186
|
+
* Returns a map: childSessionId → parentSessionId (Lore internal IDs).
|
|
187
|
+
* Used by the dashboard to build session trees.
|
|
188
|
+
*/
|
|
189
|
+
export declare function loadParentChildMap(): Map<string, string>;
|
|
180
190
|
/** Get a kv_meta value by key. Returns null if not found. */
|
|
181
191
|
export declare function getKV(key: string): string | null;
|
|
182
192
|
/** Set a kv_meta value (upsert). */
|
package/dist/node/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMtC;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAMvE;
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMtC;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,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AkDxC"}
|
package/dist/node/gradient.d.ts
CHANGED
|
@@ -33,10 +33,11 @@ export declare function getTier(tokens: number): number;
|
|
|
33
33
|
*
|
|
34
34
|
* A "bust" is when cache_write > 50% of total input tokens.
|
|
35
35
|
*
|
|
36
|
-
* @param cacheWrite
|
|
37
|
-
* @param cacheRead
|
|
38
|
-
* @param inputTokens -
|
|
39
|
-
*
|
|
36
|
+
* @param cacheWrite - cache_creation_input_tokens from the API response
|
|
37
|
+
* @param cacheRead - cache_read_input_tokens from the API response
|
|
38
|
+
* @param inputTokens - input_tokens from the API response (uncached portion only —
|
|
39
|
+
* Anthropic's input_tokens excludes both cache reads and writes)
|
|
40
|
+
* @param sessionID - session that produced this response
|
|
40
41
|
*/
|
|
41
42
|
export declare function recordCacheUsage(cacheWrite: number, cacheRead: number, inputTokens: number, sessionID?: string): void;
|
|
42
43
|
type DistillationSnapshot = {
|
|
@@ -131,6 +132,8 @@ export declare function getLtmTokens(sessionID?: string): number;
|
|
|
131
132
|
* hook to cap how many tokens formatKnowledge may use.
|
|
132
133
|
*/
|
|
133
134
|
export declare function getLtmBudget(ltmFraction: number): number;
|
|
135
|
+
/** Returns the token budget for stable LTM (preferences). Independent of context-bound LTM budget. */
|
|
136
|
+
export declare const getPreferenceLtmBudget: typeof getLtmBudget;
|
|
134
137
|
export declare function calibrate(actualInput: number, sessionID?: string, messageCount?: number): void;
|
|
135
138
|
export declare function getOverhead(): number;
|
|
136
139
|
/**
|
|
@@ -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;AAyD7C;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAGlE;AAED,2CAA2C;AAC3C,wBAAgB,eA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C;IAIlB,UAAU,EAAE,OAAO,CAAC;IACpB;;oEAEgE;IAChE,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAMF,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAIlE;AA2XD,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/node/index.d.ts
CHANGED
|
@@ -15,10 +15,10 @@ export type { LoreMessage, LoreUserMessage, LoreAssistantMessage, LorePart, Lore
|
|
|
15
15
|
export { isTextPart, isReasoningPart, isToolPart } from "./types";
|
|
16
16
|
export { dataDir } from "./data-dir";
|
|
17
17
|
export { load, config, type LoreConfig } from "./config";
|
|
18
|
-
export { db, dbPath, ensureProject, getLastImportAt, setLastImportAt, isFirstRun, projectId, projectName, projectPath, resolveProjectByRemoteOrPath, mergeProjectInternal, loadForceMinLayer, saveForceMinLayer, saveSessionCosts, loadSessionCosts, loadAllSessionCosts, type SessionCostSnapshot, saveSessionTracking, loadSessionTracking, loadHeaderSessionIndex, type SessionTrackingState, type LoadedSessionTracking, getKV, setKV, getMeta, setMeta, getInstanceId, close, } from "./db";
|
|
18
|
+
export { db, dbPath, ensureProject, getLastImportAt, setLastImportAt, isFirstRun, projectId, projectName, projectPath, resolveProjectByRemoteOrPath, mergeProjectInternal, loadForceMinLayer, saveForceMinLayer, saveSessionCosts, loadSessionCosts, loadAllSessionCosts, type SessionCostSnapshot, saveSessionTracking, loadSessionTracking, loadHeaderSessionIndex, loadParentChildMap, type SessionTrackingState, type LoadedSessionTracking, getKV, setKV, getMeta, setMeta, getInstanceId, close, } from "./db";
|
|
19
19
|
export { normalizeRemoteUrl, getGitRemote, clearGitRemoteCache } from "./git";
|
|
20
20
|
export { enableHostedMode, isHostedMode } from "./hosted";
|
|
21
|
-
export { transform, setModelLimits, setMaxLayer0Tokens, computeLayer0Cap, setCachePricing, getCachePricing, shouldCompress, getTier, recordCacheUsage, needsUrgentDistillation, calibrate, setLtmTokens, getLtmTokens, getLtmBudget, setForceMinLayer, getLastTransformedCount, getLastTransformEstimate, getLastLayer, toolStripAnnotation, onIdleResume, getLastTurnAt, consumeCameOutOfIdle, saveGradientState, setLastTurnAtForTest, inspectSessionState, getConsecutiveBusts, BUST_PRESSURE_THRESHOLD, effectiveMetaThreshold, } from "./gradient";
|
|
21
|
+
export { transform, setModelLimits, setMaxLayer0Tokens, computeLayer0Cap, setCachePricing, getCachePricing, shouldCompress, getTier, recordCacheUsage, needsUrgentDistillation, calibrate, setLtmTokens, getLtmTokens, getLtmBudget, getPreferenceLtmBudget, setForceMinLayer, getLastTransformedCount, getLastTransformEstimate, getLastLayer, toolStripAnnotation, onIdleResume, getLastTurnAt, consumeCameOutOfIdle, saveGradientState, setLastTurnAtForTest, inspectSessionState, getConsecutiveBusts, BUST_PRESSURE_THRESHOLD, effectiveMetaThreshold, } from "./gradient";
|
|
22
22
|
export { formatKnowledge, formatDistillations, DISTILLATION_SYSTEM, distillationUser, RECURSIVE_SYSTEM, recursiveUser, CURATOR_SYSTEM, curatorUser, CONSOLIDATION_SYSTEM, consolidationUser, QUERY_EXPANSION_SYSTEM, COMPACT_SUMMARY_TEMPLATE, buildCompactPrompt, } from "./prompt";
|
|
23
23
|
export { shouldImport, importFromFile, exportToFile, exportLoreFile, importLoreFile, shouldImportLoreFile, loreFileExists, clearLoreFileCache, LORE_FILE, } from "./agents-file";
|
|
24
24
|
export { workerSessionIDs, isWorkerSession } from "./worker";
|
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAWA,OAA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EACxB,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EAGjB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,QAAQ,EACR,UAAU,EACV,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,SAAS,EACT,MAAM,EACN,CAAC,EACD,CAAC,EACD,EAAE,EACF,GAAG,EACH,IAAI,EACJ,CAAC,EACD,IAAI,EACJ,MAAM,EACN,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAC"}
|
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) {
|
|
@@ -31089,6 +31195,7 @@ function sliceTokens(messages, start, end) {
|
|
|
31089
31195
|
function splitSegments(messages, maxTokens) {
|
|
31090
31196
|
const totalTokens = messages.reduce((s, m) => s + m.tokens, 0);
|
|
31091
31197
|
if (totalTokens <= maxTokens) return [messages];
|
|
31198
|
+
if (messages.length <= 1) return [messages];
|
|
31092
31199
|
const splitIdx = findSplitIndex(messages, maxTokens);
|
|
31093
31200
|
const left = messages.slice(0, splitIdx);
|
|
31094
31201
|
const right = messages.slice(splitIdx);
|
|
@@ -31727,7 +31834,8 @@ function applyOps(ops, input) {
|
|
|
31727
31834
|
content: content3,
|
|
31728
31835
|
session: input.sessionID,
|
|
31729
31836
|
scope: op.scope,
|
|
31730
|
-
crossProject: op.crossProject ?? true
|
|
31837
|
+
crossProject: op.crossProject ?? true,
|
|
31838
|
+
confidence: op.confidence
|
|
31731
31839
|
});
|
|
31732
31840
|
idsToSync.push(id);
|
|
31733
31841
|
created++;
|
|
@@ -33968,6 +34076,7 @@ export {
|
|
|
33968
34076
|
getLtmBudget,
|
|
33969
34077
|
getLtmTokens,
|
|
33970
34078
|
getMeta,
|
|
34079
|
+
getPreferenceLtmBudget,
|
|
33971
34080
|
getTier,
|
|
33972
34081
|
h,
|
|
33973
34082
|
importFromFile,
|
|
@@ -33988,6 +34097,7 @@ export {
|
|
|
33988
34097
|
loadAllSessionCosts,
|
|
33989
34098
|
loadForceMinLayer,
|
|
33990
34099
|
loadHeaderSessionIndex,
|
|
34100
|
+
loadParentChildMap,
|
|
33991
34101
|
loadSessionCosts,
|
|
33992
34102
|
loadSessionTracking,
|
|
33993
34103
|
log_exports as log,
|