@loreai/gateway 0.17.1 → 0.19.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/index.d.cts CHANGED
@@ -1,21 +1,80 @@
1
- export type GatewayConfig = {
2
- /** Port to listen on. Defaults to 4141. */
1
+ /** Gateway configuration loaded from environment variables with sensible defaults. */
2
+ export interface GatewayConfig {
3
+ /** Port to listen on. Default: 3207. Env: LORE_LISTEN_PORT */
4
+ port: number;
5
+ /** True when the port was explicitly set via LORE_LISTEN_PORT or --port. */
6
+ portExplicit: boolean;
7
+ /**
8
+ * Hosts to bind to. Default: ["127.0.0.1"].
9
+ * Env: LORE_LISTEN_HOST (comma-separated for multiple addresses).
10
+ */
11
+ hosts: string[];
12
+ /** Upstream Anthropic API URL. Default: "https://api.anthropic.com". Env: LORE_UPSTREAM_ANTHROPIC */
13
+ upstreamAnthropic: string;
14
+ /** Upstream OpenAI API URL. Default: "https://api.openai.com". Env: LORE_UPSTREAM_OPENAI */
15
+ upstreamOpenAI: string;
16
+ /** Idle timeout in seconds before triggering background work. Default: 60 */
17
+ idleTimeoutSeconds: number;
18
+ /** Whether to log requests. Default: false. Env: LORE_DEBUG */
19
+ debug: boolean;
20
+ }
21
+
22
+ export interface StartOptions {
3
23
  port?: number;
4
- /** Host to bind to. Defaults to "127.0.0.1". */
5
- host?: string;
6
- };
24
+ hosts?: string[];
25
+ debug?: boolean;
26
+ /** Suppress verbose banner (env vars, export hints). Used in embedded mode. */
27
+ quiet?: boolean;
28
+ }
29
+
30
+ export interface GatewayHandle {
31
+ config: GatewayConfig;
32
+ port: number;
33
+ /** Whether this process owns the server (started it). False when reusing an existing instance. */
34
+ owned: boolean;
35
+ /** Shut down the gateway. No-op when owned is false. */
36
+ shutdown: () => Promise<void>;
37
+ }
38
+
39
+ /** Default port preference order when LORE_LISTEN_PORT is not set. */
40
+ export declare const DEFAULT_PORTS: readonly [3207, 5673];
41
+
42
+ /** The primary default port (first in the fallback chain). */
43
+ export declare const DEFAULT_PORT: 3207;
7
44
 
8
45
  /** Load Lore gateway configuration from the environment. */
9
46
  export declare function loadConfig(): GatewayConfig;
10
47
 
11
- /** Start the Lore gateway server. */
12
- export declare function startServer(config?: GatewayConfig): Promise<void>;
48
+ /**
49
+ * Start the Lore gateway server.
50
+ *
51
+ * Prefer startGateway() for most use cases — it handles port fallback,
52
+ * port file management, and existing-instance reuse automatically.
53
+ */
54
+ export declare function startServer(config: GatewayConfig): {
55
+ stop: () => void;
56
+ port: number;
57
+ hosts: string[];
58
+ };
59
+
60
+ /**
61
+ * Start the gateway with port fallback, port file management, and
62
+ * existing-instance detection. This is the recommended entry point
63
+ * for plugins and programmatic use.
64
+ */
65
+ export declare function startGateway(opts?: StartOptions): Promise<GatewayHandle>;
66
+
67
+ /**
68
+ * Probe a running gateway at the given URL via its /health endpoint.
69
+ * Returns true if the response is 2xx, false on any error or timeout.
70
+ */
71
+ export declare function probeGateway(baseURL: string, timeoutMs?: number): Promise<boolean>;
13
72
 
14
- /** Handle an incoming request through the Lore pipeline. */
15
- export declare function handleRequest(req: Request): Promise<Response>;
73
+ /** Read the port file. Returns the port number or null if not found/invalid. */
74
+ export declare function readPortFile(): number | null;
16
75
 
17
76
  /** Reset internal pipeline state (for testing). */
18
- export declare function resetPipelineState(): void;
77
+ export declare function resetPipelineState(): Promise<void>;
19
78
 
20
79
  /** CLI entry point — called by dist/bin.cjs. */
21
80
  export declare function _cli(): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loreai/gateway",
3
- "version": "0.17.1",
3
+ "version": "0.19.0",
4
4
  "type": "module",
5
5
  "license": "FSL-1.1-Apache-2.0",
6
6
  "description": "Lore as a transparent LLM proxy — context management for any AI coding client",
@@ -28,6 +28,7 @@
28
28
  "dependencies": {},
29
29
  "files": [
30
30
  "dist/bin.cjs",
31
+ "dist/embedding-worker.cjs",
31
32
  "dist/index.cjs",
32
33
  "dist/index.d.cts"
33
34
  ],
@@ -54,7 +55,7 @@
54
55
  ],
55
56
  "author": "BYK",
56
57
  "devDependencies": {
57
- "@loreai/core": "0.17.1",
58
+ "@loreai/core": "0.19.0",
58
59
  "@sentry/bun": "^10.52.0",
59
60
  "binpunch": "^1.0.0"
60
61
  }