@amalgm/core 0.1.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/PURPOSE.md +94 -0
- package/README.md +30 -0
- package/dist/adapters/index.d.ts +13 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +11 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/identity/auth-records.d.ts +147 -0
- package/dist/identity/auth-records.d.ts.map +1 -0
- package/dist/identity/auth-records.js +354 -0
- package/dist/identity/auth-records.js.map +1 -0
- package/dist/identity/ids.d.ts +57 -0
- package/dist/identity/ids.d.ts.map +1 -0
- package/dist/identity/ids.js +80 -0
- package/dist/identity/ids.js.map +1 -0
- package/dist/identity/index.d.ts +14 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/identity/index.js +14 -0
- package/dist/identity/index.js.map +1 -0
- package/dist/identity/labels.d.ts +115 -0
- package/dist/identity/labels.d.ts.map +1 -0
- package/dist/identity/labels.js +154 -0
- package/dist/identity/labels.js.map +1 -0
- package/dist/identity/layout.d.ts +188 -0
- package/dist/identity/layout.d.ts.map +1 -0
- package/dist/identity/layout.js +233 -0
- package/dist/identity/layout.js.map +1 -0
- package/dist/identity/ports.d.ts +31 -0
- package/dist/identity/ports.d.ts.map +1 -0
- package/dist/identity/ports.js +9 -0
- package/dist/identity/ports.js.map +1 -0
- package/dist/identity/product-state.d.ts +49 -0
- package/dist/identity/product-state.d.ts.map +1 -0
- package/dist/identity/product-state.js +55 -0
- package/dist/identity/product-state.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/supervision/app-health.d.ts +148 -0
- package/dist/supervision/app-health.d.ts.map +1 -0
- package/dist/supervision/app-health.js +165 -0
- package/dist/supervision/app-health.js.map +1 -0
- package/dist/supervision/app-restart.d.ts +105 -0
- package/dist/supervision/app-restart.d.ts.map +1 -0
- package/dist/supervision/app-restart.js +97 -0
- package/dist/supervision/app-restart.js.map +1 -0
- package/dist/supervision/health.d.ts +218 -0
- package/dist/supervision/health.d.ts.map +1 -0
- package/dist/supervision/health.js +227 -0
- package/dist/supervision/health.js.map +1 -0
- package/dist/supervision/index.d.ts +17 -0
- package/dist/supervision/index.d.ts.map +1 -0
- package/dist/supervision/index.js +17 -0
- package/dist/supervision/index.js.map +1 -0
- package/dist/supervision/service-registration.d.ts +343 -0
- package/dist/supervision/service-registration.d.ts.map +1 -0
- package/dist/supervision/service-registration.js +543 -0
- package/dist/supervision/service-registration.js.map +1 -0
- package/dist/supervision/update.d.ts +231 -0
- package/dist/supervision/update.d.ts.map +1 -0
- package/dist/supervision/update.js +336 -0
- package/dist/supervision/update.js.map +1 -0
- package/dist/transport/admission.d.ts +235 -0
- package/dist/transport/admission.d.ts.map +1 -0
- package/dist/transport/admission.js +313 -0
- package/dist/transport/admission.js.map +1 -0
- package/dist/transport/auth.d.ts +232 -0
- package/dist/transport/auth.d.ts.map +1 -0
- package/dist/transport/auth.js +266 -0
- package/dist/transport/auth.js.map +1 -0
- package/dist/transport/index.d.ts +21 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +21 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/transport/ingress.d.ts +94 -0
- package/dist/transport/ingress.d.ts.map +1 -0
- package/dist/transport/ingress.js +171 -0
- package/dist/transport/ingress.js.map +1 -0
- package/dist/transport/routing.d.ts +235 -0
- package/dist/transport/routing.d.ts.map +1 -0
- package/dist/transport/routing.js +288 -0
- package/dist/transport/routing.js.map +1 -0
- package/dist/transport/shipped-routes.d.ts +21 -0
- package/dist/transport/shipped-routes.d.ts.map +1 -0
- package/dist/transport/shipped-routes.js +53 -0
- package/dist/transport/shipped-routes.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host launcher registration laws — how the runtime enrolls itself with
|
|
3
|
+
* launchd, systemd, a Windows startup script, or the portable watchdog,
|
|
4
|
+
* and how it recognizes its own processes and state afterwards.
|
|
5
|
+
*
|
|
6
|
+
* Axiom 6: a host supplies its own effects. Every function here is a pure
|
|
7
|
+
* name builder, string template, or decision over injected inputs (home
|
|
8
|
+
* directory, pids, env maps, command lines); the host performs the writes,
|
|
9
|
+
* spawns, and `launchctl`/`systemctl` calls. Axiom 8: labels, file names,
|
|
10
|
+
* template bodies, and error strings are byte-exact with the engine.
|
|
11
|
+
*
|
|
12
|
+
* Engine sources (production until cutover, axiom 9):
|
|
13
|
+
* `packages/amalgm/lib/service.js`, `runtime/lib/runtime-manifest.js`,
|
|
14
|
+
* `runtime/scripts/amalgm-mcp/runtime-owner.js`, and
|
|
15
|
+
* `packages/amalgm/lib/process-cleanup.js`.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Engine `service.js:31-32`: `${userScope}.${label}` with every character
|
|
19
|
+
* outside `[A-Za-z0-9_.-]` replaced by `_`. One label per user per branch —
|
|
20
|
+
* identity is one story (axiom 2); the scope inputs come from the identity
|
|
21
|
+
* module.
|
|
22
|
+
*/
|
|
23
|
+
export declare function serviceLabelScope(userScope: string, runtimeLabel: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Engine `service.js:33`: `ai.amalgm.runtime.${scope}`. The engine honors
|
|
26
|
+
* an `AMALGM_SERVICE_LABEL` env override; reading env is the host's job.
|
|
27
|
+
*/
|
|
28
|
+
export declare function serviceLabel(labelScope: string): string;
|
|
29
|
+
/** Engine `service.js:591-593`: `~/Library/LaunchAgents/<label>.plist`. Home is injected. */
|
|
30
|
+
export declare function launchdPlistPath(home: string, label: string): string;
|
|
31
|
+
/** Engine `service.js:637-639`: `~/.config/systemd/user/<label>.service`. */
|
|
32
|
+
export declare function systemdUnitPath(home: string, label: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Engine `service.js:641-649`: the per-user Startup folder script,
|
|
35
|
+
* `Amalgm-<labelScope>.vbs`. `appData` is the host's `%APPDATA%` when set;
|
|
36
|
+
* otherwise `<home>/AppData/Roaming`. Joined with `/` — a name contract,
|
|
37
|
+
* not a filesystem call site.
|
|
38
|
+
*/
|
|
39
|
+
export declare function windowsStartupScriptPath(labelScope: string, options: {
|
|
40
|
+
home: string;
|
|
41
|
+
appData?: string | undefined;
|
|
42
|
+
}): string;
|
|
43
|
+
/** Engine `service.js:131-133`: POSIX single-quote escaping. */
|
|
44
|
+
export declare function shellQuote(value: unknown): string;
|
|
45
|
+
/** Engine `service.js:135-142`: the five XML entities, in engine order (`&` first). */
|
|
46
|
+
export declare function plistEscape(value: unknown): string;
|
|
47
|
+
/** Engine `service.js:144-146`: systemd double-quote escaping (backslash, then quote). */
|
|
48
|
+
export declare function systemdQuote(value: unknown): string;
|
|
49
|
+
/** Engine `service.js:651-653`: VBScript string literal — doubled quotes. */
|
|
50
|
+
export declare function vbsString(value: unknown): string;
|
|
51
|
+
/**
|
|
52
|
+
* Engine `service.js:148-150`: does a path point inside a desktop app
|
|
53
|
+
* bundle (`Foo.app/Contents/Resources/cli` or `Foo.app/Contents/MacOS`)?
|
|
54
|
+
* Backslashes are normalized first. A service registration pointing at the
|
|
55
|
+
* bundle is the auto-update bundle loop: npm updates `~/.npm-global` but
|
|
56
|
+
* launchd reboots the frozen bundled copy forever.
|
|
57
|
+
*/
|
|
58
|
+
export declare function pathLooksLikeDesktopBundle(value: unknown): boolean;
|
|
59
|
+
/** The persisted service registration state this module judges. */
|
|
60
|
+
export interface ServiceState {
|
|
61
|
+
readonly backend?: string | undefined;
|
|
62
|
+
readonly label?: string | undefined;
|
|
63
|
+
readonly local_only?: boolean | undefined;
|
|
64
|
+
readonly package_version?: string | undefined;
|
|
65
|
+
readonly package_root?: string | undefined;
|
|
66
|
+
readonly node?: string | undefined;
|
|
67
|
+
readonly bin?: string | undefined;
|
|
68
|
+
readonly runtime_host?: string | undefined;
|
|
69
|
+
readonly files?: {
|
|
70
|
+
readonly plist?: string | undefined;
|
|
71
|
+
readonly unit?: string | undefined;
|
|
72
|
+
readonly script?: string | undefined;
|
|
73
|
+
readonly nodeScript?: string | undefined;
|
|
74
|
+
readonly startup?: string | undefined;
|
|
75
|
+
} | undefined;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Engine `service.js:152-167`: a registration may own the runtime unless it
|
|
79
|
+
* points at a desktop bundle (any of its paths), or explicitly declares an
|
|
80
|
+
* electron host. `runtime_host: 'node'` always may; an absent
|
|
81
|
+
* `runtime_host` is trusted (older installs, axiom 7).
|
|
82
|
+
*/
|
|
83
|
+
export declare function serviceStateCanOwnRuntime(state: ServiceState | null | undefined): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Engine `service.js:179-184`: a lock file names another live owner. The
|
|
86
|
+
* liveness probe is injected.
|
|
87
|
+
*/
|
|
88
|
+
export declare function lockOwnedByAnother(existingPid: unknown, currentPid: number, pidRunning: (pid: number) => boolean): boolean;
|
|
89
|
+
export type ServiceMode = 'auto' | 'portable' | 'systemd' | 'launchd' | 'windows';
|
|
90
|
+
/**
|
|
91
|
+
* Engine `service.js:257-263`: mode normalization. Empty/absent → `auto`;
|
|
92
|
+
* the legacy `watchdog` alias → `portable`; anything else throws the exact
|
|
93
|
+
* engine error.
|
|
94
|
+
*/
|
|
95
|
+
export declare function normalizeMode(mode: unknown): ServiceMode;
|
|
96
|
+
/**
|
|
97
|
+
* Engine `service.js:222-224`: `systemctl` output that means systemd is not
|
|
98
|
+
* actually available (containers, ssh sessions without a user bus, ...).
|
|
99
|
+
*/
|
|
100
|
+
export declare function systemdUnavailableOutput(output: unknown): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Engine `service.js:749-762`: an existing registration satisfies the
|
|
103
|
+
* request only when it points at THIS package root and version, matches
|
|
104
|
+
* the local-only flag, and matches the requested backend (with `auto`
|
|
105
|
+
* resolved to what detection would choose — the detected backend is
|
|
106
|
+
* injected, detection itself is effectful).
|
|
107
|
+
*/
|
|
108
|
+
export declare function stateMatchesRequest(state: ServiceState | null | undefined, options: {
|
|
109
|
+
mode?: unknown;
|
|
110
|
+
localOnly?: boolean | undefined;
|
|
111
|
+
}, context: {
|
|
112
|
+
packageRoot: string;
|
|
113
|
+
packageVersion: string;
|
|
114
|
+
autoBackend: string;
|
|
115
|
+
}): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Engine `service.js:770-780`. A service registration owned by an
|
|
118
|
+
* equal-or-newer install of this package must not be replaced by an older
|
|
119
|
+
* caller (e.g. the CLI bundled inside the desktop app re-registering the
|
|
120
|
+
* service over the auto-updated npm install). Re-pointing the service at an
|
|
121
|
+
* older tree makes the auto-updater restart-loop: it installs the newer
|
|
122
|
+
* version, restarts, and boots the older tree again. Explicit
|
|
123
|
+
* `amalgm service install` still takes over. `binExists` is the injected
|
|
124
|
+
* existence probe for `state.bin`.
|
|
125
|
+
*/
|
|
126
|
+
export declare function deferToExistingInstall(state: ServiceState | null | undefined, options: {
|
|
127
|
+
mode?: unknown;
|
|
128
|
+
localOnly?: boolean | undefined;
|
|
129
|
+
}, context: {
|
|
130
|
+
packageRoot: string;
|
|
131
|
+
packageVersion: string;
|
|
132
|
+
binExists: (bin: string) => boolean;
|
|
133
|
+
compare?: (left: string, right: string) => number;
|
|
134
|
+
}): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* The launchd plist body (engine `service.js:603-632`), byte-exact:
|
|
137
|
+
* KeepAlive and RunAtLoad true, both stdio streams appended to the daemon
|
|
138
|
+
* log, program arguments `node amalgm.js run --amalgm-runtime-id=<id>`.
|
|
139
|
+
* Env entries render in the injected map's insertion order.
|
|
140
|
+
*/
|
|
141
|
+
export declare function buildLaunchdPlist(input: {
|
|
142
|
+
label: string;
|
|
143
|
+
execPath: string;
|
|
144
|
+
binPath: string;
|
|
145
|
+
runtimeInstanceArg: string;
|
|
146
|
+
env: Readonly<Record<string, string>>;
|
|
147
|
+
workingDirectory: string;
|
|
148
|
+
daemonLogPath: string;
|
|
149
|
+
}): string;
|
|
150
|
+
/**
|
|
151
|
+
* The systemd user unit body (engine `service.js:683-700`), byte-exact:
|
|
152
|
+
* `Restart=always`, `RestartSec=5`, `KillSignal=SIGTERM`,
|
|
153
|
+
* `TimeoutStopSec=20`, `WantedBy=default.target`, both stdio streams
|
|
154
|
+
* appended to the daemon log via the quoted `ExecStart` shell line. The
|
|
155
|
+
* engine appends `AMALGM_NODE`/`AMALGM_BIN`/`AMALGM_DAEMON_LOG`/
|
|
156
|
+
* `AMALGM_RUNTIME_INSTANCE_ARG` after the service env; this builder does
|
|
157
|
+
* the same, so entry order matches. Note `WorkingDirectory` is rendered
|
|
158
|
+
* unescaped — engine parity.
|
|
159
|
+
*/
|
|
160
|
+
export declare function buildSystemdUnit(input: {
|
|
161
|
+
execPath: string;
|
|
162
|
+
binPath: string;
|
|
163
|
+
runtimeInstanceArg: string;
|
|
164
|
+
env: Readonly<Record<string, string>>;
|
|
165
|
+
workingDirectory: string;
|
|
166
|
+
daemonLogPath: string;
|
|
167
|
+
}): string;
|
|
168
|
+
/**
|
|
169
|
+
* The Windows startup VBScript body (engine `service.js:655-667`): launch
|
|
170
|
+
* the portable watchdog hidden (window style 0), don't wait. CRLF line
|
|
171
|
+
* endings, trailing CRLF.
|
|
172
|
+
*/
|
|
173
|
+
export declare function buildWindowsStartupScript(input: {
|
|
174
|
+
execPath: string;
|
|
175
|
+
watchdogPath: string;
|
|
176
|
+
}): string;
|
|
177
|
+
/** One runtime service's registration with the parent supervisor. */
|
|
178
|
+
export interface ServiceDeclaration {
|
|
179
|
+
readonly name: string;
|
|
180
|
+
/** Entry script, relative to the runtime directory. */
|
|
181
|
+
readonly script: string;
|
|
182
|
+
/** Key in the in-process ports object. */
|
|
183
|
+
readonly portKey: string;
|
|
184
|
+
/** Env var the service reads its port from. */
|
|
185
|
+
readonly envName: string;
|
|
186
|
+
/** Key under `ports` in runtime-state.json (`'gateway'` is hoisted to `gateway_port`). */
|
|
187
|
+
readonly stateKey: string;
|
|
188
|
+
readonly defaultPort: number;
|
|
189
|
+
readonly launchOrder: number;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The runtime's own service registration (engine
|
|
193
|
+
* `runtime-manifest.js:3-40`). This constant is the RUNTIME'S declaration,
|
|
194
|
+
* not core's: core defines the `ServiceDeclaration` shape and the laws over
|
|
195
|
+
* it; the runtime is simply the first registrant, pinned here for parity
|
|
196
|
+
* tests and for hosts that supervise the shipped runtime. Launch order:
|
|
197
|
+
* port-monitor (10) → chat-server (30) → amalgm-mcp (40) → local-gateway (50).
|
|
198
|
+
*/
|
|
199
|
+
export declare const shippedRuntimeServices: readonly ServiceDeclaration[];
|
|
200
|
+
/** Every runtime service answers liveness on this path (engine `runtime-manifest.js:140`). */
|
|
201
|
+
export declare const RUNTIME_HEALTH_PATH = "/healthz";
|
|
202
|
+
/**
|
|
203
|
+
* Engine `runtime-manifest.js:50-54`: a port is an integer in 1..65535,
|
|
204
|
+
* parsed base-10 from anything stringifiable; everything else is the
|
|
205
|
+
* fallback.
|
|
206
|
+
*/
|
|
207
|
+
export declare function parsePort(value: unknown, fallback?: number | null): number | null;
|
|
208
|
+
/** Engine `runtime-manifest.js:60-62`: services sorted by launch order. */
|
|
209
|
+
export declare function runtimeLaunchServices(services?: readonly ServiceDeclaration[]): ServiceDeclaration[];
|
|
210
|
+
/** The runtime-state.json port fields (engine `runtime-manifest.js:96-143`). */
|
|
211
|
+
export interface RuntimeStatePorts {
|
|
212
|
+
readonly gateway_port?: unknown;
|
|
213
|
+
readonly ports?: Readonly<Record<string, unknown>> | undefined;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Engine `runtime-manifest.js:96-108`: read service ports back out of
|
|
217
|
+
* runtime-state.json — the gateway from the hoisted `gateway_port` key,
|
|
218
|
+
* everything else from `ports[stateKey]`.
|
|
219
|
+
*/
|
|
220
|
+
export declare function runtimePortsFromState(state: RuntimeStatePorts | null | undefined, services?: readonly ServiceDeclaration[]): Record<string, number>;
|
|
221
|
+
/**
|
|
222
|
+
* Engine `runtime-manifest.js:126-143`: the runtime-state.json shape for
|
|
223
|
+
* allocated ports — `gateway_port` + `gateway_url` hoisted, the rest under
|
|
224
|
+
* `ports` by state key, plus a `services` list with `health_path:
|
|
225
|
+
* '/healthz'` per entry.
|
|
226
|
+
*/
|
|
227
|
+
export declare function runtimePortsState(ports: Readonly<Record<string, unknown>> | null | undefined, services?: readonly ServiceDeclaration[]): {
|
|
228
|
+
gateway_port: number | undefined;
|
|
229
|
+
gateway_url: string | undefined;
|
|
230
|
+
ports: Record<string, number>;
|
|
231
|
+
services: {
|
|
232
|
+
name: string;
|
|
233
|
+
port: number | null;
|
|
234
|
+
health_path: string;
|
|
235
|
+
}[];
|
|
236
|
+
};
|
|
237
|
+
export interface RuntimeOwnerRecord {
|
|
238
|
+
readonly pid: number;
|
|
239
|
+
readonly token: string;
|
|
240
|
+
}
|
|
241
|
+
export type OwnershipDecision =
|
|
242
|
+
/** No owner on disk: create the lock exclusively. */
|
|
243
|
+
{
|
|
244
|
+
readonly action: 'acquire';
|
|
245
|
+
}
|
|
246
|
+
/** The recorded owner is dead: unlink its lock and retry the exclusive create. */
|
|
247
|
+
| {
|
|
248
|
+
readonly action: 'replace-dead';
|
|
249
|
+
readonly stale: RuntimeOwnerRecord;
|
|
250
|
+
}
|
|
251
|
+
/** A live owner holds the directory. Message and code are byte-exact (engine `runtime-owner.js:51-52`). */
|
|
252
|
+
| {
|
|
253
|
+
readonly action: 'refuse';
|
|
254
|
+
readonly code: 'AMALGM_RUNTIME_ALREADY_RUNNING';
|
|
255
|
+
readonly message: string;
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* One user-state directory has one runtime owner (engine
|
|
259
|
+
* `runtime-owner.js:34-61`, decision half). The lock file is created
|
|
260
|
+
* exclusively; a live PID refuses a second owner; a dead PID is replaced.
|
|
261
|
+
* The liveness answer is injected — the host already probed
|
|
262
|
+
* `existing.pid`.
|
|
263
|
+
*/
|
|
264
|
+
export declare function decideOwnership(input: {
|
|
265
|
+
existing: RuntimeOwnerRecord | null;
|
|
266
|
+
pidAlive: boolean;
|
|
267
|
+
directory: string;
|
|
268
|
+
}): OwnershipDecision;
|
|
269
|
+
/**
|
|
270
|
+
* Engine `runtime-owner.js:64-74`: a release only removes the lock it
|
|
271
|
+
* wrote — the pid AND token must both match, so an old process cannot
|
|
272
|
+
* remove a successor's lock during shutdown.
|
|
273
|
+
*/
|
|
274
|
+
export declare function releaseAllowed(owner: Partial<RuntimeOwnerRecord> | null | undefined, pid: number, token: string): boolean;
|
|
275
|
+
/**
|
|
276
|
+
* Engine `process-cleanup.js:24`: every supervised process carries its
|
|
277
|
+
* runtime instance id on the command line so orphans can be identified
|
|
278
|
+
* without reading `/proc` environments.
|
|
279
|
+
*/
|
|
280
|
+
export declare function runtimeInstanceArg(runtimeInstanceId: string): string;
|
|
281
|
+
/** Engine `process-cleanup.js:165`: extract the instance id from a command line. */
|
|
282
|
+
export declare const RUNTIME_INSTANCE_ARG_PATTERN: RegExp;
|
|
283
|
+
/** Engine `process-cleanup.js:163-167` (over a backslash-normalized command). */
|
|
284
|
+
export declare function commandRuntimeInstanceId(command: unknown): string;
|
|
285
|
+
/** The suffix any supervisor command line carries (engine `process-cleanup.js:23`). */
|
|
286
|
+
export declare const SUPERVISOR_COMMAND_SUFFIX = "/bin/amalgm.js";
|
|
287
|
+
/** Marker paths for the runtime services, absolute under the injected runtime dir. */
|
|
288
|
+
export declare function runtimeServiceMarkers(runtimeDir: string, services?: readonly ServiceDeclaration[]): string[];
|
|
289
|
+
/** Relative marker suffixes (`runtime/<script>`) matching any install location. */
|
|
290
|
+
export declare function runtimeServiceSuffixes(services?: readonly ServiceDeclaration[]): string[];
|
|
291
|
+
export interface ProcessIdentity {
|
|
292
|
+
readonly env?: Readonly<Record<string, string>> | null | undefined;
|
|
293
|
+
readonly parentCommand?: string | undefined;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Engine `process-cleanup.js:157-161`: does a process env belong to this
|
|
297
|
+
* runtime? An `AMALGM_RUNTIME_INSTANCE_ID` answers definitively; an absent
|
|
298
|
+
* `AMALGM_DIR` is trusted; otherwise the dirs must match. The engine
|
|
299
|
+
* resolves both paths — this SDK compares injected, already-resolved
|
|
300
|
+
* strings.
|
|
301
|
+
*/
|
|
302
|
+
export declare function envMatchesAmalgmDir(env: Readonly<Record<string, string>> | null | undefined, context: {
|
|
303
|
+
runtimeInstanceId: string;
|
|
304
|
+
amalgmDir: string;
|
|
305
|
+
}): boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Engine `process-cleanup.js:175-188`: is this command line one of OUR
|
|
308
|
+
* runtime services? Marker/suffix match first; an instance-id arg answers
|
|
309
|
+
* definitively; a readable env decides next; otherwise only an absolute
|
|
310
|
+
* marker match may count, and foreign orphans need `includeOrphanedForeign`
|
|
311
|
+
* plus a parent that is not any supervisor.
|
|
312
|
+
*/
|
|
313
|
+
export declare function commandLooksLikeRuntimeService(command: unknown, context: {
|
|
314
|
+
markers: readonly string[];
|
|
315
|
+
suffixes: readonly string[];
|
|
316
|
+
runtimeInstanceId: string;
|
|
317
|
+
amalgmDir: string;
|
|
318
|
+
item?: ProcessIdentity | null | undefined;
|
|
319
|
+
includeOrphanedForeign?: boolean | undefined;
|
|
320
|
+
}): boolean;
|
|
321
|
+
/**
|
|
322
|
+
* Engine `process-cleanup.js:190-195`: OUR supervisor — the absolute
|
|
323
|
+
* `bin/amalgm.js` marker, a `run` word, and a definitively matching
|
|
324
|
+
* instance-id arg.
|
|
325
|
+
*/
|
|
326
|
+
export declare function commandLooksLikeSupervisor(command: unknown, context: {
|
|
327
|
+
supervisorMarker: string;
|
|
328
|
+
runtimeInstanceId: string;
|
|
329
|
+
}): boolean;
|
|
330
|
+
/** Engine `process-cleanup.js:197-200`: ANY amalgm supervisor, ours or not. */
|
|
331
|
+
export declare function commandLooksLikeAnySupervisor(command: unknown): boolean;
|
|
332
|
+
/**
|
|
333
|
+
* Engine `process-cleanup.js:120`: one `ps -eo pid=,ppid=,command=` line —
|
|
334
|
+
* `/^(\d+)\s+(\d+)\s+(.+)$/` over the trimmed line.
|
|
335
|
+
*/
|
|
336
|
+
export declare const PS_LINE_PATTERN: RegExp;
|
|
337
|
+
/** Parse one ps line (engine `process-cleanup.js:117-129`); null when it doesn't match. */
|
|
338
|
+
export declare function parsePsLine(line: string): {
|
|
339
|
+
pid: number;
|
|
340
|
+
ppid: number;
|
|
341
|
+
command: string;
|
|
342
|
+
} | null;
|
|
343
|
+
//# sourceMappingURL=service-registration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-registration.d.ts","sourceRoot":"","sources":["../../src/supervision/service-registration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAEjF;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,6FAA6F;AAC7F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GACtD,MAAM,CAIR;AAMD,gEAAgE;AAChE,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEjD;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAOlD;AAED,0FAA0F;AAC1F,wBAAgB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