mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-18 09:11:55 -07:00
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
|
|
/**
|
||
|
|
* @license
|
||
|
|
* Copyright 2026 Google LLC
|
||
|
|
* SPDX-License-Identifier: Apache-2.0
|
||
|
|
*/
|
||
|
|
|
||
|
|
import os from 'node:os';
|
||
|
|
import {
|
||
|
|
type SandboxManager,
|
||
|
|
NoopSandboxManager,
|
||
|
|
LocalSandboxManager,
|
||
|
|
} from './sandboxManager.js';
|
||
|
|
import { LinuxSandboxManager } from '../sandbox/linux/LinuxSandboxManager.js';
|
||
|
|
import { MacOsSandboxManager } from '../sandbox/macos/MacOsSandboxManager.js';
|
||
|
|
import { WindowsSandboxManager } from './windowsSandboxManager.js';
|
||
|
|
import type { SandboxConfig } from '../config/config.js';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Creates a sandbox manager based on the provided settings.
|
||
|
|
*/
|
||
|
|
export function createSandboxManager(
|
||
|
|
sandbox: SandboxConfig | undefined,
|
||
|
|
workspace: string,
|
||
|
|
): SandboxManager {
|
||
|
|
const isWindows = os.platform() === 'win32';
|
||
|
|
|
||
|
|
if (
|
||
|
|
isWindows &&
|
||
|
|
(sandbox?.enabled || sandbox?.command === 'windows-native')
|
||
|
|
) {
|
||
|
|
return new WindowsSandboxManager();
|
||
|
|
}
|
||
|
|
|
||
|
|
if (sandbox?.enabled) {
|
||
|
|
if (os.platform() === 'linux') {
|
||
|
|
return new LinuxSandboxManager({ workspace });
|
||
|
|
}
|
||
|
|
if (os.platform() === 'darwin') {
|
||
|
|
return new MacOsSandboxManager({ workspace });
|
||
|
|
}
|
||
|
|
return new LocalSandboxManager();
|
||
|
|
}
|
||
|
|
|
||
|
|
return new NoopSandboxManager();
|
||
|
|
}
|