/**
 * @license
 * Copyright 2026 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import os from 'node:os';
import { sanitizeEnvironment, getSecureSanitizationConfig, } from './environmentSanitization.js';
import { LinuxSandboxManager } from '../sandbox/linux/LinuxSandboxManager.js';
/**
 * A no-op implementation of SandboxManager that silently passes commands
 * through while applying environment sanitization.
 */
export class NoopSandboxManager {
    /**
     * Prepares a command by sanitizing the environment and passing through
     * the original program and arguments.
     */
    async prepareCommand(req) {
        const sanitizationConfig = getSecureSanitizationConfig(req.config?.sanitizationConfig);
        const sanitizedEnv = sanitizeEnvironment(req.env, sanitizationConfig);
        return {
            program: req.command,
            args: req.args,
            env: sanitizedEnv,
        };
    }
}
/**
 * SandboxManager that implements actual sandboxing.
 */
export class LocalSandboxManager {
    async prepareCommand(_req) {
        throw new Error('Tool sandboxing is not yet implemented.');
    }
}
/**
 * Creates a sandbox manager based on the provided settings.
 */
export function createSandboxManager(sandboxingEnabled, workspace) {
    if (sandboxingEnabled) {
        if (os.platform() === 'linux') {
            return new LinuxSandboxManager({ workspace });
        }
        return new LocalSandboxManager();
    }
    return new NoopSandboxManager();
}
//# sourceMappingURL=sandboxManager.js.map