返回 DeepSeek-Reasonix
shellSupportPreview.ts
根目录 / desktop / frontend / src / lib / shellSupportPreview.ts
1 import type { SandboxView, ShellCapabilityView } from "./types";
2
3 type PreviewPlatform = "darwin" | "windows" | "linux" | "";
4
5 export function reloadBrowserPreviewShell(sandbox: SandboxView): void {
6 sandbox.effectiveShell = sandbox.resolvedShell || sandbox.effectiveShell;
7 sandbox.shellReloadRequired = false;
8 }
9
10 // Browser-preview stand-ins for the backend shell inventory and repair policy.
11 // Keeping this mock owner outside bridge.ts preserves that generated-style
12 // boundary's file-size ratchet as the Settings contract grows.
13 export function browserPreviewShellSupport(platform: PreviewPlatform): Pick<SandboxView, "shellCapabilities" | "gitCapability" | "shellInstallAction" | "shellRepairGuidance" | "gitRepairGuidance"> {
14 const shellCapabilities: ShellCapabilityView[] = platform !== "windows" ? [
15 { id: "bash", variant: "system", available: true, path: "/bin/bash", source: "path" },
16 { id: "zsh", variant: "system", available: platform === "darwin", ...(platform === "darwin" ? { path: "/bin/zsh", source: "standard-path" } : { reason: "not-found" }) },
17 { id: "sh", variant: "system", available: true, path: "/bin/sh", source: "standard-path" },
18 ] : [
19 { id: "git-bash", variant: "git-for-windows", available: true, path: "C:\\Program Files\\Git\\bin\\bash.exe", source: "standard-path" },
20 { id: "powershell", available: true, path: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", source: "standard-path" },
21 { id: "pwsh", available: true, path: "C:\\Program Files\\PowerShell\\7\\pwsh.exe", source: "standard-path" },
22 ];
23 return {
24 shellCapabilities,
25 gitCapability: { id: "git", available: true, path: platform === "windows" ? "C:\\Program Files\\Git\\cmd\\git.exe" : "/usr/bin/git", source: "path" },
26 shellInstallAction: platform === "windows" ? { id: "git-for-windows", mode: "manual", available: false, manualUrl: "https://git-scm.com/download/win" } : null,
27 shellRepairGuidance: platform === "linux" ? { manager: "apt", command: "apt-get install bash" } : null,
28 gitRepairGuidance: platform === "darwin"
29 ? { manager: "homebrew", command: "brew install git" }
30 : platform === "linux" ? { manager: "apt", command: "apt-get install git" } : null,
31 };
32 }
33
33 lines TYPESCRIPT