@velum-labs/routekit-daemon 0.18.0 → 0.18.2

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/README.md CHANGED
@@ -2,12 +2,17 @@
2
2
 
3
3
  Composition root for RouteKit's singleton daemon.
4
4
 
5
- One process owns the authenticated private control listener and a stable
6
- OpenAI-compatible data listener. Router generations run behind the stable
7
- front door: config/account changes build a complete candidate, atomically
8
- switch new requests, then drain the old generation. The daemon is the sole
9
- writer for canonical config, account enrollment, revisions, catalog/health
10
- snapshots, and telemetry state.
5
+ A stable cluster primary owns singleton authority, service records, the shared
6
+ control/data listener handles, Portless registration, and the managed
7
+ CLIProxyAPI sidecar. One active worker owns the RouteKit control plane, router
8
+ generations, account state, and telemetry. Config/account changes replace the
9
+ inner router generation; restart and upgrade replace the worker while the
10
+ primary and public ports remain stable. Failed candidates leave the active
11
+ worker serving traffic.
12
+
13
+ `startRouteKitDaemon` remains the standalone composition root for embedders and
14
+ tests. Production `routekit daemon run` uses `startRouteKitDaemonHost` in the
15
+ primary and `runRouteKitDaemonWorker` in cluster workers.
11
16
 
12
17
  Applications normally use it through `@velum-labs/routekit`; embedders should keep
13
18
  using `@velum-labs/routekit-router` instead of claiming the singleton service record.
@@ -0,0 +1,88 @@
1
+ import type { RouteKitControlParams, RouteKitControlResults } from "@velum-labs/routekit-control";
2
+ export declare const DAEMON_HOST_PROTOCOL_VERSION = 1;
3
+ export declare const ROUTEKIT_DAEMON_WORKER_ENV = "ROUTEKIT_DAEMON_WORKER";
4
+ export declare const ROUTEKIT_DAEMON_GENERATION_ENV = "ROUTEKIT_DAEMON_GENERATION";
5
+ export declare const ROUTEKIT_DAEMON_CONTROL_TOKEN_ENV = "ROUTEKIT_DAEMON_CONTROL_TOKEN";
6
+ export declare const ROUTEKIT_DAEMON_DATA_URL_ENV = "ROUTEKIT_DAEMON_DATA_URL";
7
+ export declare const ROUTEKIT_DAEMON_DATA_PORT_ENV = "ROUTEKIT_DAEMON_DATA_PORT";
8
+ export declare const ROUTEKIT_DAEMON_CONTROL_PORT_ENV = "ROUTEKIT_DAEMON_CONTROL_PORT";
9
+ export declare const ROUTEKIT_DAEMON_HOST_PID_ENV = "ROUTEKIT_DAEMON_HOST_PID";
10
+ export declare const ROUTEKIT_DAEMON_HOST_STARTED_AT_ENV = "ROUTEKIT_DAEMON_HOST_STARTED_AT";
11
+ export declare const ROUTEKIT_DAEMON_INITIAL_PAUSED_ENV = "ROUTEKIT_DAEMON_INITIAL_PAUSED";
12
+ export type WorkerSnapshot = {
13
+ generation: number;
14
+ configRevision: number;
15
+ accountRevision: number;
16
+ configHash: string;
17
+ };
18
+ export type WorkerReady = WorkerSnapshot & {
19
+ type: "worker.ready";
20
+ protocolVersion: number;
21
+ workerPid: number;
22
+ workerProcessIdentity?: string;
23
+ workerStartedAt: string;
24
+ packageVersion: string;
25
+ controlUrl: string;
26
+ controlPort: number;
27
+ dataUrl: string;
28
+ dataPort: number;
29
+ binPath?: string;
30
+ };
31
+ export type WorkerRequest = {
32
+ type: "worker.pause";
33
+ requestId: string;
34
+ } | {
35
+ type: "worker.resume";
36
+ requestId: string;
37
+ } | {
38
+ type: "worker.retire";
39
+ requestId: string;
40
+ graceMs: number;
41
+ } | {
42
+ type: "worker.shutdown";
43
+ requestId: string;
44
+ } | {
45
+ type: "worker.hostState";
46
+ requestId: string;
47
+ dataUrl: string;
48
+ hostPid: number;
49
+ hostStartedAt: string;
50
+ rolling: boolean;
51
+ };
52
+ export type WorkerResponse = {
53
+ type: "worker.response";
54
+ requestId: string;
55
+ ok: true;
56
+ result?: unknown;
57
+ } | {
58
+ type: "worker.response";
59
+ requestId: string;
60
+ ok: false;
61
+ error: string;
62
+ };
63
+ export type WorkerToHostRequest = {
64
+ type: "host.roll";
65
+ requestId: string;
66
+ params: RouteKitControlParams["daemon.roll"];
67
+ } | {
68
+ type: "host.shutdown";
69
+ reason: "stop" | "restart" | "upgrade";
70
+ } | {
71
+ type: "host.sidecar";
72
+ requestId: string;
73
+ operation: "reconcile" | "refresh" | "reachable" | "status";
74
+ wanted?: boolean;
75
+ timeoutMs?: number;
76
+ };
77
+ export type HostToWorkerResponse = {
78
+ type: "host.response";
79
+ requestId: string;
80
+ ok: true;
81
+ result?: RouteKitControlResults["daemon.roll"] | unknown;
82
+ } | {
83
+ type: "host.response";
84
+ requestId: string;
85
+ ok: false;
86
+ error: string;
87
+ };
88
+ export type HostWorkerMessage = WorkerReady | WorkerRequest | WorkerResponse | WorkerToHostRequest | HostToWorkerResponse;
@@ -0,0 +1,10 @@
1
+ export const DAEMON_HOST_PROTOCOL_VERSION = 1;
2
+ export const ROUTEKIT_DAEMON_WORKER_ENV = "ROUTEKIT_DAEMON_WORKER";
3
+ export const ROUTEKIT_DAEMON_GENERATION_ENV = "ROUTEKIT_DAEMON_GENERATION";
4
+ export const ROUTEKIT_DAEMON_CONTROL_TOKEN_ENV = "ROUTEKIT_DAEMON_CONTROL_TOKEN";
5
+ export const ROUTEKIT_DAEMON_DATA_URL_ENV = "ROUTEKIT_DAEMON_DATA_URL";
6
+ export const ROUTEKIT_DAEMON_DATA_PORT_ENV = "ROUTEKIT_DAEMON_DATA_PORT";
7
+ export const ROUTEKIT_DAEMON_CONTROL_PORT_ENV = "ROUTEKIT_DAEMON_CONTROL_PORT";
8
+ export const ROUTEKIT_DAEMON_HOST_PID_ENV = "ROUTEKIT_DAEMON_HOST_PID";
9
+ export const ROUTEKIT_DAEMON_HOST_STARTED_AT_ENV = "ROUTEKIT_DAEMON_HOST_STARTED_AT";
10
+ export const ROUTEKIT_DAEMON_INITIAL_PAUSED_ENV = "ROUTEKIT_DAEMON_INITIAL_PAUSED";
package/dist/host.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { ServiceRecord } from "@velum-labs/routekit-runtime";
2
+ import type { RouteKitDaemonOptions } from "./index.js";
3
+ export type RunningRouteKitDaemonHost = {
4
+ record: ServiceRecord;
5
+ dataUrl: string;
6
+ controlUrl: string;
7
+ close(): Promise<void>;
8
+ };
9
+ export declare function startRouteKitDaemonHost(options: RouteKitDaemonOptions & {
10
+ entryPath: string;
11
+ }): Promise<RunningRouteKitDaemonHost>;