Files
rea/src/process/capture/ProcessCaptureEnvironment.ts
T
morluto 530faf43bd refactor(process): take the host from HOST_PLATFORM and require the platform in process helpers (#11038)
* refactor(process): take the host from HOST_PLATFORM and require the platform in process helpers

* refactor(process): require the settlement platform and pass it in string-embedded ownership checks
2026-11-15 19:35:03 +08:00

38 lines
1.2 KiB
TypeScript

import type { ProcessScenario } from "../../domain/process/processScenario.js";
import { HOST_PLATFORM } from "../../platform/HostPlatform.js";
import {
mergeEnvironmentOverrides,
snapshotEnvironment,
} from "../snapshotEnvironment.js";
interface ProcessCaptureEnvironmentOptions {
readonly scenario: ProcessScenario;
readonly runId: string;
readonly hostEnvironment: Readonly<Record<string, string | undefined>>;
readonly platform?: NodeJS.Platform;
}
/** Build the child environment from the host plus caller-selected overrides. */
export const makeProcessCaptureEnvironment = (
options: ProcessCaptureEnvironmentOptions,
): Record<string, string> => {
const platform = options.platform ?? HOST_PLATFORM.platform;
const environment = snapshotEnvironment(
mergeEnvironmentOverrides(
options.hostEnvironment,
options.scenario.environment,
platform,
),
platform,
);
return {
...Object.fromEntries(
Object.entries(environment).filter(
(entry): entry is [string, string] => entry[1] !== undefined,
),
),
TERM: environment.TERM ?? "xterm-256color",
REA_PROCESS_RUN_ID: options.runId,
};
};