@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.
Files changed (53) hide show
  1. package/dist/bun/agents-file.d.ts.map +1 -1
  2. package/dist/bun/config.d.ts.map +1 -1
  3. package/dist/bun/db.d.ts +13 -1
  4. package/dist/bun/db.d.ts.map +1 -1
  5. package/dist/bun/embedding.d.ts.map +1 -1
  6. package/dist/bun/git.d.ts.map +1 -1
  7. package/dist/bun/gradient.d.ts +4 -1
  8. package/dist/bun/gradient.d.ts.map +1 -1
  9. package/dist/bun/hosted.d.ts +36 -0
  10. package/dist/bun/hosted.d.ts.map +1 -0
  11. package/dist/bun/index.d.ts +3 -2
  12. package/dist/bun/index.d.ts.map +1 -1
  13. package/dist/bun/index.js +236 -152
  14. package/dist/bun/index.js.map +4 -4
  15. package/dist/bun/lat-reader.d.ts.map +1 -1
  16. package/dist/node/agents-file.d.ts.map +1 -1
  17. package/dist/node/config.d.ts.map +1 -1
  18. package/dist/node/db.d.ts +13 -1
  19. package/dist/node/db.d.ts.map +1 -1
  20. package/dist/node/embedding.d.ts.map +1 -1
  21. package/dist/node/git.d.ts.map +1 -1
  22. package/dist/node/gradient.d.ts +4 -1
  23. package/dist/node/gradient.d.ts.map +1 -1
  24. package/dist/node/hosted.d.ts +36 -0
  25. package/dist/node/hosted.d.ts.map +1 -0
  26. package/dist/node/index.d.ts +3 -2
  27. package/dist/node/index.d.ts.map +1 -1
  28. package/dist/node/index.js +236 -152
  29. package/dist/node/index.js.map +4 -4
  30. package/dist/node/lat-reader.d.ts.map +1 -1
  31. package/dist/types/agents-file.d.ts.map +1 -1
  32. package/dist/types/config.d.ts.map +1 -1
  33. package/dist/types/db.d.ts +13 -1
  34. package/dist/types/db.d.ts.map +1 -1
  35. package/dist/types/embedding.d.ts.map +1 -1
  36. package/dist/types/git.d.ts.map +1 -1
  37. package/dist/types/gradient.d.ts +4 -1
  38. package/dist/types/gradient.d.ts.map +1 -1
  39. package/dist/types/hosted.d.ts +36 -0
  40. package/dist/types/hosted.d.ts.map +1 -0
  41. package/dist/types/index.d.ts +3 -2
  42. package/dist/types/index.d.ts.map +1 -1
  43. package/dist/types/lat-reader.d.ts.map +1 -1
  44. package/package.json +2 -1
  45. package/src/agents-file.ts +12 -0
  46. package/src/config.ts +10 -5
  47. package/src/db.ts +39 -6
  48. package/src/embedding.ts +43 -5
  49. package/src/git.ts +4 -0
  50. package/src/gradient.ts +44 -0
  51. package/src/hosted.ts +46 -0
  52. package/src/index.ts +4 -0
  53. package/src/lat-reader.ts +4 -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,
@@ -86,6 +88,7 @@ export {
86
88
  close,
87
89
  } from "./db";
88
90
  export { normalizeRemoteUrl, getGitRemote, clearGitRemoteCache } from "./git";
91
+ export { enableHostedMode, isHostedMode } from "./hosted";
89
92
  export {
90
93
  transform,
91
94
  setModelLimits,
@@ -103,6 +106,7 @@ export {
103
106
  setForceMinLayer,
104
107
  getLastTransformedCount,
105
108
  getLastTransformEstimate,
109
+ getLastLayer,
106
110
  toolStripAnnotation,
107
111
  onIdleResume,
108
112
  getLastTurnAt,
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