@loreai/core 0.10.2 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bun/config.d.ts +8 -0
- package/dist/bun/config.d.ts.map +1 -1
- package/dist/bun/db.d.ts.map +1 -1
- package/dist/bun/distillation.d.ts +74 -2
- package/dist/bun/distillation.d.ts.map +1 -1
- package/dist/bun/embedding.d.ts.map +1 -1
- package/dist/bun/gradient.d.ts +72 -0
- package/dist/bun/gradient.d.ts.map +1 -1
- package/dist/bun/index.d.ts +4 -2
- package/dist/bun/index.d.ts.map +1 -1
- package/dist/bun/index.js +554 -76
- package/dist/bun/index.js.map +4 -4
- package/dist/bun/prompt.d.ts +8 -2
- package/dist/bun/prompt.d.ts.map +1 -1
- package/dist/bun/temporal.d.ts +31 -0
- package/dist/bun/temporal.d.ts.map +1 -1
- package/dist/bun/types.d.ts +9 -0
- package/dist/bun/types.d.ts.map +1 -1
- package/dist/bun/worker-model.d.ts +90 -0
- package/dist/bun/worker-model.d.ts.map +1 -0
- package/dist/node/config.d.ts +8 -0
- package/dist/node/config.d.ts.map +1 -1
- package/dist/node/db.d.ts.map +1 -1
- package/dist/node/distillation.d.ts +74 -2
- package/dist/node/distillation.d.ts.map +1 -1
- package/dist/node/embedding.d.ts.map +1 -1
- package/dist/node/gradient.d.ts +72 -0
- package/dist/node/gradient.d.ts.map +1 -1
- package/dist/node/index.d.ts +4 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +554 -76
- package/dist/node/index.js.map +4 -4
- package/dist/node/prompt.d.ts +8 -2
- package/dist/node/prompt.d.ts.map +1 -1
- package/dist/node/temporal.d.ts +31 -0
- package/dist/node/temporal.d.ts.map +1 -1
- package/dist/node/types.d.ts +9 -0
- package/dist/node/types.d.ts.map +1 -1
- package/dist/node/worker-model.d.ts +90 -0
- package/dist/node/worker-model.d.ts.map +1 -0
- package/dist/types/config.d.ts +8 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/db.d.ts.map +1 -1
- package/dist/types/distillation.d.ts +74 -2
- package/dist/types/distillation.d.ts.map +1 -1
- package/dist/types/embedding.d.ts.map +1 -1
- package/dist/types/gradient.d.ts +72 -0
- package/dist/types/gradient.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/prompt.d.ts +8 -2
- package/dist/types/prompt.d.ts.map +1 -1
- package/dist/types/temporal.d.ts +31 -0
- package/dist/types/temporal.d.ts.map +1 -1
- package/dist/types/types.d.ts +9 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/worker-model.d.ts +90 -0
- package/dist/types/worker-model.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/config.ts +53 -6
- package/src/db.ts +68 -6
- package/src/distillation.ts +225 -28
- package/src/embedding.ts +7 -0
- package/src/gradient.ts +305 -17
- package/src/index.ts +16 -0
- package/src/lat-reader.ts +4 -4
- package/src/ltm.ts +17 -17
- package/src/prompt.ts +101 -0
- package/src/recall.ts +4 -4
- package/src/temporal.ts +41 -10
- package/src/types.ts +9 -0
- package/src/worker-model.ts +264 -0
package/dist/bun/prompt.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ export declare function distillationUser(input: {
|
|
|
4
4
|
date: string;
|
|
5
5
|
messages: string;
|
|
6
6
|
}): string;
|
|
7
|
-
export declare const RECURSIVE_SYSTEM = "You are a memory reflector. You are given a set of observations from multiple conversation segments. Your job is to consolidate them into a structured working context that will become the agent's entire memory going forward.\n\nIMPORTANT: Your reflections ARE the entirety of the assistant's memory. Any information you omit is permanently forgotten. Do not leave out anything important.\n\nSTRUCTURE your output into these sections \u2014 each section supports a different type of downstream query:\n\n### Current State\nWhat is in progress right now? Active branches, open files, current task, blockers.\nThis section answers: \"What was I working on?\"\n\n### Key Decisions\nWhat was decided and why? Include the alternatives considered and rationale.\nThis section answers: \"Why did we choose approach X?\" and \"What alternatives were rejected?\"\n\n### Technical Changes\nBugs found, root causes, fixes applied, files modified, tests added/fixed.\nPreserve exact file paths, line numbers, error messages, and commit references.\nThis section answers: \"What bugs were fixed?\" and \"What files were changed?\"\n\n### Session Timeline\nCondensed chronological events with timestamps. Older events compressed more aggressively; recent events retain detail. This section answers: \"When did X happen?\" and \"What was the sequence of events?\"\n\nCONSOLIDATION RULES:\n- Preserve ALL dates and timestamps \u2014 temporal context is critical\n- Combine related items (e.g., \"agent called view tool 5 times on file x\" \u2192 single line)\n- Merge duplicate facts, keeping the most specific version\n- Drop observations superseded by later info (if value changed, keep only final value)\n- When consolidating, USER ASSERTIONS take precedence over questions about the same topic\n- Preserve all enumeratable entities [entity-type] \u2014 these are needed for aggregation questions\n- For enumeratable entities spanning multiple segments, create an explicit aggregation:\n \uD83D\uDD34 [event-attended] User attended 3 weddings total: Rachel+Mike (vineyard, Aug 2023), Emily+Sarah (garden, Sep 2023), Jen+Tom (Oct 8, 2023)\n\nEXACT NUMBERS: When two segments report different numbers for what seems like the same thing, keep the number from the earlier/original observation \u2014 it's likely the correct one from the actual event. Later references may be from memory or approximation.\n\nEARLY-SESSION CONTENT: Bug fixes, code changes, and decisions from the start of a session are just as important as later work. Never drop them just because the segment is short or old. If the first segment contains a specific bug fix with file paths and root cause, it MUST survive into the reflection.\n\nOutput ONLY an <observations> block with the consolidated observations.";
|
|
7
|
+
export declare const RECURSIVE_SYSTEM = "You are a memory reflector. You are given a set of observations from multiple conversation segments. Your job is to consolidate them into a structured working context that will become the agent's entire memory going forward.\n\nIMPORTANT: Your reflections ARE the entirety of the assistant's memory. Any information you omit is permanently forgotten. Do not leave out anything important.\n\nSTRUCTURE your output into these sections \u2014 each section supports a different type of downstream query:\n\n### Current State\nWhat is in progress right now? Active branches, open files, current task, blockers.\nThis section answers: \"What was I working on?\"\n\n### Key Decisions\nWhat was decided and why? Include the alternatives considered and rationale.\nThis section answers: \"Why did we choose approach X?\" and \"What alternatives were rejected?\"\n\n### Technical Changes\nBugs found, root causes, fixes applied, files modified, tests added/fixed.\nPreserve exact file paths, line numbers, error messages, and commit references.\nThis section answers: \"What bugs were fixed?\" and \"What files were changed?\"\n\n### Session Timeline\nCondensed chronological events with timestamps. Older events compressed more aggressively; recent events retain detail. This section answers: \"When did X happen?\" and \"What was the sequence of events?\"\n\nCONSOLIDATION RULES:\n- Preserve ALL dates and timestamps \u2014 temporal context is critical\n- Combine related items (e.g., \"agent called view tool 5 times on file x\" \u2192 single line)\n- Merge duplicate facts, keeping the most specific version\n- Drop observations superseded by later info (if value changed, keep only final value)\n- When consolidating, USER ASSERTIONS take precedence over questions about the same topic\n- Preserve all enumeratable entities [entity-type] \u2014 these are needed for aggregation questions\n- For enumeratable entities spanning multiple segments, create an explicit aggregation:\n \uD83D\uDD34 [event-attended] User attended 3 weddings total: Rachel+Mike (vineyard, Aug 2023), Emily+Sarah (garden, Sep 2023), Jen+Tom (Oct 8, 2023)\n\nEXACT NUMBERS: When two segments report different numbers for what seems like the same thing, keep the number from the earlier/original observation \u2014 it's likely the correct one from the actual event. Later references may be from memory or approximation.\n\nEARLY-SESSION CONTENT: Bug fixes, code changes, and decisions from the start of a session are just as important as later work. Never drop them just because the segment is short or old. If the first segment contains a specific bug fix with file paths and root cause, it MUST survive into the reflection.\n\nANCHORED UPDATES: If the prompt includes a <previous-meta-summary> block, treat it as the current consolidated state. Update it using the NEW observation segments \u2014 preserve still-true details, remove stale details, and merge in new facts. Keep the same section headings. Do NOT re-derive unchanged sections verbatim unless the new segments contradict them.\n\nOutput ONLY an <observations> block with the consolidated observations.";
|
|
8
8
|
export declare function recursiveUser(distillations: Array<{
|
|
9
9
|
observations: string;
|
|
10
|
-
}
|
|
10
|
+
}>, previousMeta?: string): string;
|
|
11
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\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.";
|
|
12
12
|
export declare function curatorUser(input: {
|
|
13
13
|
messages: string;
|
|
@@ -38,6 +38,12 @@ export declare function formatDistillations(distillations: Array<{
|
|
|
38
38
|
observations: string;
|
|
39
39
|
generation: number;
|
|
40
40
|
}>): string;
|
|
41
|
+
export declare const COMPACT_SUMMARY_TEMPLATE = "Output exactly this Markdown structure. Keep every section in this order, even when empty (use \"(none)\").\n\n---\n## Goal\n- [single-sentence task summary]\n\n## Constraints & Preferences\n- [user constraints, preferences, specs, or \"(none)\"]\n\n## Progress\n### Done\n- [completed work or \"(none)\"]\n\n### In Progress\n- [current work or \"(none)\"]\n\n### Blocked\n- [blockers or \"(none)\"]\n\n## Key Decisions\n- [decision and why, or \"(none)\"]\n\n## Next Steps\n- [ordered next actions or \"(none)\"]\n\n## Critical Context\n- [important technical facts, errors, open questions, or \"(none)\"]\n\n## Relevant Files\n- [file or directory path: why it matters, or \"(none)\"]\n---\n\nRules:\n- Keep every section, even when empty.\n- Use terse bullets, not prose paragraphs.\n- Preserve exact file paths, commands, error strings, and identifiers when known.\n- Do not mention the summary process or that context was compacted.\n- End with \"I'm ready to continue.\" on its own line after the closing \"---\".";
|
|
42
|
+
export declare function buildCompactPrompt(input: {
|
|
43
|
+
hasDistillations: boolean;
|
|
44
|
+
knowledge?: string;
|
|
45
|
+
previousSummary?: string;
|
|
46
|
+
}): string;
|
|
41
47
|
export declare function formatKnowledge(entries: Array<{
|
|
42
48
|
category: string;
|
|
43
49
|
title: string;
|
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,
|
|
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,i5HA0E8C,CAAC;AAE1E,wBAAgB,WAAW,CAAC,KAAK,EAAE;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,KAAK,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACJ,GAAG,MAAM,CAoBT;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,uoDA0BwC,CAAC;AAE1E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,OAAO,EAAE,KAAK,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,CAUT;AAID,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,KAAK,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC,GACD,MAAM,CAsBR;AAQD,eAAO,MAAM,wBAAwB,ggCAqCwC,CAAC;AAqB9E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,MAAM,CAeT;AAOD,wBAAgB,eAAe,CAC7B,OAAO,EAAE,KAAK,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,EACpE,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAwCR;AAMD,eAAO,MAAM,sBAAsB,ggBASwE,CAAC"}
|
package/dist/bun/temporal.d.ts
CHANGED
|
@@ -1,4 +1,35 @@
|
|
|
1
1
|
import type { LoreMessage, LorePart } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Chunk-boundary terminator inserted between chunks by `partsToText`.
|
|
4
|
+
*
|
|
5
|
+
* `\x1f` is ASCII Unit Separator — a non-word control char that:
|
|
6
|
+
* - cannot legitimately appear in normal chat or tool content (control
|
|
7
|
+
* chars are vanishingly rare even in binary file dumps),
|
|
8
|
+
* - is treated as a token separator by FTS5's `unicode61` tokenizer, so
|
|
9
|
+
* it has zero effect on BM25 indexing or scoring,
|
|
10
|
+
* - survives `sanitizeSurrogates()` (which only touches lone UTF-16
|
|
11
|
+
* surrogates, never ASCII control chars).
|
|
12
|
+
*
|
|
13
|
+
* Placed AFTER the existing `\n` so display tools that split on `\n`
|
|
14
|
+
* still render correctly; the structural parser (in `distillation.ts`)
|
|
15
|
+
* splits on `"\n" + CHUNK_TERMINATOR` for unambiguous chunk recovery.
|
|
16
|
+
*
|
|
17
|
+
* Adopted in F3b. Pre-F3b rows are rewritten in-place by a SQL migration
|
|
18
|
+
* (see `db.ts`); after that migration runs, every `temporal_messages.content`
|
|
19
|
+
* value uses this format consistently.
|
|
20
|
+
*/
|
|
21
|
+
export declare const CHUNK_TERMINATOR = "\u001F";
|
|
22
|
+
/**
|
|
23
|
+
* Serialize a list of message parts into a single content string for the
|
|
24
|
+
* `temporal_messages.content` column. Chunks are separated by
|
|
25
|
+
* `"\n" + CHUNK_TERMINATOR` so the structural parser can recover chunk
|
|
26
|
+
* boundaries unambiguously regardless of payload contents (including
|
|
27
|
+
* payloads that contain literal `[tool:...]` substrings — e.g. when the
|
|
28
|
+
* agent reads a file that documents this very format).
|
|
29
|
+
*
|
|
30
|
+
* Exported so tests can pin producer/consumer round-trip behavior.
|
|
31
|
+
*/
|
|
32
|
+
export declare function partsToText(parts: LorePart[]): string;
|
|
2
33
|
export declare function store(input: {
|
|
3
34
|
projectPath: string;
|
|
4
35
|
info: LoreMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temporal.d.ts","sourceRoot":"","sources":["../../src/temporal.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"temporal.d.ts","sourceRoot":"","sources":["../../src/temporal.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAQrD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,M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d,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,qBAAqB,EAAE,CAgC1B;AAED,wBAAgB,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAWrE;AAED,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAWR;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAC;IACnB,8FAA8F;IAC9F,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,WAAW,CA0Ed"}
|
package/dist/bun/types.d.ts
CHANGED
|
@@ -36,6 +36,15 @@ export type LoreAssistantMessage = {
|
|
|
36
36
|
modelID: string;
|
|
37
37
|
providerID: string;
|
|
38
38
|
mode: string;
|
|
39
|
+
/**
|
|
40
|
+
* Set to `true` by the OpenCode compaction agent on the assistant
|
|
41
|
+
* message that holds a `/compact` summary (see upstream
|
|
42
|
+
* `compaction.ts:435`). Lore reads this flag in F1b's
|
|
43
|
+
* `findPreviousCompactSummary` to anchor repeat `/compact`
|
|
44
|
+
* invocations to the prior summary. Always undefined for normal
|
|
45
|
+
* assistant turns.
|
|
46
|
+
*/
|
|
47
|
+
summary?: boolean;
|
|
39
48
|
path: {
|
|
40
49
|
cwd: string;
|
|
41
50
|
root: string;
|
package/dist/bun/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,MAAM,MAAM,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UAAU,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;QAChD;;;WAGG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GACA,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC3B"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic worker model selection.
|
|
3
|
+
*
|
|
4
|
+
* Background workers (distillation, curation, query expansion) don't need
|
|
5
|
+
* frontier reasoning. This module discovers cheaper models from the same
|
|
6
|
+
* provider and validates their quality via a two-phase comparison:
|
|
7
|
+
* Phase 1: structural checks (parsability, observation count, token bounds)
|
|
8
|
+
* Phase 2: LLM judge (session model rates candidate output vs reference)
|
|
9
|
+
*
|
|
10
|
+
* Results are persisted in kv_meta and re-evaluated when the model landscape
|
|
11
|
+
* changes (new models, session model switch, model deprecation).
|
|
12
|
+
*/
|
|
13
|
+
/** Minimal model info needed for worker selection — provider-agnostic. */
|
|
14
|
+
export type ModelInfo = {
|
|
15
|
+
id: string;
|
|
16
|
+
providerID: string;
|
|
17
|
+
cost: {
|
|
18
|
+
input: number;
|
|
19
|
+
};
|
|
20
|
+
status: string;
|
|
21
|
+
capabilities: {
|
|
22
|
+
input: {
|
|
23
|
+
text: boolean;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/** Result of a worker model validation stored in kv_meta. */
|
|
28
|
+
export type WorkerModelResult = {
|
|
29
|
+
modelID: string;
|
|
30
|
+
providerID: string;
|
|
31
|
+
fingerprint: string;
|
|
32
|
+
validatedAt: number;
|
|
33
|
+
judgeScore: number | null;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Select worker model candidates from the available models.
|
|
37
|
+
*
|
|
38
|
+
* Returns up to 2 candidates: cheapest overall + one tier below the session
|
|
39
|
+
* model. The session model itself is included (if it's the cheapest, the list
|
|
40
|
+
* has 1 entry and no comparison is needed).
|
|
41
|
+
*/
|
|
42
|
+
export declare function selectWorkerCandidates(sessionModel: {
|
|
43
|
+
id: string;
|
|
44
|
+
providerID: string;
|
|
45
|
+
cost: {
|
|
46
|
+
input: number;
|
|
47
|
+
};
|
|
48
|
+
}, providerModels: ModelInfo[]): ModelInfo[];
|
|
49
|
+
/**
|
|
50
|
+
* Compute a fingerprint from the model landscape. Changes when:
|
|
51
|
+
* - Models are added or removed from the provider
|
|
52
|
+
* - The session model changes
|
|
53
|
+
*/
|
|
54
|
+
export declare function computeModelFingerprint(providerID: string, sessionModelID: string, activeModelIDs: string[]): string;
|
|
55
|
+
export declare function getValidatedWorkerModel(providerID: string): WorkerModelResult | null;
|
|
56
|
+
export declare function storeValidatedWorkerModel(result: WorkerModelResult): void;
|
|
57
|
+
/**
|
|
58
|
+
* Check whether the stored validation is stale (fingerprint mismatch).
|
|
59
|
+
*/
|
|
60
|
+
export declare function isValidationStale(stored: WorkerModelResult | null, currentFingerprint: string): boolean;
|
|
61
|
+
export type StructuralCheckResult = {
|
|
62
|
+
passed: boolean;
|
|
63
|
+
observationCount: number;
|
|
64
|
+
tokenCount: number;
|
|
65
|
+
reason?: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Structural quality check: does the candidate distillation output meet
|
|
69
|
+
* minimum quality thresholds relative to the reference?
|
|
70
|
+
*/
|
|
71
|
+
export declare function structuralCheck(candidateObservations: string | null, referenceObservations: string): StructuralCheckResult;
|
|
72
|
+
export declare const 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.\n\nRate the candidate on a scale of 1-5:\n5 = Captures all key facts and decisions, equivalent to reference\n4 = Captures most facts, minor omissions\n3 = Captures the essential facts, some detail loss acceptable\n2 = Missing important facts or technical details\n1 = Significantly incomplete or inaccurate\n\nRespond with ONLY a single digit (1-5).";
|
|
73
|
+
export declare function workerJudgeUser(reference: string, candidate: string): string;
|
|
74
|
+
/** Parse the judge's score from a response. Returns null on parse failure. */
|
|
75
|
+
export declare function parseJudgeScore(response: string): number | null;
|
|
76
|
+
/**
|
|
77
|
+
* Resolve the effective worker model for a given provider.
|
|
78
|
+
* Priority: explicit config > validated auto-selection > session model (fallback).
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveWorkerModel(providerID: string, configWorkerModel?: {
|
|
81
|
+
providerID: string;
|
|
82
|
+
modelID: string;
|
|
83
|
+
}, configModel?: {
|
|
84
|
+
providerID: string;
|
|
85
|
+
modelID: string;
|
|
86
|
+
}): {
|
|
87
|
+
providerID: string;
|
|
88
|
+
modelID: string;
|
|
89
|
+
} | undefined;
|
|
90
|
+
//# sourceMappingURL=worker-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-model.d.ts","sourceRoot":"","sources":["../../src/worker-model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,0EAA0E;AAC1E,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE;QAAE,KAAK,EAAE;YAAE,IAAI,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,CAAC;CAC5C,CAAC;AAEF,6DAA6D;AAC7D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAQF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,I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M,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACpD;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAYrD"}
|
package/dist/node/config.d.ts
CHANGED
|
@@ -4,16 +4,24 @@ export declare const LoreConfig: z.ZodObject<{
|
|
|
4
4
|
providerID: z.ZodString;
|
|
5
5
|
modelID: z.ZodString;
|
|
6
6
|
}, z.core.$strip>>;
|
|
7
|
+
workerModel: z.ZodOptional<z.ZodObject<{
|
|
8
|
+
providerID: z.ZodString;
|
|
9
|
+
modelID: z.ZodString;
|
|
10
|
+
}, z.core.$strip>>;
|
|
7
11
|
budget: z.ZodDefault<z.ZodObject<{
|
|
8
12
|
distilled: z.ZodDefault<z.ZodNumber>;
|
|
9
13
|
raw: z.ZodDefault<z.ZodNumber>;
|
|
10
14
|
output: z.ZodDefault<z.ZodNumber>;
|
|
11
15
|
ltm: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
targetCacheReadCostPerTurn: z.ZodDefault<z.ZodNumber>;
|
|
17
|
+
maxLayer0Tokens: z.ZodOptional<z.ZodNumber>;
|
|
12
18
|
}, z.core.$strip>>;
|
|
19
|
+
idleResumeMinutes: z.ZodDefault<z.ZodNumber>;
|
|
13
20
|
distillation: z.ZodDefault<z.ZodObject<{
|
|
14
21
|
minMessages: z.ZodDefault<z.ZodNumber>;
|
|
15
22
|
maxSegment: z.ZodDefault<z.ZodNumber>;
|
|
16
23
|
metaThreshold: z.ZodDefault<z.ZodNumber>;
|
|
24
|
+
toolOutputMaxChars: z.ZodDefault<z.ZodNumber>;
|
|
17
25
|
}, z.core.$strip>>;
|
|
18
26
|
knowledge: z.ZodDefault<z.ZodObject<{
|
|
19
27
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,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;AAIxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2JrB,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,CASjE"}
|
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;
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAyVtC,wBAAgB,EAAE,IAAI,QAAQ,CAkC7B;AAqCD,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,6 +1,48 @@
|
|
|
1
|
+
import * as temporal from "./temporal";
|
|
1
2
|
import { workerSessionIDs } from "./worker";
|
|
2
3
|
import type { LLMClient } from "./types";
|
|
3
4
|
export { workerSessionIDs };
|
|
5
|
+
type TemporalMessage = temporal.TemporalMessage;
|
|
6
|
+
/**
|
|
7
|
+
* Truncate tool outputs within a `TemporalMessage.content` string (produced
|
|
8
|
+
* by `temporal.partsToText`). Plain text and `[reasoning]` chunks pass
|
|
9
|
+
* through untouched; only `[tool:<name>] <payload>` envelopes whose payload
|
|
10
|
+
* exceeds `maxChars` are replaced with a compact `toolStripAnnotation(...)`
|
|
11
|
+
* marker preserving line count, error flag, and file paths.
|
|
12
|
+
*
|
|
13
|
+
* Annotation matches the style used by the runtime gradient so the
|
|
14
|
+
* distillation LLM sees the same affordance it sees during live turns.
|
|
15
|
+
*
|
|
16
|
+
* Exported primarily for tests. If future renderers need the same
|
|
17
|
+
* semantics (e.g. a recall-time preview), they can reuse this.
|
|
18
|
+
*/
|
|
19
|
+
export declare function truncateToolOutputsInContent(content: string, maxChars: number): string;
|
|
20
|
+
/**
|
|
21
|
+
* Render a sequence of TemporalMessages as a single string for the distillation
|
|
22
|
+
* LLM. User messages pass through verbatim; assistant and tool messages have
|
|
23
|
+
* oversized tool outputs truncated via {@link truncateToolOutputsInContent}.
|
|
24
|
+
*
|
|
25
|
+
* Exported so tests can verify truncation on realistic message fixtures without
|
|
26
|
+
* spinning up a full distillSegment round trip.
|
|
27
|
+
*/
|
|
28
|
+
export declare function messagesToText(messages: TemporalMessage[], toolOutputMaxChars?: number): string;
|
|
29
|
+
type DistillationResult = {
|
|
30
|
+
observations: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Return the most recent gen>0 (meta) distillation observations for this
|
|
34
|
+
* session, or undefined when none exists. Used by `metaDistill` as the
|
|
35
|
+
* `<previous-meta-summary>` anchor on second-and-later consolidation rounds:
|
|
36
|
+
* the LLM updates the prior meta in place rather than re-deriving from
|
|
37
|
+
* scratch.
|
|
38
|
+
*
|
|
39
|
+
* Filters on `generation > 0` explicitly — gen-0 rows are raw segment
|
|
40
|
+
* observations and aren't a suitable anchor (same constraint that motivated
|
|
41
|
+
* the F1b SDK live-read for /compact summaries).
|
|
42
|
+
*
|
|
43
|
+
* Exported primarily for tests; `metaDistill` is the only production caller.
|
|
44
|
+
*/
|
|
45
|
+
export declare function latestMetaObservations(projectPath: string, sessionID: string): string | undefined;
|
|
4
46
|
/** Safely parse the source_ids JSON column. Defaults to [] on corrupt data. */
|
|
5
47
|
export declare function parseSourceIds(raw: string): string[];
|
|
6
48
|
export type Distillation = {
|
|
@@ -13,8 +55,21 @@ export type Distillation = {
|
|
|
13
55
|
token_count: number;
|
|
14
56
|
created_at: number;
|
|
15
57
|
};
|
|
16
|
-
/**
|
|
17
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Load distillations for a session, oldest first.
|
|
60
|
+
*
|
|
61
|
+
* By default (`includeArchived = false`) skips rows that have been archived
|
|
62
|
+
* by `archiveDistillations` — typically gen-0 segments that were already
|
|
63
|
+
* consolidated into a gen>0 meta. This honors the docstring contract that
|
|
64
|
+
* archived rows are "excluded from the in-context prefix."
|
|
65
|
+
*
|
|
66
|
+
* Pre-F2, this function did NOT filter `archived` and so leaked merged
|
|
67
|
+
* gen-0 rows into `/compact` and overflow-recovery prompts alongside the
|
|
68
|
+
* meta that consolidated them. The default-false behavior fixes that
|
|
69
|
+
* divergence; `includeArchived: true` preserves the legacy shape for
|
|
70
|
+
* rare callers that explicitly want all rows.
|
|
71
|
+
*/
|
|
72
|
+
export declare function loadForSession(projectPath: string, sessionID: string, includeArchived?: boolean): Distillation[];
|
|
18
73
|
export declare function run(input: {
|
|
19
74
|
llm: LLMClient;
|
|
20
75
|
projectPath: string;
|
|
@@ -29,4 +84,21 @@ export declare function run(input: {
|
|
|
29
84
|
rounds: number;
|
|
30
85
|
distilled: number;
|
|
31
86
|
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Consolidate a session's gen-0 distillation segments into a higher-generation
|
|
89
|
+
* meta-distillation. On second-and-later rounds, anchors on the prior meta
|
|
90
|
+
* via `<previous-meta-summary>` so the LLM updates in place rather than
|
|
91
|
+
* re-deriving from scratch.
|
|
92
|
+
*
|
|
93
|
+
* Exported for tests; `run()` is the production entry point.
|
|
94
|
+
*/
|
|
95
|
+
export declare function metaDistill(input: {
|
|
96
|
+
llm: LLMClient;
|
|
97
|
+
projectPath: string;
|
|
98
|
+
sessionID: string;
|
|
99
|
+
model?: {
|
|
100
|
+
providerID: string;
|
|
101
|
+
modelID: string;
|
|
102
|
+
};
|
|
103
|
+
}): Promise<DistillationResult | null>;
|
|
32
104
|
//# sourceMappingURL=distillation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distillation.d.ts","sourceRoot":"","sources":["../../src/distillation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"distillation.d.ts","sourceRoot":"","sources":["../../src/distillation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AAWvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,KAAK,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC;AAmDhD;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,MAAM,CAwBR;AAgBD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,eAAe,EAAE,EAC3B,kBAAkB,CAAC,EAAE,MAAM,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SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CA+ErC"}
|
|
@@ -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;AAeH,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;AAsKD,0DAA0D;AAC1D,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAMD;;qEAEqE;AACrE,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAMD;;;;;;;GAOG;AACH,wBAAsB,KAAK,CACzB,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,EAAE,UAAU,GAAG,OAAO,GAC9B,OAAO,CAAC,YAAY,EAAE,CAAC,CAIzB;AAMD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,MAAM,CAazE;AAMD,8DAA8D;AAC9D,wBAAgB,MAAM,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAEhD;AAED,oEAAoE;AACpE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,CAGhE;AAMD,KAAK,SAAS,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpD;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,cAAc,EAAE,YAAY,EAC5B,KAAK,SAAK,GACT,SAAS,EAAE,CAcb;AAMD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,cAAc,EAAE,YAAY,EAC5B,KAAK,SAAK,GACT,SAAS,EAAE,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;AAkBD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAoC3C;AAMD;;;;;;GAMG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAuC1D;AAMD;;;;GAIG;AACH,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,MAAM,CAAC,CAsCtE"}
|
package/dist/node/gradient.d.ts
CHANGED
|
@@ -1,9 +1,62 @@
|
|
|
1
1
|
import type { LoreMessageWithParts } from "./types";
|
|
2
2
|
type MessageWithParts = LoreMessageWithParts;
|
|
3
|
+
/**
|
|
4
|
+
* Detect cold-cache resumption and refresh byte-identity caches.
|
|
5
|
+
*
|
|
6
|
+
* Anthropic's prompt cache evicts entries after ~5 minutes (default tier) /
|
|
7
|
+
* ~1 hour (extended tier). When a session resumes after the eviction window,
|
|
8
|
+
* the cache is provably cold — every prefix we've been carefully keeping
|
|
9
|
+
* byte-stable (`prefixCache`, `rawWindowCache`, plus the host's per-session
|
|
10
|
+
* LTM cache) provides no benefit on this turn. Worse, the LTM block was
|
|
11
|
+
* scored against the conversation context as it was on the previous turn,
|
|
12
|
+
* which may have drifted significantly in N hours.
|
|
13
|
+
*
|
|
14
|
+
* On resume after `thresholdMs`:
|
|
15
|
+
* - reset the distilled prefix cache (next turn re-renders from scratch)
|
|
16
|
+
* - reset the raw window pin cache (next turn picks a fresh cutoff)
|
|
17
|
+
* - set `cameOutOfIdle` so the OpenCode host can also clear `ltmSessionCache`
|
|
18
|
+
* and bypass the conversation-vs-LTM cost comparison in the LTM
|
|
19
|
+
* degraded-recovery branch
|
|
20
|
+
*
|
|
21
|
+
* Importantly, this does NOT touch:
|
|
22
|
+
* - reasoning blocks (Anthropic's April 23 postmortem identifies dropping
|
|
23
|
+
* reasoning blocks as the root cause of forgetfulness/repetition; Lore
|
|
24
|
+
* preserves reasoning by policy across all gradient layers)
|
|
25
|
+
* - the gradient layer (cold cache doesn't change token budgets;
|
|
26
|
+
* calibration's actualInput = input + cache.read + cache.write already
|
|
27
|
+
* accounts for cache misses correctly)
|
|
28
|
+
* - calibration state (`lastKnownInput`, overhead EMA, message-ID set) —
|
|
29
|
+
* the next API response will refresh these via the normal calibrate() path
|
|
30
|
+
*
|
|
31
|
+
* Set `thresholdMs <= 0` to disable. Returns true if a reset fired so the
|
|
32
|
+
* caller can log/observe.
|
|
33
|
+
*/
|
|
34
|
+
export declare function onIdleResume(sessionID: string, thresholdMs: number, now?: number): {
|
|
35
|
+
triggered: false;
|
|
36
|
+
} | {
|
|
37
|
+
triggered: true;
|
|
38
|
+
idleMs: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Read-and-clear the cameOutOfIdle flag. The OpenCode host's LTM degraded-
|
|
42
|
+
* recovery branch consumes this to decide whether to bypass the
|
|
43
|
+
* conversation-vs-LTM token comparison on a post-idle turn.
|
|
44
|
+
*/
|
|
45
|
+
export declare function consumeCameOutOfIdle(sessionID: string): boolean;
|
|
3
46
|
export declare function setModelLimits(limits: {
|
|
4
47
|
context: number;
|
|
5
48
|
output: number;
|
|
6
49
|
}): void;
|
|
50
|
+
/**
|
|
51
|
+
* Set the cost-aware layer-0 token cap. When the cap > 0, the layer-0
|
|
52
|
+
* passthrough gate uses `min(maxInput, cap)` instead of `maxInput` alone.
|
|
53
|
+
*
|
|
54
|
+
* Call from the host adapter after computing the cap from model pricing:
|
|
55
|
+
* `cap = max(targetCostPerTurn / model.cost.cache.read, MIN_LAYER0_FLOOR)`
|
|
56
|
+
*/
|
|
57
|
+
export declare function setMaxLayer0Tokens(tokens: number): void;
|
|
58
|
+
/** Compute the layer-0 token cap from a per-turn cost target and cache-read price. */
|
|
59
|
+
export declare function computeLayer0Cap(targetCostPerTurn: number, cacheReadCostPerToken: number): number;
|
|
7
60
|
/** Called by the system transform hook after formatting LTM knowledge. */
|
|
8
61
|
export declare function setLtmTokens(tokens: number): void;
|
|
9
62
|
/** Returns the current LTM token count (for tests and diagnostics). */
|
|
@@ -33,6 +86,25 @@ export declare function getLastLayer(sessionID?: string): SafetyLayer;
|
|
|
33
86
|
*/
|
|
34
87
|
export declare function setForceMinLayer(layer: SafetyLayer, sessionID?: string): void;
|
|
35
88
|
export declare function resetCalibration(sessionID?: string): void;
|
|
89
|
+
/**
|
|
90
|
+
* For testing only — observe session-state cache fields without exposing the
|
|
91
|
+
* full type. Returns null when the session has no state. The boolean fields
|
|
92
|
+
* answer "does this cache hold something right now?" — sufficient for asserting
|
|
93
|
+
* that onIdleResume() reset them.
|
|
94
|
+
*/
|
|
95
|
+
export declare function inspectSessionState(sessionID: string): {
|
|
96
|
+
hasPrefixCache: boolean;
|
|
97
|
+
hasRawWindowCache: boolean;
|
|
98
|
+
cameOutOfIdle: boolean;
|
|
99
|
+
lastTurnAt: number;
|
|
100
|
+
} | null;
|
|
101
|
+
/**
|
|
102
|
+
* For testing only — set the session's lastTurnAt field. Used to simulate
|
|
103
|
+
* idle gaps without sleeping. Creates the session state if not present so
|
|
104
|
+
* tests don't need to seed it via a transform() call.
|
|
105
|
+
*/
|
|
106
|
+
export declare function setLastTurnAtForTest(sessionID: string, ms: number): void;
|
|
107
|
+
export declare function toolStripAnnotation(toolName: string, output: string): string;
|
|
36
108
|
/**
|
|
37
109
|
* Replace duplicate tool outputs with compact back-references, keeping only
|
|
38
110
|
* the latest occurrence of each unique output. Reduces context token usage
|
|
@@ -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;
|
|
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;AAmJ7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,GAAG,GAAE,MAAmB,GACvB;IAAE,SAAS,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAU5D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAK/D;AAMD,wBAAgB,cAAc,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,QASzE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,QAEhD;AAED,sFAAsF;AACtF,wBAAgB,gBAAgB,CAC9B,iBAAiB,EAAE,MAAM,EACzB,qBAAqB,EAAE,MAAM,GAC5B,MAAM,CAIR;AAED,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,QAE1C;AAED,uEAAuE;AACvE,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAIxD;AAWD,wBAAgB,SAAS,CACvB,WAAW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G,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;AAIF,wBAAgB,uBAAuB,IAAI,OAAO,CAIjD;AAgSD,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,CAwDlB;AAGD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAErE"}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -10,10 +10,12 @@ export type { LoreMessage, LoreUserMessage, LoreAssistantMessage, LorePart, Lore
|
|
|
10
10
|
export { isTextPart, isReasoningPart, isToolPart } from "./types";
|
|
11
11
|
export { load, config, type LoreConfig } from "./config";
|
|
12
12
|
export { db, ensureProject, isFirstRun, projectId, projectName, loadForceMinLayer, saveForceMinLayer, close, } from "./db";
|
|
13
|
-
export { transform, setModelLimits, needsUrgentDistillation, calibrate, setLtmTokens, getLtmTokens, getLtmBudget, setForceMinLayer, getLastTransformedCount, getLastTransformEstimate, } from "./gradient";
|
|
14
|
-
export { formatKnowledge, formatDistillations, DISTILLATION_SYSTEM, distillationUser, RECURSIVE_SYSTEM, recursiveUser, CURATOR_SYSTEM, curatorUser, CONSOLIDATION_SYSTEM, consolidationUser, QUERY_EXPANSION_SYSTEM, } from "./prompt";
|
|
13
|
+
export { transform, setModelLimits, setMaxLayer0Tokens, computeLayer0Cap, needsUrgentDistillation, calibrate, setLtmTokens, getLtmTokens, getLtmBudget, setForceMinLayer, getLastTransformedCount, getLastTransformEstimate, toolStripAnnotation, onIdleResume, consumeCameOutOfIdle, setLastTurnAtForTest, inspectSessionState, } from "./gradient";
|
|
14
|
+
export { formatKnowledge, formatDistillations, DISTILLATION_SYSTEM, distillationUser, RECURSIVE_SYSTEM, recursiveUser, CURATOR_SYSTEM, curatorUser, CONSOLIDATION_SYSTEM, consolidationUser, QUERY_EXPANSION_SYSTEM, COMPACT_SUMMARY_TEMPLATE, buildCompactPrompt, } from "./prompt";
|
|
15
15
|
export { shouldImport, importFromFile, exportToFile } from "./agents-file";
|
|
16
16
|
export { workerSessionIDs, isWorkerSession } from "./worker";
|
|
17
|
+
export * as workerModel from "./worker-model";
|
|
18
|
+
export { WORKER_JUDGE_SYSTEM, workerJudgeUser, } from "./worker-model";
|
|
17
19
|
export { ftsQuery, ftsQueryOr, EMPTY_QUERY, reciprocalRankFusion, expandQuery, extractTopTerms, } from "./search";
|
|
18
20
|
export { serialize, inline, h, p, ul, lip, liph, t, root, strong, normalize, sanitizeSurrogates, unescapeMarkdown, } from "./markdown";
|
|
19
21
|
//# sourceMappingURL=index.d.ts.map
|
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,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,GAAG,MAAM,OAAO,CAAC;AAE7B,OAAO,EACL,SAAS,EACT,uBAAuB,EACvB,yBA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