mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 11:25:50 -06:00
feat(node-host): supervise durable worker launches (#122829)
* feat(node-host): add worker launch supervision * fix(node-host): harden worker lifecycle ownership * fix(node-host): harden worker execution boundary * fix(node-host): preserve worker trust settings * chore(plugin-sdk): refresh worker lifecycle baselines * docs(plan): track runner implementation slices * test(node-host): await runtime shutdown owner
This commit is contained in:
committed by
GitHub
parent
93f5e0f1f6
commit
6b9bea84f0
@@ -0,0 +1,51 @@
|
||||
const POSIX_WORKER_ENV_KEYS = new Set([
|
||||
"PATH",
|
||||
"HOME",
|
||||
"TMPDIR",
|
||||
"TMP",
|
||||
"TEMP",
|
||||
"LANG",
|
||||
"LANGUAGE",
|
||||
"TZ",
|
||||
"NODE_EXTRA_CA_CERTS",
|
||||
"NODE_USE_SYSTEM_CA",
|
||||
"OPENCLAW_ALLOW_INSECURE_PRIVATE_WS",
|
||||
]);
|
||||
const WINDOWS_WORKER_ENV_KEYS = new Set([
|
||||
...POSIX_WORKER_ENV_KEYS,
|
||||
"USERPROFILE",
|
||||
"HOMEDRIVE",
|
||||
"HOMEPATH",
|
||||
"SYSTEMROOT",
|
||||
"WINDIR",
|
||||
"COMSPEC",
|
||||
"PATHEXT",
|
||||
]);
|
||||
|
||||
/** Freeze the minimal non-secret environment inherited by node-host workers. */
|
||||
export function snapshotNodeWorkerEnv(source: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
|
||||
const windows = process.platform === "win32";
|
||||
const snapshot: NodeJS.ProcessEnv = {};
|
||||
const retainedWindowsKeys = new Map<string, string>();
|
||||
for (const [key, value] of Object.entries(source)) {
|
||||
if (value === undefined) {
|
||||
continue;
|
||||
}
|
||||
const normalized = windows ? key.toUpperCase() : key;
|
||||
const allowed =
|
||||
(windows ? WINDOWS_WORKER_ENV_KEYS : POSIX_WORKER_ENV_KEYS).has(normalized) ||
|
||||
normalized.startsWith("LC_");
|
||||
if (!allowed) {
|
||||
continue;
|
||||
}
|
||||
if (windows) {
|
||||
const previousKey = retainedWindowsKeys.get(normalized);
|
||||
if (previousKey) {
|
||||
delete snapshot[previousKey];
|
||||
}
|
||||
retainedWindowsKeys.set(normalized, key);
|
||||
}
|
||||
snapshot[key] = value;
|
||||
}
|
||||
return snapshot;
|
||||
}
|
||||
Reference in New Issue
Block a user