@loreai/core 0.10.2 → 0.11.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 +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 +530 -67
- 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 +530 -67
- 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 +57 -1
- package/src/distillation.ts +225 -28
- package/src/embedding.ts +7 -0
- package/src/gradient.ts +262 -8
- 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/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>;
|
package/dist/bun/config.d.ts.map
CHANGED
|
@@ -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/bun/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,CA4B7B;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,GAC1B,MAAM,CAUR;AAED,KAAK,kBAAkB,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAwBF;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAEpB;AAwBD,+EAA+E;AAC/E,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAQpD;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,eAAe,UAAQ,GACtB,YAAY,EAAE,CAqBhB;AA0ID,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;IAChD,qEAAqE;IACrE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CA4DjD;AAsDD;;;;;;;GAOG;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,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,wB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MAAM,CAAC,CAsCtE"}
|
package/dist/bun/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;C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G,MAAM,CAErE"}
|
package/dist/bun/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/bun/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAE7B,OAAO,EACL,SAAS,EACT,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EACL,EAAE,EACF,aAAa,EACb,UAAU,EACV,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,GACN,MAAM,MAAM,CAAC;AACd,OAAO,EACL,SAAS,EACT,cAAc,EACd,uBAAuB,EACvB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,
|
|
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,yBAAyB,EACzB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EACL,EAAE,EACF,aAAa,EACb,UAAU,EACV,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,GACN,MAAM,MAAM,CAAC;AACd,OAAO,EACL,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,E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