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