@loreai/core 0.19.0 → 0.20.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/agents-file.d.ts.map +1 -1
- package/dist/bun/config.d.ts.map +1 -1
- package/dist/bun/db.d.ts +13 -1
- package/dist/bun/db.d.ts.map +1 -1
- package/dist/bun/embedding.d.ts.map +1 -1
- package/dist/bun/git.d.ts.map +1 -1
- package/dist/bun/gradient.d.ts +4 -1
- package/dist/bun/gradient.d.ts.map +1 -1
- package/dist/bun/hosted.d.ts +36 -0
- package/dist/bun/hosted.d.ts.map +1 -0
- package/dist/bun/index.d.ts +3 -2
- package/dist/bun/index.d.ts.map +1 -1
- package/dist/bun/index.js +236 -152
- package/dist/bun/index.js.map +4 -4
- package/dist/bun/lat-reader.d.ts.map +1 -1
- package/dist/node/agents-file.d.ts.map +1 -1
- package/dist/node/config.d.ts.map +1 -1
- package/dist/node/db.d.ts +13 -1
- package/dist/node/db.d.ts.map +1 -1
- package/dist/node/embedding.d.ts.map +1 -1
- package/dist/node/git.d.ts.map +1 -1
- package/dist/node/gradient.d.ts +4 -1
- package/dist/node/gradient.d.ts.map +1 -1
- package/dist/node/hosted.d.ts +36 -0
- package/dist/node/hosted.d.ts.map +1 -0
- package/dist/node/index.d.ts +3 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +236 -152
- package/dist/node/index.js.map +4 -4
- package/dist/node/lat-reader.d.ts.map +1 -1
- package/dist/types/agents-file.d.ts.map +1 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/db.d.ts +13 -1
- package/dist/types/db.d.ts.map +1 -1
- package/dist/types/embedding.d.ts.map +1 -1
- package/dist/types/git.d.ts.map +1 -1
- package/dist/types/gradient.d.ts +4 -1
- package/dist/types/gradient.d.ts.map +1 -1
- package/dist/types/hosted.d.ts +36 -0
- package/dist/types/hosted.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lat-reader.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/agents-file.ts +12 -0
- package/src/config.ts +10 -5
- package/src/db.ts +39 -6
- package/src/embedding.ts +43 -5
- package/src/git.ts +4 -0
- package/src/gradient.ts +44 -0
- package/src/hosted.ts +46 -0
- package/src/index.ts +4 -0
- package/src/lat-reader.ts +4 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lat-reader.d.ts","sourceRoot":"","sources":["../../src/lat-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"lat-reader.d.ts","sourceRoot":"","sources":["../../src/lat-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAmBH,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAI7D,KAAK,aAAa,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC;AAyBF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,EAAE,CAqErG;AA8BD,kDAAkD;AAClD,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAItD;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAiFnD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,gBAAgB,EAAE,CAqBrB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,GAChB,UAAU,EAAE,CA2Cd;AAED,wCAAwC;AACxC,wBAAgB,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAMjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents-file.d.ts","sourceRoot":"","sources":["../../src/agents-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"agents-file.d.ts","sourceRoot":"","sources":["../../src/agents-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,eAAO,MAAM,kBAAkB,qGACqE,CAAC;AACrG,eAAO,MAAM,gBAAgB,sCAAsC,CAAC;AAepE;;;;GAIG;AACH,eAAO,MAAM,SAAS,aAAa,CAAC;AA8CpC;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAI5D;AAMD,MAAM,MAAM,eAAe,GAAG;IAC5B,+EAA+E;IAC/E,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA+EF;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,EAAE,CAgD1E;AAmFD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,IAAI,CAgCP;AAMD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAeV;AAoFD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,IAAI,CAgBP;AAMD;;GAEG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAG3D;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAmBxD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CA0BjE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAqBxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8OrB,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/types/db.d.ts
CHANGED
|
@@ -38,8 +38,20 @@ export declare function close(): void;
|
|
|
38
38
|
* an alias so subsequent calls skip the subprocess. If the matched project's
|
|
39
39
|
* git_remote was not yet populated (pre-v14 rows), it is backfilled lazily.
|
|
40
40
|
*/
|
|
41
|
-
export declare function ensureProject(path: string, name?: string): string;
|
|
41
|
+
export declare function ensureProject(path: string, name?: string, suppliedGitRemote?: string | null): string;
|
|
42
42
|
export declare function projectId(path: string): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Look up a project by git_remote (preferred) or path. Returns the project ID
|
|
45
|
+
* or null if not found. Unlike `ensureProject()`, this is read-only — it never
|
|
46
|
+
* creates a project or registers path aliases.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveProjectByRemoteOrPath(gitRemote?: string, path?: string): string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Look up the path for a project by its internal ID.
|
|
51
|
+
* Used by the REST API to resolve project UUID → path for core functions
|
|
52
|
+
* that require a path argument.
|
|
53
|
+
*/
|
|
54
|
+
export declare function projectPath(id: string): string | null;
|
|
43
55
|
/** Look up a project's display name by its internal ID. */
|
|
44
56
|
export declare function projectName(id: string): string | null;
|
|
45
57
|
/**
|
package/dist/types/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;AAmiBD,4DAA4D;AAC5D,wBA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,IAAI,MAAM,CAMtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../src/embedding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../src/embedding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA0CH,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;AAgHD;;;;GAIG;AACH,qBAAa,6BAA8B,SAAQ,KAAK;gBAC1C,KAAK,CAAC,EAAE,OAAO;CAS5B;AAQD,uDAAuD;AACvD,wBAAgB,wBAAwB,IAAI,IAAI,CAG/C;AAED;;oCAEoC;AACpC,wBAAgB,6BAA6B,IAAI,IAAI,CAGpD;AAyVD;;;wEAGwE;AACxE,wBAAgB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAQ7C;AAED;;;uDAGuD;AACvD,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAQnD;AAED;;;;;;;gDAOgD;AAChD,wBAAgB,qBAAqB,IAAI,OAAO,CAK/C;AAED;;;sEAGsE;AACtE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAIrD;AAOD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,IAAI;IACpC,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,QAAQ,EAAE,iBAAiB,CAAC;CAC7B,GAAG,IAAI,CAgBP;AAMD;;;;;;4DAM4D;AAC5D,wBAAgB,WAAW,IAAI,OAAO,CAKrC;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,KAAK,CACzB,KAAK,EA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AoB,CAClC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,GACd,IAAI,CAeN;AAMD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,YAAY,EAC5B,SAAS,EAAE,MAAM,EACjB,KAAK,SAAK,EACV,SAAS,CAAC,EAAE,MAAM,GACjB,SAAS,EAAE,CAmBb;AAkBD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAwC3C;AAgBD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAsExD;AAsDD;;;;;;GAMG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CA8C1D;AAMD;;;;GAIG;AACH,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,MAAM,CAAC,CAwDtE"}
|
package/dist/types/git.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/git.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/git.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA6BtD;AAaD;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkDxD"}
|
package/dist/types/gradient.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare function getMaxContextTokens(): number;
|
|
|
17
17
|
* @param cacheRead - cache_read_input_tokens from the API response
|
|
18
18
|
* @param sessionID - session that produced this response
|
|
19
19
|
*/
|
|
20
|
-
export declare function updateBustRate(cacheWrite: number, cacheRead: number, sessionID?: string): void;
|
|
20
|
+
export declare function updateBustRate(cacheWrite: number, cacheRead: number, sessionID?: string, lastLayer?: number): void;
|
|
21
21
|
type DistillationSnapshot = {
|
|
22
22
|
/** Cached distillation rows from the most recent DB read */
|
|
23
23
|
rows: Distillation[];
|
|
@@ -141,6 +141,9 @@ export declare function inspectSessionState(sessionID: string): {
|
|
|
141
141
|
postIdleCompact: boolean;
|
|
142
142
|
lastTurnAt: number;
|
|
143
143
|
distillationSnapshot: DistillationSnapshot | null;
|
|
144
|
+
bustRateEMA: number;
|
|
145
|
+
dynamicContextCap: number;
|
|
146
|
+
consecutiveLayer4: number;
|
|
144
147
|
} | null;
|
|
145
148
|
/**
|
|
146
149
|
* For testing only — set the session's lastTurnAt field. Used to simulate
|
|
@@ -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;AA0D7C,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,MAAM,EACtB,sBAAsB,EAAE,MAAM,GAC7B,MAAM,CAGR;AAED;;0CAE0C;AAC1C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,QAEjD;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI,
|
|
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;AA0D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CAAC,CAAC;AAqB5C,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;IAIlB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAMF,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAIlE;AAgVD,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"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hosted.ts — Hosted/remote mode flag for @loreai/core.
|
|
3
|
+
*
|
|
4
|
+
* When the gateway runs remotely (different machine/container from the
|
|
5
|
+
* developer's workspace), filesystem operations that use client-controlled
|
|
6
|
+
* paths are unsafe:
|
|
7
|
+
*
|
|
8
|
+
* - `git remote -v` subprocess with attacker-controlled cwd
|
|
9
|
+
* - `.lore.json` config read from attacker-controlled path
|
|
10
|
+
* - `.lore.md` / AGENTS.md read/write at attacker-controlled path
|
|
11
|
+
* - `lat.md/` recursive directory scan at attacker-controlled path
|
|
12
|
+
* - `fs.watch()` on attacker-controlled paths
|
|
13
|
+
*
|
|
14
|
+
* Setting hosted mode causes all these operations to become safe no-ops.
|
|
15
|
+
* The gateway sets this flag during startup when `LORE_HOSTED_MODE=1`.
|
|
16
|
+
*
|
|
17
|
+
* This is a process-wide flag — once set, it cannot be unset (the only
|
|
18
|
+
* consumer is the gateway process, and hosted mode is a startup decision).
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Enable hosted mode. Once enabled, cannot be disabled.
|
|
22
|
+
* All filesystem operations using client-controlled paths become no-ops.
|
|
23
|
+
*/
|
|
24
|
+
export declare function enableHostedMode(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Returns true if hosted mode is active — filesystem operations using
|
|
27
|
+
* client-controlled paths should be skipped.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isHostedMode(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Reset hosted mode flag. **Test-only** — production code should never
|
|
32
|
+
* call this. Exported so tests can toggle hosted mode without process
|
|
33
|
+
* restarts.
|
|
34
|
+
*/
|
|
35
|
+
export declare function _resetHostedModeForTest(): void;
|
|
36
|
+
//# sourceMappingURL=hosted.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted.d.ts","sourceRoot":"","sources":["../../src/hosted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,9 +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, 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, type SessionTrackingState, type LoadedSessionTracking, getKV, setKV, getMeta, setMeta, getInstanceId, close, } from "./db";
|
|
19
19
|
export { normalizeRemoteUrl, getGitRemote, clearGitRemoteCache } from "./git";
|
|
20
|
-
export {
|
|
20
|
+
export { enableHostedMode, isHostedMode } from "./hosted";
|
|
21
|
+
export { transform, setModelLimits, setMaxLayer0Tokens, computeLayer0Cap, setMaxContextTokens, computeContextCap, getMaxContextTokens, updateBustRate, needsUrgentDistillation, calibrate, setLtmTokens, getLtmTokens, getLtmBudget, setForceMinLayer, getLastTransformedCount, getLastTransformEstimate, getLastLayer, toolStripAnnotation, onIdleResume, getLastTurnAt, consumeCameOutOfIdle, saveGradientState, setLastTurnAtForTest, inspectSessionState, } from "./gradient";
|
|
21
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";
|
|
22
23
|
export { shouldImport, importFromFile, exportToFile, exportLoreFile, importLoreFile, shouldImportLoreFile, loreFileExists, clearLoreFileCache, LORE_FILE, } from "./agents-file";
|
|
23
24
|
export { workerSessionIDs, isWorkerSession } from "./worker";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,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ACnB,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lat-reader.d.ts","sourceRoot":"","sources":["../../src/lat-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"lat-reader.d.ts","sourceRoot":"","sources":["../../src/lat-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAmBH,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,GAA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1-Apache-2.0",
|
|
6
6
|
"description": "Shared memory engine for Lore — three-tier storage, distillation, gradient context management",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"types": "./dist/node/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
11
12
|
"bun": "./src/index.ts",
|
|
12
13
|
"default": "./dist/node/index.js"
|
|
13
14
|
}
|
package/src/agents-file.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { dirname, join } from "path";
|
|
|
13
13
|
import { db, ensureProject } from "./db";
|
|
14
14
|
import * as ltm from "./ltm";
|
|
15
15
|
import { serialize, inline, h, ul, liph, strong, t, root, unescapeMarkdown } from "./markdown";
|
|
16
|
+
import { isHostedMode } from "./hosted";
|
|
16
17
|
|
|
17
18
|
// ---------------------------------------------------------------------------
|
|
18
19
|
// Constants
|
|
@@ -334,6 +335,8 @@ export function exportToFile(input: {
|
|
|
334
335
|
projectPath: string;
|
|
335
336
|
filePath: string;
|
|
336
337
|
}): void {
|
|
338
|
+
if (isHostedMode()) return;
|
|
339
|
+
|
|
337
340
|
// Write the actual entries to .lore.md first.
|
|
338
341
|
exportLoreFile(input.projectPath);
|
|
339
342
|
|
|
@@ -378,6 +381,7 @@ export function shouldImport(input: {
|
|
|
378
381
|
projectPath: string;
|
|
379
382
|
filePath: string;
|
|
380
383
|
}): boolean {
|
|
384
|
+
if (isHostedMode()) return false;
|
|
381
385
|
if (!existsSync(input.filePath)) return false;
|
|
382
386
|
|
|
383
387
|
const fileContent = readFileSync(input.filePath, "utf8");
|
|
@@ -483,6 +487,7 @@ export function importFromFile(input: {
|
|
|
483
487
|
projectPath: string;
|
|
484
488
|
filePath: string;
|
|
485
489
|
}): void {
|
|
490
|
+
if (isHostedMode()) return;
|
|
486
491
|
if (!existsSync(input.filePath)) return;
|
|
487
492
|
|
|
488
493
|
const fileContent = readFileSync(input.filePath, "utf8");
|
|
@@ -507,6 +512,7 @@ export function importFromFile(input: {
|
|
|
507
512
|
* Returns true if a `.lore.md` file exists in the project root.
|
|
508
513
|
*/
|
|
509
514
|
export function loreFileExists(projectPath: string): boolean {
|
|
515
|
+
if (isHostedMode()) return false;
|
|
510
516
|
return existsSync(join(projectPath, LORE_FILE));
|
|
511
517
|
}
|
|
512
518
|
|
|
@@ -519,6 +525,8 @@ export function loreFileExists(projectPath: string): boolean {
|
|
|
519
525
|
* and mtime bumps.
|
|
520
526
|
*/
|
|
521
527
|
export function exportLoreFile(projectPath: string): void {
|
|
528
|
+
if (isHostedMode()) return;
|
|
529
|
+
|
|
522
530
|
const sectionBody = buildSection(projectPath);
|
|
523
531
|
const content = LORE_FILE_HEADER + "\n" + sectionBody;
|
|
524
532
|
const contentHash = hashSection(content);
|
|
@@ -545,6 +553,8 @@ export function exportLoreFile(projectPath: string): void {
|
|
|
545
553
|
* call when the file hasn't been touched since we last processed it.
|
|
546
554
|
*/
|
|
547
555
|
export function shouldImportLoreFile(projectPath: string): boolean {
|
|
556
|
+
if (isHostedMode()) return false;
|
|
557
|
+
|
|
548
558
|
const fp = join(projectPath, LORE_FILE);
|
|
549
559
|
if (!existsSync(fp)) return false;
|
|
550
560
|
|
|
@@ -579,6 +589,8 @@ export function shouldImportLoreFile(projectPath: string): boolean {
|
|
|
579
589
|
* content hasn't changed, only the DB was updated to match it.
|
|
580
590
|
*/
|
|
581
591
|
export function importLoreFile(projectPath: string): void {
|
|
592
|
+
if (isHostedMode()) return;
|
|
593
|
+
|
|
582
594
|
const fp = join(projectPath, LORE_FILE);
|
|
583
595
|
if (!existsSync(fp)) return;
|
|
584
596
|
|
package/src/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
+
import { isHostedMode } from "./hosted";
|
|
4
5
|
|
|
5
6
|
export const LoreConfig = z.object({
|
|
6
7
|
model: z
|
|
@@ -251,11 +252,15 @@ export function config(): LoreConfig {
|
|
|
251
252
|
}
|
|
252
253
|
|
|
253
254
|
export async function load(directory: string): Promise<LoreConfig> {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
255
|
+
// In hosted mode, never read config from client-controlled paths —
|
|
256
|
+
// a crafted .lore.json could alter gateway behavior (budget, model, thresholds).
|
|
257
|
+
if (!isHostedMode()) {
|
|
258
|
+
const path = join(directory, ".lore.json");
|
|
259
|
+
if (existsSync(path)) {
|
|
260
|
+
const raw = JSON.parse(readFileSync(path, "utf8"));
|
|
261
|
+
current = LoreConfig.parse(raw);
|
|
262
|
+
return current;
|
|
263
|
+
}
|
|
259
264
|
}
|
|
260
265
|
current = LoreConfig.parse({});
|
|
261
266
|
return current;
|
package/src/db.ts
CHANGED
|
@@ -813,7 +813,7 @@ export function close() {
|
|
|
813
813
|
* an alias so subsequent calls skip the subprocess. If the matched project's
|
|
814
814
|
* git_remote was not yet populated (pre-v14 rows), it is backfilled lazily.
|
|
815
815
|
*/
|
|
816
|
-
export function ensureProject(path: string, name?: string): string {
|
|
816
|
+
export function ensureProject(path: string, name?: string, suppliedGitRemote?: string | null): string {
|
|
817
817
|
// Guard: reject synthetic test paths when targeting the production DB.
|
|
818
818
|
// Test paths like "/test/ltm/project" are absolute paths that don't exist
|
|
819
819
|
// on any real filesystem — they're only valid in test suites running against
|
|
@@ -836,21 +836,21 @@ export function ensureProject(path: string, name?: string): string {
|
|
|
836
836
|
if (existing) {
|
|
837
837
|
// Lazy backfill: populate git_remote on pre-v14 rows
|
|
838
838
|
if (!existing.git_remote) {
|
|
839
|
-
const
|
|
840
|
-
if (
|
|
839
|
+
const resolvedRemote = suppliedGitRemote ?? getGitRemote(path);
|
|
840
|
+
if (resolvedRemote) {
|
|
841
841
|
// Check for conflict: another project already has this git_remote.
|
|
842
842
|
// If so, merge the conflicting project into this one (one-time).
|
|
843
843
|
const conflict = db()
|
|
844
844
|
.query(
|
|
845
845
|
"SELECT id FROM projects WHERE git_remote = ? AND id != ? LIMIT 1",
|
|
846
846
|
)
|
|
847
|
-
.get(
|
|
847
|
+
.get(resolvedRemote, existing.id) as { id: string } | null;
|
|
848
848
|
if (conflict) {
|
|
849
849
|
mergeProjectInternal(conflict.id, existing.id);
|
|
850
850
|
}
|
|
851
851
|
db()
|
|
852
852
|
.query("UPDATE projects SET git_remote = ? WHERE id = ?")
|
|
853
|
-
.run(
|
|
853
|
+
.run(resolvedRemote, existing.id);
|
|
854
854
|
}
|
|
855
855
|
}
|
|
856
856
|
return existing.id;
|
|
@@ -863,7 +863,7 @@ export function ensureProject(path: string, name?: string): string {
|
|
|
863
863
|
if (alias) return alias.project_id;
|
|
864
864
|
|
|
865
865
|
// 3. Git remote identification
|
|
866
|
-
const gitRemote = getGitRemote(path);
|
|
866
|
+
const gitRemote = suppliedGitRemote ?? getGitRemote(path);
|
|
867
867
|
if (gitRemote) {
|
|
868
868
|
const byRemote = db()
|
|
869
869
|
.query("SELECT id FROM projects WHERE git_remote = ? LIMIT 1")
|
|
@@ -908,6 +908,39 @@ export function projectId(path: string): string | undefined {
|
|
|
908
908
|
return alias?.project_id;
|
|
909
909
|
}
|
|
910
910
|
|
|
911
|
+
/**
|
|
912
|
+
* Look up a project by git_remote (preferred) or path. Returns the project ID
|
|
913
|
+
* or null if not found. Unlike `ensureProject()`, this is read-only — it never
|
|
914
|
+
* creates a project or registers path aliases.
|
|
915
|
+
*/
|
|
916
|
+
export function resolveProjectByRemoteOrPath(
|
|
917
|
+
gitRemote?: string,
|
|
918
|
+
path?: string,
|
|
919
|
+
): string | null {
|
|
920
|
+
if (gitRemote) {
|
|
921
|
+
const row = db()
|
|
922
|
+
.query("SELECT id FROM projects WHERE git_remote = ? LIMIT 1")
|
|
923
|
+
.get(gitRemote) as { id: string } | null;
|
|
924
|
+
if (row) return row.id;
|
|
925
|
+
}
|
|
926
|
+
if (path) {
|
|
927
|
+
return projectId(path) ?? null;
|
|
928
|
+
}
|
|
929
|
+
return null;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
* Look up the path for a project by its internal ID.
|
|
934
|
+
* Used by the REST API to resolve project UUID → path for core functions
|
|
935
|
+
* that require a path argument.
|
|
936
|
+
*/
|
|
937
|
+
export function projectPath(id: string): string | null {
|
|
938
|
+
const row = db()
|
|
939
|
+
.query("SELECT path FROM projects WHERE id = ?")
|
|
940
|
+
.get(id) as { path: string } | null;
|
|
941
|
+
return row?.path ?? null;
|
|
942
|
+
}
|
|
943
|
+
|
|
911
944
|
/** Look up a project's display name by its internal ID. */
|
|
912
945
|
export function projectName(id: string): string | null {
|
|
913
946
|
const row = db()
|
package/src/embedding.ts
CHANGED
|
@@ -28,6 +28,27 @@ import type {
|
|
|
28
28
|
* embedding calls but bounded enough to avoid minutes-long hangs. */
|
|
29
29
|
const EMBED_TIMEOUT_MS = 10_000;
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Safe per-text character limit for local ONNX inference. The Nomic v1.5 model
|
|
33
|
+
* supports up to 8192 tokens, but ONNX runtime OOMs on inputs near that ceiling
|
|
34
|
+
* (error codes 284432024, 287180544, 144786472). Pre-truncating to ~4096 tokens
|
|
35
|
+
* worth of characters keeps the tensor well within safe allocation bounds.
|
|
36
|
+
* The worker's `truncation: true` remains as a safety net.
|
|
37
|
+
*/
|
|
38
|
+
const LOCAL_MAX_CHARS = 4096 * 4; // ~4096 tokens × ~4 chars/token
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Truncate a string to LOCAL_MAX_CHARS without splitting a UTF-16 surrogate pair.
|
|
42
|
+
* If the cut falls on a high surrogate (0xD800-0xDBFF), backs up one char.
|
|
43
|
+
*/
|
|
44
|
+
function safeLocalTruncate(text: string): string {
|
|
45
|
+
if (text.length <= LOCAL_MAX_CHARS) return text;
|
|
46
|
+
let end = LOCAL_MAX_CHARS;
|
|
47
|
+
const code = text.charCodeAt(end - 1);
|
|
48
|
+
if (code >= 0xD800 && code <= 0xDBFF) end--; // don't split surrogate pair
|
|
49
|
+
return text.slice(0, end);
|
|
50
|
+
}
|
|
51
|
+
|
|
31
52
|
// ---------------------------------------------------------------------------
|
|
32
53
|
// Provider interface
|
|
33
54
|
// ---------------------------------------------------------------------------
|
|
@@ -332,9 +353,10 @@ class LocalProvider implements EmbeddingProvider {
|
|
|
332
353
|
localProviderKnownBroken = true;
|
|
333
354
|
if (!localProviderErrorLogged) {
|
|
334
355
|
localProviderErrorLogged = true;
|
|
335
|
-
log.
|
|
356
|
+
log.error(
|
|
336
357
|
`local embedding provider failed to init: ${msg.error}. ` +
|
|
337
358
|
`Set VOYAGE_API_KEY/OPENAI_API_KEY for automatic remote fallback.`,
|
|
359
|
+
new Error(`embedding worker init failed: ${msg.error}`),
|
|
338
360
|
);
|
|
339
361
|
}
|
|
340
362
|
for (const [, p] of this.pendingRequests) {
|
|
@@ -351,6 +373,7 @@ class LocalProvider implements EmbeddingProvider {
|
|
|
351
373
|
this.worker.on("error", (err: Error) => {
|
|
352
374
|
this.workerInitError = err.message;
|
|
353
375
|
this.workerReady = false;
|
|
376
|
+
log.error("embedding worker crashed:", err);
|
|
354
377
|
for (const [, p] of this.pendingRequests) {
|
|
355
378
|
p.reject(new LocalProviderUnavailableError(err));
|
|
356
379
|
}
|
|
@@ -361,6 +384,10 @@ class LocalProvider implements EmbeddingProvider {
|
|
|
361
384
|
this.worker.on("exit", (code) => {
|
|
362
385
|
if (code !== 0 && !this.workerInitError) {
|
|
363
386
|
this.workerInitError = `embedding worker exited with code ${code}`;
|
|
387
|
+
log.error(
|
|
388
|
+
this.workerInitError,
|
|
389
|
+
new Error(this.workerInitError),
|
|
390
|
+
);
|
|
364
391
|
}
|
|
365
392
|
this.workerReady = false;
|
|
366
393
|
for (const [, p] of this.pendingRequests) {
|
|
@@ -396,9 +423,13 @@ class LocalProvider implements EmbeddingProvider {
|
|
|
396
423
|
async embed(texts: string[], inputType: "document" | "query"): Promise<Float32Array[]> {
|
|
397
424
|
await this.ensureWorker();
|
|
398
425
|
|
|
426
|
+
// Pre-truncate texts that exceed the safe ONNX inference limit.
|
|
427
|
+
// This prevents OOM on single inputs near the model's 8192-token max.
|
|
428
|
+
const truncated = texts.map(safeLocalTruncate);
|
|
429
|
+
|
|
399
430
|
// Prepend Nomic task instruction prefix.
|
|
400
431
|
const prefix = inputType === "document" ? "search_document: " : "search_query: ";
|
|
401
|
-
const prefixed =
|
|
432
|
+
const prefixed = truncated.map((t) => prefix + t);
|
|
402
433
|
|
|
403
434
|
const id = this.nextRequestId++;
|
|
404
435
|
// Recall queries (single query-type texts) get high priority so they
|
|
@@ -842,6 +873,7 @@ export function embedKnowledgeEntry(
|
|
|
842
873
|
title: string,
|
|
843
874
|
content: string,
|
|
844
875
|
): void {
|
|
876
|
+
if (!isAvailable()) return;
|
|
845
877
|
const text = `${title}\n${content}`;
|
|
846
878
|
embed([text], "document")
|
|
847
879
|
.then(([vec]) => {
|
|
@@ -850,7 +882,7 @@ export function embedKnowledgeEntry(
|
|
|
850
882
|
.run(toBlob(vec), id);
|
|
851
883
|
})
|
|
852
884
|
.catch((err) => {
|
|
853
|
-
log.
|
|
885
|
+
log.error("embedding failed for knowledge entry", id, ":", err);
|
|
854
886
|
});
|
|
855
887
|
}
|
|
856
888
|
|
|
@@ -863,6 +895,7 @@ export function embedDistillation(
|
|
|
863
895
|
id: string,
|
|
864
896
|
observations: string,
|
|
865
897
|
): void {
|
|
898
|
+
if (!isAvailable()) return;
|
|
866
899
|
embed([observations], "document")
|
|
867
900
|
.then(([vec]) => {
|
|
868
901
|
db()
|
|
@@ -870,7 +903,7 @@ export function embedDistillation(
|
|
|
870
903
|
.run(toBlob(vec), id);
|
|
871
904
|
})
|
|
872
905
|
.catch((err) => {
|
|
873
|
-
log.
|
|
906
|
+
log.error("embedding failed for distillation", id, ":", err);
|
|
874
907
|
});
|
|
875
908
|
}
|
|
876
909
|
|
|
@@ -884,6 +917,7 @@ export function embedTemporalMessage(
|
|
|
884
917
|
id: string,
|
|
885
918
|
content: string,
|
|
886
919
|
): void {
|
|
920
|
+
if (!isAvailable()) return;
|
|
887
921
|
// Skip very short messages — they don't carry enough semantic signal
|
|
888
922
|
// to be useful in vector search and would waste embedding capacity.
|
|
889
923
|
if (content.length < 50) return;
|
|
@@ -895,7 +929,7 @@ export function embedTemporalMessage(
|
|
|
895
929
|
.run(toBlob(vec), id);
|
|
896
930
|
})
|
|
897
931
|
.catch((err) => {
|
|
898
|
-
log.
|
|
932
|
+
log.error("embedding failed for temporal message", id, ":", err);
|
|
899
933
|
});
|
|
900
934
|
}
|
|
901
935
|
|
|
@@ -1199,6 +1233,8 @@ export async function backfillEmbeddings(): Promise<number> {
|
|
|
1199
1233
|
} catch (err) {
|
|
1200
1234
|
// log.error sends to Sentry via captureException
|
|
1201
1235
|
log.error(`embedding backfill batch failed (${batch.length} items):`, err);
|
|
1236
|
+
// Provider is dead — no point retrying remaining batches.
|
|
1237
|
+
if (err instanceof LocalProviderUnavailableError) break;
|
|
1202
1238
|
}
|
|
1203
1239
|
// No yieldToEventLoop() needed — embed() is truly async (worker thread).
|
|
1204
1240
|
}
|
|
@@ -1259,6 +1295,8 @@ export async function backfillDistillationEmbeddings(): Promise<number> {
|
|
|
1259
1295
|
} catch (err) {
|
|
1260
1296
|
// log.error sends to Sentry via captureException
|
|
1261
1297
|
log.error(`distillation embedding backfill batch failed (${batch.length} items):`, err);
|
|
1298
|
+
// Provider is dead — no point retrying remaining batches.
|
|
1299
|
+
if (err instanceof LocalProviderUnavailableError) break;
|
|
1262
1300
|
}
|
|
1263
1301
|
|
|
1264
1302
|
if (embedded >= nextProgressAt) {
|
package/src/git.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { execSync } from "child_process";
|
|
16
|
+
import { isHostedMode } from "./hosted";
|
|
16
17
|
|
|
17
18
|
// ---------------------------------------------------------------------------
|
|
18
19
|
// URL normalization
|
|
@@ -95,6 +96,9 @@ export function clearGitRemoteCache(): void {
|
|
|
95
96
|
* subprocess calls — `git remote -v` only runs once per unique path.
|
|
96
97
|
*/
|
|
97
98
|
export function getGitRemote(path: string): string | null {
|
|
99
|
+
// In hosted mode, never run git subprocesses with client-controlled cwd.
|
|
100
|
+
if (isHostedMode()) return null;
|
|
101
|
+
|
|
98
102
|
const cached = gitRemoteCache.get(path);
|
|
99
103
|
if (cached !== undefined) return cached;
|
|
100
104
|
|
package/src/gradient.ts
CHANGED
|
@@ -98,9 +98,42 @@ export function updateBustRate(
|
|
|
98
98
|
cacheWrite: number,
|
|
99
99
|
cacheRead: number,
|
|
100
100
|
sessionID?: string,
|
|
101
|
+
lastLayer?: number,
|
|
101
102
|
): void {
|
|
102
103
|
if (!sessionID) return;
|
|
103
104
|
const state = getSessionState(sessionID);
|
|
105
|
+
|
|
106
|
+
// Layer 4 (emergency) is structurally a full cache write — feeding its
|
|
107
|
+
// bust stats into the EMA and cap adaptation creates a death spiral where
|
|
108
|
+
// the cap ratchets down to MIN_CONTEXT_FLOOR and prevents the session from
|
|
109
|
+
// ever fitting in layers 1-3 again. Skip EMA updates entirely.
|
|
110
|
+
// This check is BEFORE the total===0 guard so that the consecutiveLayer4
|
|
111
|
+
// counter is always updated regardless of whether usage was reported.
|
|
112
|
+
if (lastLayer === 4) {
|
|
113
|
+
state.consecutiveLayer4++;
|
|
114
|
+
|
|
115
|
+
// Recovery hatch: after 5+ consecutive Layer 4 turns, the shrunken cap
|
|
116
|
+
// may be what's trapping us. Relax it by 10% per turn to give layers
|
|
117
|
+
// 1-3 a chance to fit. From 130K floor: turns 5-9 → 143K→157K→173K→190K→209K.
|
|
118
|
+
if (
|
|
119
|
+
state.consecutiveLayer4 >= 5 &&
|
|
120
|
+
state.dynamicContextCap > 0 &&
|
|
121
|
+
maxContextTokensCeiling > 0
|
|
122
|
+
) {
|
|
123
|
+
state.dynamicContextCap = Math.min(
|
|
124
|
+
maxContextTokensCeiling,
|
|
125
|
+
Math.floor(state.dynamicContextCap * 1.10),
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Non-Layer-4 turn: reset the consecutive counter (also before total===0
|
|
132
|
+
// guard — a zero-usage non-L4 turn must not leave a stale count).
|
|
133
|
+
if (lastLayer !== undefined) {
|
|
134
|
+
state.consecutiveLayer4 = 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
104
137
|
const total = cacheWrite + cacheRead;
|
|
105
138
|
if (total === 0) return;
|
|
106
139
|
|
|
@@ -253,6 +286,10 @@ type SessionState = {
|
|
|
253
286
|
postIdleCompact: boolean;
|
|
254
287
|
/** Consecutive turns at layer >= 2. When >= 3, log a compaction hint. */
|
|
255
288
|
consecutiveHighLayer: number;
|
|
289
|
+
/** Consecutive Layer 4 turns — used to skip bust-rate EMA updates
|
|
290
|
+
* (Layer 4 busts are structural, not a caching signal) and to trigger
|
|
291
|
+
* a recovery hatch that relaxes dynamicContextCap after prolonged trapping. */
|
|
292
|
+
consecutiveLayer4: number;
|
|
256
293
|
|
|
257
294
|
// --- Cost-aware context cap dynamic state ---
|
|
258
295
|
|
|
@@ -298,6 +335,7 @@ function makeSessionState(): SessionState {
|
|
|
298
335
|
cameOutOfIdle: false,
|
|
299
336
|
postIdleCompact: false,
|
|
300
337
|
consecutiveHighLayer: 0,
|
|
338
|
+
consecutiveLayer4: 0,
|
|
301
339
|
|
|
302
340
|
bustRateEMA: -1,
|
|
303
341
|
interBustIntervalEMA: -1,
|
|
@@ -605,6 +643,9 @@ export function inspectSessionState(sessionID: string): {
|
|
|
605
643
|
postIdleCompact: boolean;
|
|
606
644
|
lastTurnAt: number;
|
|
607
645
|
distillationSnapshot: DistillationSnapshot | null;
|
|
646
|
+
bustRateEMA: number;
|
|
647
|
+
dynamicContextCap: number;
|
|
648
|
+
consecutiveLayer4: number;
|
|
608
649
|
} | null {
|
|
609
650
|
const state = sessionStates.get(sessionID);
|
|
610
651
|
if (!state) return null;
|
|
@@ -615,6 +656,9 @@ export function inspectSessionState(sessionID: string): {
|
|
|
615
656
|
postIdleCompact: state.postIdleCompact,
|
|
616
657
|
lastTurnAt: state.lastTurnAt,
|
|
617
658
|
distillationSnapshot: state.distillationSnapshot,
|
|
659
|
+
bustRateEMA: state.bustRateEMA,
|
|
660
|
+
dynamicContextCap: state.dynamicContextCap,
|
|
661
|
+
consecutiveLayer4: state.consecutiveLayer4,
|
|
618
662
|
};
|
|
619
663
|
}
|
|
620
664
|
|