Files
reverse-engineering-anything/src/config/environmentName.ts
T
10f1994fe1 feat(environment): serve an environment manifest as a replay environment (#4975)
Serve retained capture Evidence as a bounded MCP replay environment with discovery.
Preserve default stdio, caller-selected facts and complete source Evidence.

Fix numeric fidelity, argument identity, startup cancellation and bounded discovery,
query/path matching and output metadata. Verify real recorded API data and public
CLI/MCP workflows; preserve explicit gaps for Windows and third-party hosts.

Co-authored-by: Edgar Arakelyan <edgar.arakelyan@scale.com>
Co-authored-by: gensokyo-dev <gensokyo-dev@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 03:06:29 +08:00

31 lines
1000 B
TypeScript

import { z } from "zod";
import { ConfigurationError } from "../domain/configurationErrors.js";
import { err, ok, type Result } from "../domain/result.js";
export const ENVIRONMENT_NAME_CONSTRAINT =
"ENVIRONMENT_NAME must be a non-empty name when set.";
const environmentNameSchema = z.string().trim().min(1);
/** The served environment name override, or undefined when the manifest name applies. */
export const parseEnvironmentName = (
environment: Readonly<NodeJS.ProcessEnv>,
): Result<string | undefined, ConfigurationError> => {
const value = environment.ENVIRONMENT_NAME;
if (value === undefined) return ok(undefined);
const parsed = environmentNameSchema.safeParse(value);
return parsed.success
? ok(parsed.data)
: err(
new ConfigurationError(ENVIRONMENT_NAME_CONSTRAINT, {
settings: [
{
setting: "ENVIRONMENT_NAME",
constraint: ENVIRONMENT_NAME_CONSTRAINT,
},
],
}),
);
};