@loreai/core 0.18.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/curator.d.ts.map +1 -1
- package/dist/bun/db.d.ts +86 -1
- package/dist/bun/db.d.ts.map +1 -1
- package/dist/bun/distillation.d.ts +2 -13
- package/dist/bun/distillation.d.ts.map +1 -1
- package/dist/bun/embedding.d.ts +5 -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 +13 -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 +1049 -247
- package/dist/bun/index.js.map +4 -4
- package/dist/bun/lat-reader.d.ts.map +1 -1
- package/dist/bun/ltm.d.ts +99 -5
- package/dist/bun/ltm.d.ts.map +1 -1
- package/dist/bun/session-limiter.d.ts +26 -0
- package/dist/bun/session-limiter.d.ts.map +1 -0
- package/dist/bun/temporal.d.ts +2 -0
- package/dist/bun/temporal.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/curator.d.ts.map +1 -1
- package/dist/node/db.d.ts +86 -1
- package/dist/node/db.d.ts.map +1 -1
- package/dist/node/distillation.d.ts +2 -13
- package/dist/node/distillation.d.ts.map +1 -1
- package/dist/node/embedding.d.ts +5 -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 +13 -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 +1049 -247
- package/dist/node/index.js.map +4 -4
- package/dist/node/lat-reader.d.ts.map +1 -1
- package/dist/node/ltm.d.ts +99 -5
- package/dist/node/ltm.d.ts.map +1 -1
- package/dist/node/session-limiter.d.ts +26 -0
- package/dist/node/session-limiter.d.ts.map +1 -0
- package/dist/node/temporal.d.ts +2 -0
- package/dist/node/temporal.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/curator.d.ts.map +1 -1
- package/dist/types/db.d.ts +86 -1
- package/dist/types/db.d.ts.map +1 -1
- package/dist/types/distillation.d.ts +2 -13
- package/dist/types/distillation.d.ts.map +1 -1
- package/dist/types/embedding.d.ts +5 -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 +13 -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/dist/types/ltm.d.ts +99 -5
- package/dist/types/ltm.d.ts.map +1 -1
- package/dist/types/session-limiter.d.ts +26 -0
- package/dist/types/session-limiter.d.ts.map +1 -0
- package/dist/types/temporal.d.ts +2 -0
- package/dist/types/temporal.d.ts.map +1 -1
- package/package.json +3 -1
- package/src/agents-file.ts +12 -0
- package/src/config.ts +10 -5
- package/src/curator.ts +54 -2
- package/src/db.ts +386 -6
- package/src/distillation.ts +55 -14
- package/src/embedding.ts +71 -8
- package/src/git.ts +4 -0
- package/src/gradient.ts +227 -74
- package/src/hosted.ts +46 -0
- package/src/index.ts +12 -0
- package/src/lat-reader.ts +4 -0
- package/src/ltm.ts +480 -45
- package/src/session-limiter.ts +47 -0
- package/src/temporal.ts +10 -0
package/src/hosted.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
let _hostedMode = false;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Enable hosted mode. Once enabled, cannot be disabled.
|
|
25
|
+
* All filesystem operations using client-controlled paths become no-ops.
|
|
26
|
+
*/
|
|
27
|
+
export function enableHostedMode(): void {
|
|
28
|
+
_hostedMode = true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns true if hosted mode is active — filesystem operations using
|
|
33
|
+
* client-controlled paths should be skipped.
|
|
34
|
+
*/
|
|
35
|
+
export function isHostedMode(): boolean {
|
|
36
|
+
return _hostedMode;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Reset hosted mode flag. **Test-only** — production code should never
|
|
41
|
+
* call this. Exported so tests can toggle hosted mode without process
|
|
42
|
+
* restarts.
|
|
43
|
+
*/
|
|
44
|
+
export function _resetHostedModeForTest(): void {
|
|
45
|
+
_hostedMode = false;
|
|
46
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -66,6 +66,8 @@ export {
|
|
|
66
66
|
isFirstRun,
|
|
67
67
|
projectId,
|
|
68
68
|
projectName,
|
|
69
|
+
projectPath,
|
|
70
|
+
resolveProjectByRemoteOrPath,
|
|
69
71
|
mergeProjectInternal,
|
|
70
72
|
loadForceMinLayer,
|
|
71
73
|
saveForceMinLayer,
|
|
@@ -73,12 +75,20 @@ export {
|
|
|
73
75
|
loadSessionCosts,
|
|
74
76
|
loadAllSessionCosts,
|
|
75
77
|
type SessionCostSnapshot,
|
|
78
|
+
saveSessionTracking,
|
|
79
|
+
loadSessionTracking,
|
|
80
|
+
loadHeaderSessionIndex,
|
|
81
|
+
type SessionTrackingState,
|
|
82
|
+
type LoadedSessionTracking,
|
|
83
|
+
getKV,
|
|
84
|
+
setKV,
|
|
76
85
|
getMeta,
|
|
77
86
|
setMeta,
|
|
78
87
|
getInstanceId,
|
|
79
88
|
close,
|
|
80
89
|
} from "./db";
|
|
81
90
|
export { normalizeRemoteUrl, getGitRemote, clearGitRemoteCache } from "./git";
|
|
91
|
+
export { enableHostedMode, isHostedMode } from "./hosted";
|
|
82
92
|
export {
|
|
83
93
|
transform,
|
|
84
94
|
setModelLimits,
|
|
@@ -96,10 +106,12 @@ export {
|
|
|
96
106
|
setForceMinLayer,
|
|
97
107
|
getLastTransformedCount,
|
|
98
108
|
getLastTransformEstimate,
|
|
109
|
+
getLastLayer,
|
|
99
110
|
toolStripAnnotation,
|
|
100
111
|
onIdleResume,
|
|
101
112
|
getLastTurnAt,
|
|
102
113
|
consumeCameOutOfIdle,
|
|
114
|
+
saveGradientState,
|
|
103
115
|
// Test-only — exposed at the barrel so host-package tests can simulate idle
|
|
104
116
|
// gaps without sleeping. Not part of the public API.
|
|
105
117
|
setLastTurnAtForTest,
|
package/src/lat-reader.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { db, ensureProject } from "./db";
|
|
|
17
17
|
import { sha256 } from "#db/driver";
|
|
18
18
|
import { ftsQuery, extractTopTerms, EMPTY_QUERY, runRelaxedSearch } from "./search";
|
|
19
19
|
import * as log from "./log";
|
|
20
|
+
import { isHostedMode } from "./hosted";
|
|
20
21
|
|
|
21
22
|
const processor = remark();
|
|
22
23
|
|
|
@@ -179,6 +180,7 @@ function contentHash(content: string): string {
|
|
|
179
180
|
|
|
180
181
|
/** Check if a project has a lat.md/ directory. */
|
|
181
182
|
export function hasLatDir(projectPath: string): boolean {
|
|
183
|
+
if (isHostedMode()) return false;
|
|
182
184
|
const latDir = join(projectPath, "lat.md");
|
|
183
185
|
return existsSync(latDir) && statSync(latDir).isDirectory();
|
|
184
186
|
}
|
|
@@ -192,6 +194,8 @@ export function hasLatDir(projectPath: string): boolean {
|
|
|
192
194
|
* @returns Number of sections updated/inserted
|
|
193
195
|
*/
|
|
194
196
|
export function refresh(projectPath: string): number {
|
|
197
|
+
if (isHostedMode()) return 0;
|
|
198
|
+
|
|
195
199
|
const latDir = join(projectPath, "lat.md");
|
|
196
200
|
if (!existsSync(latDir) || !statSync(latDir).isDirectory()) return 0;
|
|
197
201
|
|