@loreai/core 0.19.0 → 0.20.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/agents-file.d.ts.map +1 -1
- package/dist/bun/config.d.ts +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 +39 -13
- 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 +295 -235
- 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 +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 +39 -13
- 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 +295 -235
- 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 +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 +39 -13
- 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 +14 -17
- package/src/db.ts +39 -6
- package/src/embedding.ts +43 -5
- package/src/git.ts +4 -0
- package/src/gradient.ts +167 -145
- package/src/hosted.ts +46 -0
- package/src/index.ts +9 -4
- 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"}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const LoreConfig: z.ZodObject<{
|
|
|
15
15
|
ltm: z.ZodDefault<z.ZodNumber>;
|
|
16
16
|
targetCacheReadCostPerTurn: z.ZodDefault<z.ZodNumber>;
|
|
17
17
|
maxLayer0Tokens: z.ZodOptional<z.ZodNumber>;
|
|
18
|
-
targetBustCost: z.ZodDefault<z.ZodNumber
|
|
18
|
+
targetBustCost: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
19
19
|
maxContextTokens: z.ZodOptional<z.ZodNumber>;
|
|
20
20
|
}, z.core.$strip>>;
|
|
21
21
|
idleResumeMinutes: z.ZodDefault<z.ZodNumber>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsOrB,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,wBAAgB,MAAM,IAAI,MAAM,CAI/B;AAID,wBAAgB,EAAE,IAAI,QAAQ,CA8C7B;AAsHD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,IAAI,CAoCN;AAED,wBAAgB,KAAK,SAKpB;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,
|
|
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,wBAAgB,MAAM,IAAI,MAAM,CAI/B;AAID,wBAAgB,EAAE,IAAI,QAAQ,CA8C7B;AAsHD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MA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AE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC,CAiBD;AAMD,6DAA6D;AAC7D,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKhD;AAED,oCAAoC;AACpC,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAMtD;AAMD,8DAA8D;AAC9D,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKlD;AAED,qCAAqC;AACrC,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAMxD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,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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;AAMD,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAiBF,wBAAgB,4BAA4B,CAC1C,cAAc,EAAE,YAAY,EAC5B,SAAS,EAAE,MAAM,EACjB,KAAK,SAAK,GACT,qBAAqB,EAAE,CAgBzB;AAMD;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GACd,IAAI,CAYN;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,MAAM,EACV,YAAY,EAAE,MAAM,GACnB,IAAI,CAWN;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,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
|
@@ -1,23 +1,44 @@
|
|
|
1
1
|
import type { LoreMessageWithParts } from "./types";
|
|
2
2
|
type MessageWithParts = LoreMessageWithParts;
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Set cache pricing for the current model. Called by the host adapter after
|
|
5
|
+
* looking up model cost data. Required for tier-based bust-vs-continue
|
|
6
|
+
* decisions. When not set (both 0), tier decisions fall back to conservative
|
|
7
|
+
* defaults: always compress at tier boundaries.
|
|
8
|
+
*/
|
|
9
|
+
export declare function setCachePricing(writeCost: number, readCost: number): void;
|
|
10
|
+
/** Returns current pricing (for tests). */
|
|
11
|
+
export declare function getCachePricing(): {
|
|
12
|
+
write: number;
|
|
13
|
+
read: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Decide whether compression is economical at a tier boundary.
|
|
17
|
+
*
|
|
18
|
+
* @param currentTokens - expected input tokens if we stay at the current layer
|
|
19
|
+
* @param compressedTokens - expected tokens after compression
|
|
20
|
+
* @param consecutiveBusts - how many turns in a row we've busted the cache
|
|
21
|
+
* @param threshold - bust cost must be < threshold × continue cost to compress (default 0.85)
|
|
22
|
+
* @returns true if compression is worth it
|
|
23
|
+
*/
|
|
24
|
+
export declare function shouldCompress(currentTokens: number, compressedTokens: number, consecutiveBusts: number, threshold?: number): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Determine which tier the given token count falls into.
|
|
27
|
+
* Returns 0, 1, or 2 corresponding to the tier index.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getTier(tokens: number): number;
|
|
30
|
+
/**
|
|
31
|
+
* Record cache usage from an API response. Tracks consecutive busts for
|
|
32
|
+
* the rolling bust detection used by shouldCompress().
|
|
33
|
+
*
|
|
34
|
+
* A "bust" is when cache_write > 50% of total input tokens.
|
|
15
35
|
*
|
|
16
36
|
* @param cacheWrite - cache_creation_input_tokens from the API response
|
|
17
37
|
* @param cacheRead - cache_read_input_tokens from the API response
|
|
38
|
+
* @param inputTokens - total input_tokens from the API response (includes uncached)
|
|
18
39
|
* @param sessionID - session that produced this response
|
|
19
40
|
*/
|
|
20
|
-
export declare function
|
|
41
|
+
export declare function recordCacheUsage(cacheWrite: number, cacheRead: number, inputTokens: number, sessionID?: string): void;
|
|
21
42
|
type DistillationSnapshot = {
|
|
22
43
|
/** Cached distillation rows from the most recent DB read */
|
|
23
44
|
rows: Distillation[];
|
|
@@ -141,6 +162,7 @@ export declare function inspectSessionState(sessionID: string): {
|
|
|
141
162
|
postIdleCompact: boolean;
|
|
142
163
|
lastTurnAt: number;
|
|
143
164
|
distillationSnapshot: DistillationSnapshot | null;
|
|
165
|
+
consecutiveBusts: number;
|
|
144
166
|
} | null;
|
|
145
167
|
/**
|
|
146
168
|
* For testing only — set the session's lastTurnAt field. Used to simulate
|
|
@@ -215,6 +237,10 @@ export type TransformResult = {
|
|
|
215
237
|
distilledBudget: number;
|
|
216
238
|
rawBudget: number;
|
|
217
239
|
refreshLtm: boolean;
|
|
240
|
+
/** When set, the conversation is growing unsustainably — 5+ consecutive
|
|
241
|
+
* cache busts detected. The pipeline should inject a warning message
|
|
242
|
+
* advising the user to compact or start a new conversation. */
|
|
243
|
+
unsustainable?: boolean;
|
|
218
244
|
};
|
|
219
245
|
export declare function needsUrgentDistillation(sessionID: string): boolean;
|
|
220
246
|
export declare function transform(input: {
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"gradient.d.ts","sourceRoot":"","sources":["../../src/gradient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,oBAAoB,EAAqE,MAAM,SAAS,CAAC;AAQ9I,KAAK,gBAAgB,GAAG,oBAAoB,CAAC;AAyD7C;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAGlE;AAED,2CAA2C;AAC3C,wBAAgB,eAAe,IAAI;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAEjE;AAWD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM,EACxB,SAAS,SAAO,GACf,OAAO,CAeT;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAI9C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI,CAeN;AA4BD,KAAK,oBAAoB,GAAG;IAC1B,4DAA4D;IAC5D,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAqIF;;;;;;;;;;;;;;;;;;;;;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,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, setCachePricing, getCachePricing, shouldCompress, getTier, recordCacheUsage, 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,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,eAAe,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,iBAAiB,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,kBAAkB,MAAM,UAAU,CAAC;AAE/C,OAAO,EACL,SAAS,EACT,YAAY,EACZ,UAAU,EACV,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,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,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EACL,EAAE,EACF,MAAM,EACN,aAAa,EACb,eAAe,EACf,eAAe,EACf,UAAU,EACV,SAAS,EACT,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,EACL,KAAK,EACL,OAAO,EACP,OAAO,EACP,aAAa,EACb,KAAK,GACN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,EACL,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,
|
|
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,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O,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,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loreai/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "FSL-1.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
|
|
@@ -35,20 +36,12 @@ export const LoreConfig = z.object({
|
|
|
35
36
|
* cost-aware formula from targetCacheReadCostPerTurn. 0 = disabled
|
|
36
37
|
* (no cap, use full context). Default: undefined (use cost-aware auto). */
|
|
37
38
|
maxLayer0Tokens: z.number().min(0).optional(),
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* For opus-4-6 ($6.25/M write): $1.00 → 160K cap.
|
|
42
|
-
* For sonnet-4 ($3.75/M write): $1.00 → 267K (effectively uncapped at 200K).
|
|
43
|
-
* The cap is further adjusted dynamically per session based on observed
|
|
44
|
-
* bust rate (EMA) and break frequency. Default: 1.00. Set to 0 to disable. */
|
|
45
|
-
targetBustCost: z.number().min(0).default(1.00),
|
|
46
|
-
/** Direct override for the total-context token cap at layer 1+. When set,
|
|
47
|
-
* bypasses the cost-aware formula from targetBustCost. 0 = disabled.
|
|
48
|
-
* Default: undefined (use cost-aware auto). */
|
|
39
|
+
/** @deprecated Ignored. Tier-based bust-vs-continue replaces static cap. */
|
|
40
|
+
targetBustCost: z.number().min(0).default(1.00).optional(),
|
|
41
|
+
/** @deprecated Ignored. Tier-based bust-vs-continue replaces static cap. */
|
|
49
42
|
maxContextTokens: z.number().min(0).optional(),
|
|
50
43
|
})
|
|
51
|
-
.default({ distilled: 0.25, raw: 0.4, output: 0.25, ltm: 0.05, targetCacheReadCostPerTurn: 0.10
|
|
44
|
+
.default({ distilled: 0.25, raw: 0.4, output: 0.25, ltm: 0.05, targetCacheReadCostPerTurn: 0.10 }),
|
|
52
45
|
/**
|
|
53
46
|
* Cold-cache idle-resume handling.
|
|
54
47
|
*
|
|
@@ -251,11 +244,15 @@ export function config(): LoreConfig {
|
|
|
251
244
|
}
|
|
252
245
|
|
|
253
246
|
export async function load(directory: string): Promise<LoreConfig> {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
247
|
+
// In hosted mode, never read config from client-controlled paths —
|
|
248
|
+
// a crafted .lore.json could alter gateway behavior (budget, model, thresholds).
|
|
249
|
+
if (!isHostedMode()) {
|
|
250
|
+
const path = join(directory, ".lore.json");
|
|
251
|
+
if (existsSync(path)) {
|
|
252
|
+
const raw = JSON.parse(readFileSync(path, "utf8"));
|
|
253
|
+
current = LoreConfig.parse(raw);
|
|
254
|
+
return current;
|
|
255
|
+
}
|
|
259
256
|
}
|
|
260
257
|
current = LoreConfig.parse({});
|
|
261
258
|
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()
|