/**
 * The four config-dir env keys a harness pins to its version home. Every
 * per-harness branch in the old buildExecEnv deleted the ones it does NOT set,
 * so its own config pointer never leaks into a foreign harness's invocation.
 * (XDG_CONFIG_HOME / XDG_DATA_HOME — Muse/Cursor — are deliberately absent: the
 * old code sets them but never strips them, and this preserves that exactly.)
 */
export const CONFIG_DIR_ENV_KEYS = [
    'CLAUDE_CONFIG_DIR',
    'CODEX_HOME',
    'COPILOT_HOME',
    'KIMI_CODE_HOME',
];
/**
 * Strip every config-dir env key except the one(s) this harness sets. `keep=[]`
 * (the default / no-config-dir harness) deletes all four — the old `else` arm.
 */
export function stripForeignConfigDir(result, keep = []) {
    for (const key of CONFIG_DIR_ENV_KEYS) {
        if (!keep.includes(key))
            delete result[key];
    }
}
const REGISTRY = new Map();
/**
 * The no-behavior adapter — a harness with no managed config-dir env and no
 * launch-arg quirks. buildExecEnv strips all four config-dir keys for it (the old
 * `else` arm) by falling back to {@link stripForeignConfigDir} when an adapter
 * omits `applyExecConfigEnv`.
 */
function defaultAdapter(id) {
    return { id };
}
export function registerHarnessAdapter(adapter) {
    REGISTRY.set(adapter.id, adapter);
}
/**
 * The behavior adapter for a harness. Every `AgentId` resolves to an adapter —
 * one with real behavior when registered, else the id-only default (the old
 * `else` arm). Callers therefore never name-check a harness.
 */
export function resolveHarnessAdapter(id) {
    return REGISTRY.get(id) ?? defaultAdapter(id);
}
export function listHarnessAdapters() {
    return [...REGISTRY.keys()].sort();
}
