@moxt-ai/mobius 0.0.336 → 0.0.338
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1407 -1283
- package/dist/cli.js.map +4 -4
- package/dist/daemon/upgrades/upgrade.d.ts.map +1 -1
- package/dist/daemon/upgrades/upgrade.js +25 -2
- package/dist/daemon/upgrades/upgrade.js.map +1 -1
- package/dist/runtime.js +1091 -1021
- package/dist/runtime.js.map +4 -4
- package/dist/session/turn/runtime-turn-activity.d.ts +12 -1
- package/dist/session/turn/runtime-turn-activity.d.ts.map +1 -1
- package/dist/session/turn/runtime-turn-activity.js +52 -26
- package/dist/session/turn/runtime-turn-activity.js.map +1 -1
- package/dist/util/filesystem/private-path.js +6 -324
- package/dist/util/filesystem/private-path.js.map +4 -4
- package/dist/util/platform/contracts.d.ts +0 -26
- package/dist/util/platform/contracts.d.ts.map +1 -1
- package/dist/util/platform/index.d.ts.map +1 -1
- package/dist/util/platform/index.js +1 -4
- package/dist/util/platform/index.js.map +1 -1
- package/dist/util/platform/linux.d.ts.map +1 -1
- package/dist/util/platform/linux.js +1 -117
- package/dist/util/platform/linux.js.map +1 -1
- package/dist/util/platform/macos.d.ts.map +1 -1
- package/dist/util/platform/macos.js +1 -4
- package/dist/util/platform/macos.js.map +1 -1
- package/dist/util/platform/posix.d.ts +0 -21
- package/dist/util/platform/posix.d.ts.map +1 -1
- package/dist/util/platform/posix.js +1 -104
- package/dist/util/platform/posix.js.map +1 -1
- package/dist/util/platform/windows.d.ts.map +1 -1
- package/dist/util/platform/windows.js +1 -107
- package/dist/util/platform/windows.js.map +1 -1
- package/dist/util/process/executable.d.ts +2 -2
- package/dist/util/process/executable.d.ts.map +1 -1
- package/dist/util/process/executable.js +31 -222
- package/dist/util/process/executable.js.map +4 -4
- package/dist/util/process/platform/contracts.d.ts +29 -0
- package/dist/util/process/platform/contracts.d.ts.map +1 -0
- package/dist/util/process/platform/contracts.js +2 -0
- package/dist/util/process/platform/contracts.js.map +1 -0
- package/dist/util/process/platform/index.d.ts +3 -0
- package/dist/util/process/platform/index.d.ts.map +1 -0
- package/dist/util/process/platform/index.js +20 -0
- package/dist/util/process/platform/index.js.map +1 -0
- package/dist/util/process/platform/linux.d.ts +3 -0
- package/dist/util/process/platform/linux.d.ts.map +1 -0
- package/dist/util/process/platform/linux.js +122 -0
- package/dist/util/process/platform/linux.js.map +1 -0
- package/dist/util/process/platform/macos.d.ts +3 -0
- package/dist/util/process/platform/macos.d.ts.map +1 -0
- package/dist/util/process/platform/macos.js +8 -0
- package/dist/util/process/platform/macos.js.map +1 -0
- package/dist/util/process/platform/posix.d.ts +25 -0
- package/dist/util/process/platform/posix.d.ts.map +1 -0
- package/dist/util/process/platform/posix.js +107 -0
- package/dist/util/process/platform/posix.js.map +1 -0
- package/dist/util/process/platform/windows.d.ts +3 -0
- package/dist/util/process/platform/windows.d.ts.map +1 -0
- package/dist/util/process/platform/windows.js +114 -0
- package/dist/util/process/platform/windows.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/util/filesystem/private-path.ts", "../../../src/util/platform/linux.ts", "../../../src/util/platform/posix.ts", "../../../src/util/filesystem/path-error.ts", "../../../src/util/platform/macos.ts", "../../../src/util/platform/claude-desktop.ts", "../../../src/util/platform/windows.ts", "../../../src/util/
|
|
4
|
-
"sourcesContent": ["import { lstat } from \"node:fs/promises\";\nimport { platformSupportFor } from \"../platform/index.ts\";\nimport { LocalPathError } from \"./path-error.ts\";\n\nexport { LocalPathError } from \"./path-error.ts\";\n\nexport async function validateLocalPath(\n path: string,\n directory: boolean,\n privateAccess: boolean,\n signal: AbortSignal,\n): Promise<void> {\n signal.throwIfAborted();\n const metadata = await lstat(path);\n if (metadata.isSymbolicLink() || (directory ? !metadata.isDirectory() : !metadata.isFile())) {\n throw new LocalPathError(\"Unsafe local path\");\n }\n await platformSupportFor(process.platform).validatePathPermissions(path, directory, privateAccess, signal);\n}\n", "import { constants, readdirSync, readFileSync } from \"node:fs\";\nimport { access, readdir, readFile, realpath, stat } from \"node:fs/promises\";\nimport { isAbsolute, join } from \"node:path\";\nimport type { PlatformSupport, ProcessTableEntry } from \"./contracts.ts\";\nimport { posixOperations, processExists as posixProcessExists, readProcessTableWithPs } from \"./posix.ts\";\n\nfunction appendLinuxProcessTableEntry(entries: ProcessTableEntry[], processId: number, encoded: string): void {\n const closingParenthesis = encoded.lastIndexOf(\")\");\n if (!encoded.startsWith(`${processId.toString()} (`) || closingParenthesis < 0) {\n return;\n }\n const fields = encoded\n .slice(closingParenthesis + 1)\n .trim()\n .split(/\\s+/);\n const parentProcessId = Number(fields[1]);\n const processGroupId = Number(fields[2]);\n if (\n !Number.isSafeInteger(parentProcessId) ||\n parentProcessId < 0 ||\n !Number.isSafeInteger(processGroupId) ||\n processGroupId <= 0\n ) {\n return;\n }\n entries.push({ parentProcessId, processGroupId, processId });\n}\n\nasync function readLinuxProcessTable(): Promise<readonly ProcessTableEntry[]> {\n const entries: ProcessTableEntry[] = [];\n try {\n const directories = await readdir(\"/proc\", { withFileTypes: true });\n for (const directory of directories) {\n if (!directory.isDirectory() || !/^\\d+$/.test(directory.name)) {\n continue;\n }\n const processId = Number(directory.name);\n if (!Number.isSafeInteger(processId) || processId <= 0) {\n continue;\n }\n try {\n appendLinuxProcessTableEntry(\n entries,\n processId,\n await readFile(join(\"/proc\", directory.name, \"stat\"), \"utf8\"),\n );\n } catch {\n // Processes can exit while procfs is being enumerated.\n }\n }\n } catch {\n // A restricted Linux runtime may not mount procfs; the fixed ps fallback runs below.\n }\n return entries;\n}\n\nfunction readLinuxProcessTableSynchronously(): readonly ProcessTableEntry[] {\n const entries: ProcessTableEntry[] = [];\n try {\n const directories = readdirSync(\"/proc\", { withFileTypes: true });\n for (const directory of directories) {\n if (!directory.isDirectory() || !/^\\d+$/.test(directory.name)) {\n continue;\n }\n const processId = Number(directory.name);\n if (!Number.isSafeInteger(processId) || processId <= 0) {\n continue;\n }\n try {\n appendLinuxProcessTableEntry(\n entries,\n processId,\n readFileSync(join(\"/proc\", directory.name, \"stat\"), \"utf8\"),\n );\n } catch {\n // Processes can exit while procfs is being enumerated.\n }\n }\n } catch {\n // A restricted Linux runtime may not mount procfs; the asynchronous fallback runs below.\n }\n return entries;\n}\n\nasync function readLinuxProcessTableWithFallback(): Promise<readonly ProcessTableEntry[]> {\n const procfsEntries = await readLinuxProcessTable();\n if (procfsEntries.length > 0) {\n return procfsEntries;\n }\n for (const candidate of [\"/usr/bin/ps\", \"/bin/ps\", \"/run/current-system/sw/bin/ps\"]) {\n try {\n const resolvedPath = await realpath(candidate);\n if (!(await stat(resolvedPath)).isFile()) {\n continue;\n }\n await access(resolvedPath, constants.X_OK);\n } catch {\n continue;\n }\n const entries = await readProcessTableWithPs(candidate);\n if (entries.length > 0) {\n return entries;\n }\n }\n return [];\n}\n\nfunction processExists(processId: number): boolean {\n try {\n const encoded = readFileSync(join(\"/proc\", processId.toString(), \"stat\"), \"utf8\");\n const closingParenthesis = encoded.lastIndexOf(\")\");\n if (closingParenthesis >= 0) {\n const processState = encoded\n .slice(closingParenthesis + 1)\n .trimStart()\n .charAt(0);\n if (processState === \"Z\" || processState === \"X\") {\n return false;\n }\n }\n } catch {\n // Fall through so restricted procfs mounts still use the portable signal probe.\n }\n return posixProcessExists(processId);\n}\n\nexport const linuxPlatform: PlatformSupport = {\n ...posixOperations,\n readProcessTable: readLinuxProcessTableWithFallback,\n readProcessTableSynchronously: readLinuxProcessTableSynchronously,\n processExists,\n claudeCodeExecutablePaths: (environment) => {\n const homeDirectory = environment[\"HOME\"];\n return homeDirectory !== undefined && isAbsolute(homeDirectory)\n ? [join(homeDirectory, \".local\", \"bin\", \"claude\")]\n : [];\n },\n};\n", "import { type ChildProcess, execFile } from \"node:child_process\";\nimport { constants } from \"node:fs\";\nimport { access, chmod, lstat, realpath, unlink } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { LocalPathError } from \"../filesystem/path-error.ts\";\nimport type { PlatformSupport, ProcessTableEntry, ProcessTreeIdentity } from \"./contracts.ts\";\n\nconst PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1_000;\nconst PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;\n\nexport function parseProcessTable(output: string): readonly ProcessTableEntry[] {\n const entries: ProcessTableEntry[] = [];\n for (const line of output.split(\"\\n\")) {\n const groups = /^\\s*(?<pid>\\d+)\\s+(?<ppid>\\d+)\\s+(?<pgid>\\d+)\\s*$/.exec(line)?.groups;\n if (groups === undefined) {\n continue;\n }\n const processId = Number(groups[\"pid\"]);\n const parentProcessId = Number(groups[\"ppid\"]);\n const processGroupId = Number(groups[\"pgid\"]);\n if (\n !Number.isSafeInteger(processId) ||\n processId <= 0 ||\n !Number.isSafeInteger(parentProcessId) ||\n parentProcessId < 0 ||\n !Number.isSafeInteger(processGroupId) ||\n processGroupId <= 0\n ) {\n continue;\n }\n entries.push({ parentProcessId, processGroupId, processId });\n }\n return entries;\n}\n\nexport function readProcessTableWithPs(executable: string): Promise<readonly ProcessTableEntry[]> {\n return new Promise((resolveTable) => {\n execFile(\n executable,\n [\"-axo\", \"pid=,ppid=,pgid=\"],\n {\n encoding: \"utf8\",\n maxBuffer: PROCESS_TABLE_OUTPUT_LIMIT_BYTES,\n signal: AbortSignal.timeout(PROCESS_TABLE_TIMEOUT_MILLISECONDS),\n timeout: PROCESS_TABLE_TIMEOUT_MILLISECONDS,\n },\n (error, stdout) => {\n resolveTable(error === null ? parseProcessTable(stdout) : []);\n },\n );\n });\n}\n\nexport function processExists(processId: number): boolean {\n try {\n process.kill(processId, 0);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function signalCapturedProcesses(\n processes: readonly ProcessTreeIdentity[],\n rootProcessId: number,\n signal: number,\n): void {\n const processIds = new Set(processes.map((identity) => identity.processId));\n const signalledGroups = new Set<number>();\n for (const identity of processes) {\n const isRootProcessGroup = identity.processGroupId === rootProcessId;\n if (\n (!isRootProcessGroup && !processIds.has(identity.processGroupId)) ||\n signalledGroups.has(identity.processGroupId)\n ) {\n continue;\n }\n try {\n process.kill(-identity.processGroupId, signal);\n signalledGroups.add(identity.processGroupId);\n } catch {\n // A concurrently exited group no longer needs cleanup.\n }\n }\n for (const identity of processes) {\n if (\n identity.processId === rootProcessId ||\n identity.processGroupId === rootProcessId ||\n signalledGroups.has(identity.processGroupId)\n ) {\n continue;\n }\n try {\n process.kill(identity.processId, signal);\n } catch {\n // A concurrently exited process no longer needs cleanup.\n }\n }\n}\n\nfunction terminateProcess(child: ChildProcess, signal: NodeJS.Signals): void {\n if (child.exitCode !== null || child.signalCode !== null || child.pid === undefined) {\n return;\n }\n try {\n process.kill(-child.pid, signal);\n return;\n } catch {\n // Fall through when the child did not create a process group.\n }\n child.kill(signal);\n}\n\nasync function removeControlSocket(path: string): Promise<void> {\n try {\n await unlink(path);\n } catch (cause) {\n if (!(cause instanceof Error) || !(\"code\" in cause) || cause.code !== \"ENOENT\") {\n throw cause;\n }\n }\n}\n\nexport const posixOperations = {\n controlSocketPath: (installationHash: string) => join(tmpdir(), `mobius-${installationHash}.sock`),\n prepareControlSocket: removeControlSocket,\n secureControlSocket: async (path: string) => {\n await chmod(path, 0o600);\n },\n removeControlSocket,\n\n pathDelimiter: \":\",\n environmentValue: (environment: Readonly<NodeJS.ProcessEnv>, name: string) => environment[name],\n executableExtensions: () => [\"\"],\n resolveExecutableTarget: async (path: string) => {\n const target = await realpath(path);\n await access(target, constants.X_OK);\n return target;\n },\n executableLaunch: (command: string, args: readonly string[]) => ({ command, arguments: args }),\n spawnOptions: { detached: true, windowsHide: true },\n signalCapturedProcesses,\n terminateProcess,\n validatePathPermissions: async (path: string, directory: boolean, privateAccess: boolean, signal: AbortSignal) => {\n signal.throwIfAborted();\n const metadata = await lstat(path);\n if (process.getuid === undefined || metadata.uid !== process.getuid()) {\n throw new LocalPathError(\"Path is not user-owned\");\n }\n if (privateAccess) {\n await chmod(path, directory ? 0o700 : 0o600);\n }\n signal.throwIfAborted();\n },\n} satisfies Pick<\n PlatformSupport,\n | \"controlSocketPath\"\n | \"prepareControlSocket\"\n | \"secureControlSocket\"\n | \"removeControlSocket\"\n | \"pathDelimiter\"\n | \"environmentValue\"\n | \"executableExtensions\"\n | \"resolveExecutableTarget\"\n | \"executableLaunch\"\n | \"spawnOptions\"\n | \"signalCapturedProcesses\"\n | \"terminateProcess\"\n | \"validatePathPermissions\"\n>;\n", "export class LocalPathError extends Error {\n readonly code = \"unsafe_local_path\";\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n this.name = \"LocalPathError\";\n }\n}\n", "import { isAbsolute, join } from \"node:path\";\nimport { claudeDesktopExecutablePaths } from \"./claude-desktop.ts\";\nimport type { PlatformSupport } from \"./contracts.ts\";\nimport { posixOperations, processExists, readProcessTableWithPs } from \"./posix.ts\";\n\nexport const macosPlatform: PlatformSupport = {\n ...posixOperations,\n readProcessTable: () => readProcessTableWithPs(\"/bin/ps\"),\n readProcessTableSynchronously: () => [],\n processExists,\n claudeCodeExecutablePaths: (environment) => {\n const paths = [\"/opt/homebrew/bin/claude\", \"/usr/local/bin/claude\"];\n const homeDirectory = environment[\"HOME\"];\n if (homeDirectory !== undefined && isAbsolute(homeDirectory)) {\n paths.unshift(join(homeDirectory, \".local\", \"bin\", \"claude\"));\n paths.push(\n ...claudeDesktopExecutablePaths(\n [join(homeDirectory, \"Library\", \"Application Support\", \"Claude\", \"claude-code\")],\n [[\"claude.app\", \"Contents\", \"MacOS\", \"claude\"], [\"claude\"]],\n ),\n );\n }\n return paths;\n },\n};\n", "import { readdirSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport function installedDirectories(directory: string): readonly string[] {\n try {\n return readdirSync(directory, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name);\n } catch (cause) {\n if (\n cause instanceof Error &&\n \"code\" in cause &&\n (cause.code === \"ENOENT\" || cause.code === \"ENOTDIR\" || cause.code === \"EACCES\")\n ) {\n return [];\n }\n throw cause;\n }\n}\n\nexport function claudeDesktopExecutablePaths(\n roots: readonly string[],\n executablePaths: readonly (readonly string[])[],\n): readonly string[] {\n const paths: string[] = [];\n for (const root of roots) {\n const versions = installedDirectories(root)\n .filter((version) => /^\\d+\\.\\d+\\.\\d+$/.test(version))\n .toSorted((left, right) => right.localeCompare(left, \"en\", { numeric: true }));\n for (const version of versions) {\n const directory = join(root, version);\n // Current Desktop builds use checksum directories; older versions install directly.\n const installations = [\n directory,\n ...installedDirectories(directory).map((build) => join(directory, build)),\n ];\n for (const installation of installations) {\n for (const executablePath of executablePaths) {\n paths.push(join(installation, ...executablePath));\n }\n }\n }\n }\n return paths;\n}\n", "import { type ChildProcess, execFile } from \"node:child_process\";\nimport { readFile, realpath } from \"node:fs/promises\";\nimport { dirname, extname, isAbsolute, join, resolve } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport { LocalPathError } from \"../filesystem/path-error.ts\";\nimport { ProcessExecutionError } from \"../process/process-error.ts\";\nimport { claudeDesktopExecutablePaths, installedDirectories } from \"./claude-desktop.ts\";\nimport type { PlatformSupport, ProcessLaunch, ProcessTableEntry, ProcessTreeIdentity } from \"./contracts.ts\";\nimport { parseProcessTable, processExists } from \"./posix.ts\";\n\nconst execute = promisify(execFile);\n\nfunction environmentValue(environment: Readonly<NodeJS.ProcessEnv>, name: string): string | undefined {\n return Object.entries(environment).find(([key]) => key.toUpperCase() === name.toUpperCase())?.[1];\n}\n\nfunction desktopClaudeExecutablePaths(environment: Readonly<NodeJS.ProcessEnv>): readonly string[] {\n const roots: string[] = [];\n const localAppData = environmentValue(environment, \"LOCALAPPDATA\");\n if (localAppData !== undefined && isAbsolute(localAppData)) {\n const dataDirectory = join(localAppData, \"Claude-Data\");\n for (const installation of installedDirectories(dataDirectory)) {\n if (installation.startsWith(\"claude_\")) {\n roots.push(join(dataDirectory, installation, \"claude-code\"));\n }\n }\n }\n const appData = environmentValue(environment, \"APPDATA\");\n if (appData !== undefined && isAbsolute(appData)) {\n roots.push(join(appData, \"Claude\", \"claude-code\"));\n }\n return claudeDesktopExecutablePaths(roots, [[\"claude.exe\"]]);\n}\n\nfunction executableExtensions(executableName: string, environment: Readonly<NodeJS.ProcessEnv>): readonly string[] {\n if (/\\.[a-zA-Z0-9]+$/.test(executableName)) {\n return [\"\"];\n }\n const configured = environmentValue(environment, \"PATHEXT\") ?? \".COM;.EXE;.BAT;.CMD\";\n const extensions = configured\n .split(\";\")\n .map((extension) => extension.trim())\n .filter((extension) => extension.length > 0)\n .map((extension) => (extension.startsWith(\".\") ? extension : `.${extension}`));\n return extensions.length > 0 ? extensions : [\".EXE\"];\n}\n\nasync function resolveExecutableTarget(path: string): Promise<string> {\n let resolvedPath: string;\n try {\n resolvedPath = await realpath(extname(path) === \"\" ? `${path}.cmd` : path);\n } catch (cause) {\n if (extname(path) !== \"\" || !(cause instanceof Error) || !(\"code\" in cause) || cause.code !== \"ENOENT\") {\n throw cause;\n }\n resolvedPath = await realpath(path);\n }\n if (extname(resolvedPath).toLowerCase() === \".cmd\") {\n // npm cmd-shim entrypoints are Node scripts. Resolve the script instead of\n // handing untrusted arguments to cmd.exe's command language.\n const shim = await readFile(resolvedPath, \"utf8\");\n // Node's bundled npm uses its own shim format, not npm cmd-shim.\n if (\n shim.includes('SET \"NPM_CLI_JS=%~dp0\\\\node_modules\\\\npm\\\\bin\\\\npm-cli.js\"') &&\n shim.includes('\"%NODE_EXE%\" \"%NPM_CLI_JS%\" %*')\n ) {\n return await realpath(resolve(dirname(resolvedPath), \"node_modules/npm/bin/npm-cli.js\"));\n }\n const script = /\"%_prog%\"\\s+\"%dp0%[\\\\/]([^\"\\r\\n]+\\.(?:js|mjs|cjs))\"\\s+%\\*/iu.exec(shim)?.[1];\n if (script !== undefined && shim.includes(\"SET dp0=%~dp0\")) {\n resolvedPath = await realpath(resolve(dirname(resolvedPath), script));\n } else {\n const pnpmScript = /^\\s*node\\s+\"%~dp0[\\\\/]([^\"\\r\\n]+\\.(?:js|mjs|cjs))\"\\s+%\\*\\s*$/imu.exec(shim)?.[1];\n if (pnpmScript === undefined || !shim.includes(\"@SETLOCAL\")) {\n throw new ProcessExecutionError(\n \"process_unsupported_script\",\n \"Use a native executable or a verified Node entrypoint\",\n );\n }\n resolvedPath = await realpath(resolve(dirname(resolvedPath), pnpmScript));\n }\n }\n return resolvedPath;\n}\n\nfunction executableLaunch(command: string, args: readonly string[]): ProcessLaunch {\n if (/\\.(?:js|mjs|cjs)$/iu.test(command)) {\n return { command: process.execPath, arguments: [command, ...args] };\n }\n if (/\\.(?:cmd|bat)$/iu.test(command)) {\n throw new ProcessExecutionError(\n \"process_unsupported_script\",\n \"Use a native executable or a verified Node entrypoint\",\n );\n }\n return { command, arguments: args };\n}\n\nfunction readProcessTable(): Promise<readonly ProcessTableEntry[]> {\n const systemRoot = environmentValue(process.env, \"SystemRoot\");\n if (systemRoot === undefined) {\n return Promise.resolve([]);\n }\n return new Promise((resolveTable) => {\n execFile(\n join(systemRoot, \"System32\", \"WindowsPowerShell\", \"v1.0\", \"powershell.exe\"),\n [\n \"-NoLogo\",\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n \"Get-CimInstance Win32_Process | ForEach-Object { '{0} {1} {0}' -f $_.ProcessId, $_.ParentProcessId }\",\n ],\n {\n encoding: \"utf8\",\n windowsHide: true,\n timeout: 10000,\n signal: AbortSignal.timeout(10000),\n maxBuffer: 1024 * 1024,\n },\n (error, stdout) => resolveTable(error === null ? parseProcessTable(stdout) : []),\n );\n });\n}\n\nfunction signalCapturedProcesses(\n processes: readonly ProcessTreeIdentity[],\n _rootProcessId: number,\n signal: number,\n): void {\n for (const identity of [...processes].reverse()) {\n try {\n process.kill(identity.processId, signal);\n } catch {\n // A concurrently exited process no longer needs cleanup.\n }\n }\n}\n\nfunction terminateProcess(child: ChildProcess, signal: NodeJS.Signals): void {\n if (child.exitCode !== null || child.signalCode !== null || child.pid === undefined) {\n return;\n }\n child.kill(signal);\n}\n\n// The path is data in the environment, never interpolated into PowerShell source.\nconst windowsPermissions = `\n$ErrorActionPreference = 'Stop'\n$ProgressPreference = 'SilentlyContinue'\n$item = Get-Item -LiteralPath $env:MOBIUS_PERMISSION_PATH -Force\nif (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) { throw 'Unsafe path' }\n$sid = [Security.Principal.WindowsIdentity]::GetCurrent().User\n$acl = $item.GetAccessControl()\n$owner = $acl.GetOwner([Security.Principal.SecurityIdentifier])\nif ($owner -ne $sid -and -not ($owner.Value -eq 'S-1-5-32-544' -and ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) { throw 'Path is not user-owned' }\nif ($env:MOBIUS_PERMISSION_PRIVATE -eq '1') {\n if ($item.PSIsContainer) {\n $private = New-Object Security.AccessControl.DirectorySecurity\n $rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')\n } else {\n $private = New-Object Security.AccessControl.FileSecurity\n $rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'Allow')\n }\n $private.SetOwner($sid)\n $private.SetAccessRuleProtection($true, $false)\n $private.AddAccessRule($rule)\n $item.SetAccessControl($private)\n}\n`;\n\n// Keep ACL validation bounded in case Windows filesystem operations stall.\nconst windowsPermissionsTimeoutMs = 30_000;\n\nasync function validatePathPermissions(\n path: string,\n _directory: boolean,\n privateAccess: boolean,\n signal: AbortSignal,\n): Promise<void> {\n signal.throwIfAborted();\n const systemRoot = environmentValue(process.env, \"SystemRoot\");\n if (systemRoot === undefined) {\n throw new LocalPathError(\"Windows system directory is unavailable\");\n }\n try {\n await execute(\n join(systemRoot, \"System32\", \"WindowsPowerShell\", \"v1.0\", \"powershell.exe\"),\n [\n \"-NoLogo\",\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-EncodedCommand\",\n Buffer.from(windowsPermissions, \"utf16le\").toString(\"base64\"),\n ],\n {\n env: {\n ...process.env,\n MOBIUS_PERMISSION_PATH: path,\n MOBIUS_PERMISSION_PRIVATE: privateAccess ? \"1\" : \"0\",\n },\n windowsHide: true,\n signal: AbortSignal.any([signal, AbortSignal.timeout(windowsPermissionsTimeoutMs)]),\n timeout: windowsPermissionsTimeoutMs,\n maxBuffer: 16384,\n },\n );\n } catch (cause) {\n signal.throwIfAborted();\n throw new LocalPathError(\"The local path permissions could not be secured\", { cause });\n }\n}\n\nexport const windowsPlatform: PlatformSupport = {\n controlSocketPath: (installationHash) => `\\\\\\\\.\\\\pipe\\\\mobius-${installationHash}`,\n prepareControlSocket: async () => {},\n secureControlSocket: async () => {},\n removeControlSocket: async () => {},\n\n pathDelimiter: \";\",\n environmentValue,\n executableExtensions,\n resolveExecutableTarget,\n executableLaunch,\n spawnOptions: { detached: false, windowsHide: true },\n signalCapturedProcesses,\n terminateProcess,\n validatePathPermissions,\n readProcessTable,\n readProcessTableSynchronously: () => [],\n processExists,\n claudeCodeExecutablePaths: (environment) => {\n const paths: string[] = [];\n const userProfile = environmentValue(environment, \"USERPROFILE\");\n if (userProfile !== undefined && isAbsolute(userProfile)) {\n paths.push(join(userProfile, \".local\", \"bin\", \"claude.exe\"));\n }\n const localAppData = environmentValue(environment, \"LOCALAPPDATA\");\n if (localAppData !== undefined && isAbsolute(localAppData)) {\n paths.push(join(localAppData, \"Microsoft\", \"WinGet\", \"Links\", \"claude.exe\"));\n }\n paths.push(...desktopClaudeExecutablePaths(environment));\n return paths;\n },\n};\n", "export class ProcessExecutionError extends Error {\n readonly code: string;\n\n constructor(code: string, message: string, options: ErrorOptions = {}) {\n super(message, options);\n this.code = code;\n this.name = \"ProcessExecutionError\";\n }\n}\n", "import type { PlatformSupport } from \"./contracts.ts\";\nimport { linuxPlatform } from \"./linux.ts\";\nimport { macosPlatform } from \"./macos.ts\";\nimport { posixOperations, processExists, readProcessTableWithPs } from \"./posix.ts\";\nimport { windowsPlatform } from \"./windows.ts\";\n\n// Preserve the existing fallback for other POSIX hosts.\nconst fallbackPlatform: PlatformSupport = {\n ...posixOperations,\n readProcessTable: () => readProcessTableWithPs(\"/usr/bin/ps\"),\n readProcessTableSynchronously: () => [],\n processExists,\n claudeCodeExecutablePaths: () => [],\n};\nconst platforms: ReadonlyMap<NodeJS.Platform, PlatformSupport> = new Map([\n [\"linux\", linuxPlatform],\n [\"darwin\", macosPlatform],\n [\"win32\", windowsPlatform],\n]);\n\nexport function platformSupportFor(platform: NodeJS.Platform): PlatformSupport {\n return platforms.get(platform) ?? fallbackPlatform;\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,SAAAA,cAAa;;;ACAtB,SAAS,aAAAC,YAAW,aAAa,oBAAoB;AACrD,SAAS,UAAAC,SAAQ,SAAS,UAAU,YAAAC,WAAU,YAAY;AAC1D,SAAS,YAAY,QAAAC,aAAY;;;ACFjC,SAA4B,gBAAgB;AAC5C,SAAS,iBAAiB;AAC1B,SAAS,QAAQ,OAAO,OAAO,UAAU,cAAc;AACvD,SAAS,cAAc;AACvB,SAAS,YAAY;;;ACJd,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAC7B,OAAO;AAAA,EAEhB,YAAY,SAAiB,UAAwB,CAAC,GAAG;AACrD,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EAChB;AACJ;;;ADCA,IAAM,qCAAqC;AAC3C,IAAM,mCAAmC,OAAO;AAEzC,SAAS,kBAAkB,QAA8C;AAC5E,QAAM,UAA+B,CAAC;AACtC,aAAW,QAAQ,OAAO,MAAM,IAAI,GAAG;AACnC,UAAM,SAAS,oDAAoD,KAAK,IAAI,GAAG;AAC/E,QAAI,WAAW,QAAW;AACtB;AAAA,IACJ;AACA,UAAM,YAAY,OAAO,OAAO,KAAK,CAAC;AACtC,UAAM,kBAAkB,OAAO,OAAO,MAAM,CAAC;AAC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aL,YAAW,WAAW,GAAG;AACtD,YAAM,KAAKC,MAAK,aAAa,UAAU,OAAO,YAAY,CAAC;AAAA,IAC/D;AACA,UAAM,eAAe,iBAAiB,aAAa,cAAc;AACjE,QAAI,iBAAiB,UAAaD,YAAW,YAAY,GAAG;AACxD,YAAM,KAAKC,MAAK,cAAc,aAAa,UAAU,SAAS,YAAY,CAAC;AAAA,IAC/E;AACA,UAAM,KAAK,GAAG,6BAA6B,WAAW,CAAC;AACvD,WAAO;AAAA,EACX;AACJ;;;AE7OA,IAAM,mBAAoC;AAAA,EACtC,GAAG;AAAA,EACH,kBAAkB,MAAM,uBAAuB,aAAa;AAAA,EAC5D,+BAA+B,MAAM,CAAC;AAAA,EACtC;AAAA,EACA,2BAA2B,MAAM,CAAC;AACtC;AACA,IAAM,YAA2D,oBAAI,IAAI;AAAA,EACrE,CAAC,SAAS,aAAa;AAAA,EACvB,CAAC,UAAU,aAAa;AAAA,EACxB,CAAC,SAAS,eAAe;AAC7B,CAAC;AAEM,SAAS,mBAAmB,UAA4C;AAC3E,SAAO,UAAU,IAAI,QAAQ,KAAK;AACtC;;;ARhBA,eAAsB,kBAClB,MACA,WACA,eACA,QACa;AACb,SAAO,eAAe;AACtB,QAAM,WAAW,MAAMK,OAAM,IAAI;AACjC,MAAI,SAAS,eAAe,MAAM,YAAY,CAAC,SAAS,YAAY,IAAI,CAAC,SAAS,OAAO,IAAI;AACzF,UAAM,IAAI,eAAe,mBAAmB;AAAA,EAChD;AACA,QAAM,mBAAmB,QAAQ,QAAQ,EAAE,wBAAwB,MAAM,WAAW,eAAe,MAAM;AAC7G;",
|
|
6
|
-
"names": ["lstat", "
|
|
3
|
+
"sources": ["../../../src/util/filesystem/private-path.ts", "../../../src/util/platform/linux.ts", "../../../src/util/platform/posix.ts", "../../../src/util/filesystem/path-error.ts", "../../../src/util/platform/macos.ts", "../../../src/util/platform/claude-desktop.ts", "../../../src/util/platform/windows.ts", "../../../src/util/platform/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { lstat } from \"node:fs/promises\";\nimport { platformSupportFor } from \"../platform/index.ts\";\nimport { LocalPathError } from \"./path-error.ts\";\n\nexport { LocalPathError } from \"./path-error.ts\";\n\nexport async function validateLocalPath(\n path: string,\n directory: boolean,\n privateAccess: boolean,\n signal: AbortSignal,\n): Promise<void> {\n signal.throwIfAborted();\n const metadata = await lstat(path);\n if (metadata.isSymbolicLink() || (directory ? !metadata.isDirectory() : !metadata.isFile())) {\n throw new LocalPathError(\"Unsafe local path\");\n }\n await platformSupportFor(process.platform).validatePathPermissions(path, directory, privateAccess, signal);\n}\n", "import { isAbsolute, join } from \"node:path\";\nimport type { PlatformSupport } from \"./contracts.ts\";\nimport { posixOperations } from \"./posix.ts\";\n\nexport const linuxPlatform: PlatformSupport = {\n ...posixOperations,\n claudeCodeExecutablePaths: (environment) => {\n const homeDirectory = environment[\"HOME\"];\n return homeDirectory !== undefined && isAbsolute(homeDirectory)\n ? [join(homeDirectory, \".local\", \"bin\", \"claude\")]\n : [];\n },\n};\n", "import { chmod, lstat, unlink } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { LocalPathError } from \"../filesystem/path-error.ts\";\nimport type { PlatformSupport } from \"./contracts.ts\";\n\nasync function removeControlSocket(path: string): Promise<void> {\n try {\n await unlink(path);\n } catch (cause) {\n if (!(cause instanceof Error) || !(\"code\" in cause) || cause.code !== \"ENOENT\") {\n throw cause;\n }\n }\n}\n\nexport const posixOperations = {\n controlSocketPath: (installationHash: string) => join(tmpdir(), `mobius-${installationHash}.sock`),\n prepareControlSocket: removeControlSocket,\n secureControlSocket: async (path: string) => {\n await chmod(path, 0o600);\n },\n removeControlSocket,\n validatePathPermissions: async (path: string, directory: boolean, privateAccess: boolean, signal: AbortSignal) => {\n signal.throwIfAborted();\n const metadata = await lstat(path);\n if (process.getuid === undefined || metadata.uid !== process.getuid()) {\n throw new LocalPathError(\"Path is not user-owned\");\n }\n if (privateAccess) {\n await chmod(path, directory ? 0o700 : 0o600);\n }\n signal.throwIfAborted();\n },\n} satisfies Pick<\n PlatformSupport,\n | \"controlSocketPath\"\n | \"prepareControlSocket\"\n | \"secureControlSocket\"\n | \"removeControlSocket\"\n | \"validatePathPermissions\"\n>;\n", "export class LocalPathError extends Error {\n readonly code = \"unsafe_local_path\";\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n this.name = \"LocalPathError\";\n }\n}\n", "import { isAbsolute, join } from \"node:path\";\nimport { claudeDesktopExecutablePaths } from \"./claude-desktop.ts\";\nimport type { PlatformSupport } from \"./contracts.ts\";\nimport { posixOperations } from \"./posix.ts\";\n\nexport const macosPlatform: PlatformSupport = {\n ...posixOperations,\n claudeCodeExecutablePaths: (environment) => {\n const paths = [\"/opt/homebrew/bin/claude\", \"/usr/local/bin/claude\"];\n const homeDirectory = environment[\"HOME\"];\n if (homeDirectory !== undefined && isAbsolute(homeDirectory)) {\n paths.unshift(join(homeDirectory, \".local\", \"bin\", \"claude\"));\n paths.push(\n ...claudeDesktopExecutablePaths(\n [join(homeDirectory, \"Library\", \"Application Support\", \"Claude\", \"claude-code\")],\n [[\"claude.app\", \"Contents\", \"MacOS\", \"claude\"], [\"claude\"]],\n ),\n );\n }\n return paths;\n },\n};\n", "import { readdirSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport function installedDirectories(directory: string): readonly string[] {\n try {\n return readdirSync(directory, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name);\n } catch (cause) {\n if (\n cause instanceof Error &&\n \"code\" in cause &&\n (cause.code === \"ENOENT\" || cause.code === \"ENOTDIR\" || cause.code === \"EACCES\")\n ) {\n return [];\n }\n throw cause;\n }\n}\n\nexport function claudeDesktopExecutablePaths(\n roots: readonly string[],\n executablePaths: readonly (readonly string[])[],\n): readonly string[] {\n const paths: string[] = [];\n for (const root of roots) {\n const versions = installedDirectories(root)\n .filter((version) => /^\\d+\\.\\d+\\.\\d+$/.test(version))\n .toSorted((left, right) => right.localeCompare(left, \"en\", { numeric: true }));\n for (const version of versions) {\n const directory = join(root, version);\n // Current Desktop builds use checksum directories; older versions install directly.\n const installations = [\n directory,\n ...installedDirectories(directory).map((build) => join(directory, build)),\n ];\n for (const installation of installations) {\n for (const executablePath of executablePaths) {\n paths.push(join(installation, ...executablePath));\n }\n }\n }\n }\n return paths;\n}\n", "import { execFile } from \"node:child_process\";\nimport { isAbsolute, join } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport { LocalPathError } from \"../filesystem/path-error.ts\";\nimport { claudeDesktopExecutablePaths, installedDirectories } from \"./claude-desktop.ts\";\nimport type { PlatformSupport } from \"./contracts.ts\";\n\nconst execute = promisify(execFile);\n\nfunction environmentValue(environment: Readonly<NodeJS.ProcessEnv>, name: string): string | undefined {\n return Object.entries(environment).find(([key]) => key.toUpperCase() === name.toUpperCase())?.[1];\n}\n\nfunction desktopClaudeExecutablePaths(environment: Readonly<NodeJS.ProcessEnv>): readonly string[] {\n const roots: string[] = [];\n const localAppData = environmentValue(environment, \"LOCALAPPDATA\");\n if (localAppData !== undefined && isAbsolute(localAppData)) {\n const dataDirectory = join(localAppData, \"Claude-Data\");\n for (const installation of installedDirectories(dataDirectory)) {\n if (installation.startsWith(\"claude_\")) {\n roots.push(join(dataDirectory, installation, \"claude-code\"));\n }\n }\n }\n const appData = environmentValue(environment, \"APPDATA\");\n if (appData !== undefined && isAbsolute(appData)) {\n roots.push(join(appData, \"Claude\", \"claude-code\"));\n }\n return claudeDesktopExecutablePaths(roots, [[\"claude.exe\"]]);\n}\n\n// The path is data in the environment, never interpolated into PowerShell source.\nconst windowsPermissions = `\n$ErrorActionPreference = 'Stop'\n$ProgressPreference = 'SilentlyContinue'\n$item = Get-Item -LiteralPath $env:MOBIUS_PERMISSION_PATH -Force\nif (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) { throw 'Unsafe path' }\n$sid = [Security.Principal.WindowsIdentity]::GetCurrent().User\n$acl = $item.GetAccessControl()\n$owner = $acl.GetOwner([Security.Principal.SecurityIdentifier])\nif ($owner -ne $sid -and -not ($owner.Value -eq 'S-1-5-32-544' -and ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) { throw 'Path is not user-owned' }\nif ($env:MOBIUS_PERMISSION_PRIVATE -eq '1') {\n if ($item.PSIsContainer) {\n $private = New-Object Security.AccessControl.DirectorySecurity\n $rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')\n } else {\n $private = New-Object Security.AccessControl.FileSecurity\n $rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'Allow')\n }\n $private.SetOwner($sid)\n $private.SetAccessRuleProtection($true, $false)\n $private.AddAccessRule($rule)\n $item.SetAccessControl($private)\n}\n`;\n\n// Keep ACL validation bounded in case Windows filesystem operations stall.\nconst windowsPermissionsTimeoutMs = 30_000;\n\nasync function validatePathPermissions(\n path: string,\n _directory: boolean,\n privateAccess: boolean,\n signal: AbortSignal,\n): Promise<void> {\n signal.throwIfAborted();\n const systemRoot = environmentValue(process.env, \"SystemRoot\");\n if (systemRoot === undefined) {\n throw new LocalPathError(\"Windows system directory is unavailable\");\n }\n try {\n await execute(\n join(systemRoot, \"System32\", \"WindowsPowerShell\", \"v1.0\", \"powershell.exe\"),\n [\n \"-NoLogo\",\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-EncodedCommand\",\n Buffer.from(windowsPermissions, \"utf16le\").toString(\"base64\"),\n ],\n {\n env: {\n ...process.env,\n MOBIUS_PERMISSION_PATH: path,\n MOBIUS_PERMISSION_PRIVATE: privateAccess ? \"1\" : \"0\",\n },\n windowsHide: true,\n signal: AbortSignal.any([signal, AbortSignal.timeout(windowsPermissionsTimeoutMs)]),\n timeout: windowsPermissionsTimeoutMs,\n maxBuffer: 16384,\n },\n );\n } catch (cause) {\n signal.throwIfAborted();\n throw new LocalPathError(\"The local path permissions could not be secured\", { cause });\n }\n}\n\nexport const windowsPlatform: PlatformSupport = {\n controlSocketPath: (installationHash) => `\\\\\\\\.\\\\pipe\\\\mobius-${installationHash}`,\n prepareControlSocket: async () => {},\n secureControlSocket: async () => {},\n removeControlSocket: async () => {},\n validatePathPermissions,\n claudeCodeExecutablePaths: (environment) => {\n const paths: string[] = [];\n const userProfile = environmentValue(environment, \"USERPROFILE\");\n if (userProfile !== undefined && isAbsolute(userProfile)) {\n paths.push(join(userProfile, \".local\", \"bin\", \"claude.exe\"));\n }\n const localAppData = environmentValue(environment, \"LOCALAPPDATA\");\n if (localAppData !== undefined && isAbsolute(localAppData)) {\n paths.push(join(localAppData, \"Microsoft\", \"WinGet\", \"Links\", \"claude.exe\"));\n }\n paths.push(...desktopClaudeExecutablePaths(environment));\n return paths;\n },\n};\n", "import type { PlatformSupport } from \"./contracts.ts\";\nimport { linuxPlatform } from \"./linux.ts\";\nimport { macosPlatform } from \"./macos.ts\";\nimport { posixOperations } from \"./posix.ts\";\nimport { windowsPlatform } from \"./windows.ts\";\n\n// Preserve the existing fallback for other POSIX hosts.\nconst fallbackPlatform: PlatformSupport = {\n ...posixOperations,\n claudeCodeExecutablePaths: () => [],\n};\nconst platforms: ReadonlyMap<NodeJS.Platform, PlatformSupport> = new Map([\n [\"linux\", linuxPlatform],\n [\"darwin\", macosPlatform],\n [\"win32\", windowsPlatform],\n]);\n\nexport function platformSupportFor(platform: NodeJS.Platform): PlatformSupport {\n return platforms.get(platform) ?? fallbackPlatform;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,SAAAA,cAAa;;;ACAtB,SAAS,YAAY,QAAAC,aAAY;;;ACAjC,SAAS,OAAO,OAAO,cAAc;AACrC,SAAS,cAAc;AACvB,SAAS,YAAY;;;ACFd,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAC7B,OAAO;AAAA,EAEhB,YAAY,SAAiB,UAAwB,CAAC,GAAG;AACrD,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;;AC9GA,IAAM,mBAAoC;AAAA,EACtC,GAAG;AAAA,EACH,2BAA2B,MAAM,CAAC;AACtC;AACA,IAAM,YAA2D,oBAAI,IAAI;AAAA,EACrE,CAAC,SAAS,aAAa;AAAA,EACvB,CAAC,UAAU,aAAa;AAAA,EACxB,CAAC,SAAS,eAAe;AAC7B,CAAC;AAEM,SAAS,mBAAmB,UAA4C;AAC3E,SAAO,UAAU,IAAI,QAAQ,KAAK;AACtC;;;APbA,eAAsB,kBAClB,MACA,WACA,eACA,QACa;AACb,SAAO,eAAe;AACtB,QAAM,WAAW,MAAMC,OAAM,IAAI;AACjC,MAAI,SAAS,eAAe,MAAM,YAAY,CAAC,SAAS,YAAY,IAAI,CAAC,SAAS,OAAO,IAAI;AACzF,UAAM,IAAI,eAAe,mBAAmB;AAAA,EAChD;AACA,QAAM,mBAAmB,QAAQ,QAAQ,EAAE,wBAAwB,MAAM,WAAW,eAAe,MAAM;AAC7G;",
|
|
6
|
+
"names": ["lstat", "join", "join", "isAbsolute", "join", "join", "isAbsolute", "join", "isAbsolute", "join", "isAbsolute", "join", "lstat"]
|
|
7
7
|
}
|
|
@@ -1,35 +1,9 @@
|
|
|
1
|
-
import type { ChildProcess } from "node:child_process";
|
|
2
|
-
export interface ProcessTreeIdentity {
|
|
3
|
-
readonly processGroupId: number;
|
|
4
|
-
readonly processId: number;
|
|
5
|
-
}
|
|
6
|
-
export interface ProcessTableEntry extends ProcessTreeIdentity {
|
|
7
|
-
readonly parentProcessId: number;
|
|
8
|
-
}
|
|
9
|
-
export interface ProcessLaunch {
|
|
10
|
-
readonly command: string;
|
|
11
|
-
readonly arguments: readonly string[];
|
|
12
|
-
}
|
|
13
1
|
export interface PlatformSupport {
|
|
14
2
|
readonly controlSocketPath: (installationHash: string) => string;
|
|
15
3
|
readonly prepareControlSocket: (path: string) => Promise<void>;
|
|
16
4
|
readonly secureControlSocket: (path: string) => Promise<void>;
|
|
17
5
|
readonly removeControlSocket: (path: string) => Promise<void>;
|
|
18
|
-
readonly pathDelimiter: string;
|
|
19
|
-
readonly environmentValue: (environment: Readonly<NodeJS.ProcessEnv>, name: string) => string | undefined;
|
|
20
|
-
readonly executableExtensions: (name: string, environment: Readonly<NodeJS.ProcessEnv>) => readonly string[];
|
|
21
|
-
readonly resolveExecutableTarget: (path: string) => Promise<string>;
|
|
22
|
-
readonly executableLaunch: (command: string, args: readonly string[]) => ProcessLaunch;
|
|
23
|
-
readonly spawnOptions: {
|
|
24
|
-
readonly detached: boolean;
|
|
25
|
-
readonly windowsHide: boolean;
|
|
26
|
-
};
|
|
27
|
-
readonly signalCapturedProcesses: (processes: readonly ProcessTreeIdentity[], rootProcessId: number, signal: number) => void;
|
|
28
|
-
readonly terminateProcess: (child: ChildProcess, signal: NodeJS.Signals) => void;
|
|
29
6
|
readonly validatePathPermissions: (path: string, directory: boolean, privateAccess: boolean, signal: AbortSignal) => Promise<void>;
|
|
30
|
-
readonly readProcessTable: () => Promise<readonly ProcessTableEntry[]>;
|
|
31
|
-
readonly readProcessTableSynchronously: () => readonly ProcessTableEntry[];
|
|
32
|
-
readonly processExists: (processId: number) => boolean;
|
|
33
7
|
readonly claudeCodeExecutablePaths: (environment: Readonly<NodeJS.ProcessEnv>) => readonly string[];
|
|
34
8
|
}
|
|
35
9
|
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/util/platform/contracts.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/util/platform/contracts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,iBAAiB,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,MAAM,CAAC;IACjE,QAAQ,CAAC,oBAAoB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,QAAQ,CAAC,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,QAAQ,CAAC,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,QAAQ,CAAC,uBAAuB,EAAE,CAC9B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,OAAO,EACtB,MAAM,EAAE,WAAW,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,QAAQ,CAAC,yBAAyB,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,SAAS,MAAM,EAAE,CAAC;CACvG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/platform/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/platform/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAiBtD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,GAAG,eAAe,CAE7E"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { linuxPlatform } from "./linux.js";
|
|
2
2
|
import { macosPlatform } from "./macos.js";
|
|
3
|
-
import { posixOperations
|
|
3
|
+
import { posixOperations } from "./posix.js";
|
|
4
4
|
import { windowsPlatform } from "./windows.js";
|
|
5
5
|
// Preserve the existing fallback for other POSIX hosts.
|
|
6
6
|
const fallbackPlatform = {
|
|
7
7
|
...posixOperations,
|
|
8
|
-
readProcessTable: () => readProcessTableWithPs("/usr/bin/ps"),
|
|
9
|
-
readProcessTableSynchronously: () => [],
|
|
10
|
-
processExists,
|
|
11
8
|
claudeCodeExecutablePaths: () => [],
|
|
12
9
|
};
|
|
13
10
|
const platforms = new Map([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/util/platform/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/util/platform/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,wDAAwD;AACxD,MAAM,gBAAgB,GAAoB;IACtC,GAAG,eAAe;IAClB,yBAAyB,EAAE,GAAG,EAAE,CAAC,EAAE;CACtC,CAAC;AACF,MAAM,SAAS,GAAkD,IAAI,GAAG,CAAC;IACrE,CAAC,OAAO,EAAE,aAAa,CAAC;IACxB,CAAC,QAAQ,EAAE,aAAa,CAAC;IACzB,CAAC,OAAO,EAAE,eAAe,CAAC;CAC7B,CAAC,CAAC;AAEH,MAAM,UAAU,kBAAkB,CAAC,QAAyB;IACxD,OAAO,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC;AACvD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linux.d.ts","sourceRoot":"","sources":["../../../src/util/platform/linux.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linux.d.ts","sourceRoot":"","sources":["../../../src/util/platform/linux.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,eAAO,MAAM,aAAa,EAAE,eAQ3B,CAAC"}
|
|
@@ -1,123 +1,7 @@
|
|
|
1
|
-
import { constants, readdirSync, readFileSync } from "node:fs";
|
|
2
|
-
import { access, readdir, readFile, realpath, stat } from "node:fs/promises";
|
|
3
1
|
import { isAbsolute, join } from "node:path";
|
|
4
|
-
import { posixOperations
|
|
5
|
-
function appendLinuxProcessTableEntry(entries, processId, encoded) {
|
|
6
|
-
const closingParenthesis = encoded.lastIndexOf(")");
|
|
7
|
-
if (!encoded.startsWith(`${processId.toString()} (`) || closingParenthesis < 0) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const fields = encoded
|
|
11
|
-
.slice(closingParenthesis + 1)
|
|
12
|
-
.trim()
|
|
13
|
-
.split(/\s+/);
|
|
14
|
-
const parentProcessId = Number(fields[1]);
|
|
15
|
-
const processGroupId = Number(fields[2]);
|
|
16
|
-
if (!Number.isSafeInteger(parentProcessId) ||
|
|
17
|
-
parentProcessId < 0 ||
|
|
18
|
-
!Number.isSafeInteger(processGroupId) ||
|
|
19
|
-
processGroupId <= 0) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
entries.push({ parentProcessId, processGroupId, processId });
|
|
23
|
-
}
|
|
24
|
-
async function readLinuxProcessTable() {
|
|
25
|
-
const entries = [];
|
|
26
|
-
try {
|
|
27
|
-
const directories = await readdir("/proc", { withFileTypes: true });
|
|
28
|
-
for (const directory of directories) {
|
|
29
|
-
if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const processId = Number(directory.name);
|
|
33
|
-
if (!Number.isSafeInteger(processId) || processId <= 0) {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
appendLinuxProcessTableEntry(entries, processId, await readFile(join("/proc", directory.name, "stat"), "utf8"));
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
// Processes can exit while procfs is being enumerated.
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
// A restricted Linux runtime may not mount procfs; the fixed ps fallback runs below.
|
|
46
|
-
}
|
|
47
|
-
return entries;
|
|
48
|
-
}
|
|
49
|
-
function readLinuxProcessTableSynchronously() {
|
|
50
|
-
const entries = [];
|
|
51
|
-
try {
|
|
52
|
-
const directories = readdirSync("/proc", { withFileTypes: true });
|
|
53
|
-
for (const directory of directories) {
|
|
54
|
-
if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
const processId = Number(directory.name);
|
|
58
|
-
if (!Number.isSafeInteger(processId) || processId <= 0) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
try {
|
|
62
|
-
appendLinuxProcessTableEntry(entries, processId, readFileSync(join("/proc", directory.name, "stat"), "utf8"));
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
// Processes can exit while procfs is being enumerated.
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
// A restricted Linux runtime may not mount procfs; the asynchronous fallback runs below.
|
|
71
|
-
}
|
|
72
|
-
return entries;
|
|
73
|
-
}
|
|
74
|
-
async function readLinuxProcessTableWithFallback() {
|
|
75
|
-
const procfsEntries = await readLinuxProcessTable();
|
|
76
|
-
if (procfsEntries.length > 0) {
|
|
77
|
-
return procfsEntries;
|
|
78
|
-
}
|
|
79
|
-
for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
|
|
80
|
-
try {
|
|
81
|
-
const resolvedPath = await realpath(candidate);
|
|
82
|
-
if (!(await stat(resolvedPath)).isFile()) {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
await access(resolvedPath, constants.X_OK);
|
|
86
|
-
}
|
|
87
|
-
catch {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
const entries = await readProcessTableWithPs(candidate);
|
|
91
|
-
if (entries.length > 0) {
|
|
92
|
-
return entries;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return [];
|
|
96
|
-
}
|
|
97
|
-
function processExists(processId) {
|
|
98
|
-
try {
|
|
99
|
-
const encoded = readFileSync(join("/proc", processId.toString(), "stat"), "utf8");
|
|
100
|
-
const closingParenthesis = encoded.lastIndexOf(")");
|
|
101
|
-
if (closingParenthesis >= 0) {
|
|
102
|
-
const processState = encoded
|
|
103
|
-
.slice(closingParenthesis + 1)
|
|
104
|
-
.trimStart()
|
|
105
|
-
.charAt(0);
|
|
106
|
-
if (processState === "Z" || processState === "X") {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
// Fall through so restricted procfs mounts still use the portable signal probe.
|
|
113
|
-
}
|
|
114
|
-
return posixProcessExists(processId);
|
|
115
|
-
}
|
|
2
|
+
import { posixOperations } from "./posix.js";
|
|
116
3
|
export const linuxPlatform = {
|
|
117
4
|
...posixOperations,
|
|
118
|
-
readProcessTable: readLinuxProcessTableWithFallback,
|
|
119
|
-
readProcessTableSynchronously: readLinuxProcessTableSynchronously,
|
|
120
|
-
processExists,
|
|
121
5
|
claudeCodeExecutablePaths: (environment) => {
|
|
122
6
|
const homeDirectory = environment["HOME"];
|
|
123
7
|
return homeDirectory !== undefined && isAbsolute(homeDirectory)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linux.js","sourceRoot":"","sources":["../../../src/util/platform/linux.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"linux.js","sourceRoot":"","sources":["../../../src/util/platform/linux.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,CAAC,MAAM,aAAa,GAAoB;IAC1C,GAAG,eAAe;IAClB,yBAAyB,EAAE,CAAC,WAAW,EAAE,EAAE;QACvC,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QAC1C,OAAO,aAAa,KAAK,SAAS,IAAI,UAAU,CAAC,aAAa,CAAC;YAC3D,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YAClD,CAAC,CAAC,EAAE,CAAC;IACb,CAAC;CACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"macos.d.ts","sourceRoot":"","sources":["../../../src/util/platform/macos.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"macos.d.ts","sourceRoot":"","sources":["../../../src/util/platform/macos.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,eAAO,MAAM,aAAa,EAAE,eAgB3B,CAAC"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { isAbsolute, join } from "node:path";
|
|
2
2
|
import { claudeDesktopExecutablePaths } from "./claude-desktop.js";
|
|
3
|
-
import { posixOperations
|
|
3
|
+
import { posixOperations } from "./posix.js";
|
|
4
4
|
export const macosPlatform = {
|
|
5
5
|
...posixOperations,
|
|
6
|
-
readProcessTable: () => readProcessTableWithPs("/bin/ps"),
|
|
7
|
-
readProcessTableSynchronously: () => [],
|
|
8
|
-
processExists,
|
|
9
6
|
claudeCodeExecutablePaths: (environment) => {
|
|
10
7
|
const paths = ["/opt/homebrew/bin/claude", "/usr/local/bin/claude"];
|
|
11
8
|
const homeDirectory = environment["HOME"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"macos.js","sourceRoot":"","sources":["../../../src/util/platform/macos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"macos.js","sourceRoot":"","sources":["../../../src/util/platform/macos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,CAAC,MAAM,aAAa,GAAoB;IAC1C,GAAG,eAAe;IAClB,yBAAyB,EAAE,CAAC,WAAW,EAAE,EAAE;QACvC,MAAM,KAAK,GAAG,CAAC,0BAA0B,EAAE,uBAAuB,CAAC,CAAC;QACpE,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,aAAa,KAAK,SAAS,IAAI,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;YAC3D,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC9D,KAAK,CAAC,IAAI,CACN,GAAG,4BAA4B,CAC3B,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,EAAE,qBAAqB,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,EAChF,CAAC,CAAC,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAC9D,CACJ,CAAC;QACN,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ,CAAC"}
|
|
@@ -1,30 +1,9 @@
|
|
|
1
|
-
import { type ChildProcess } from "node:child_process";
|
|
2
|
-
import type { ProcessTableEntry, ProcessTreeIdentity } from "./contracts.ts";
|
|
3
|
-
export declare function parseProcessTable(output: string): readonly ProcessTableEntry[];
|
|
4
|
-
export declare function readProcessTableWithPs(executable: string): Promise<readonly ProcessTableEntry[]>;
|
|
5
|
-
export declare function processExists(processId: number): boolean;
|
|
6
|
-
export declare function signalCapturedProcesses(processes: readonly ProcessTreeIdentity[], rootProcessId: number, signal: number): void;
|
|
7
|
-
declare function terminateProcess(child: ChildProcess, signal: NodeJS.Signals): void;
|
|
8
1
|
declare function removeControlSocket(path: string): Promise<void>;
|
|
9
2
|
export declare const posixOperations: {
|
|
10
3
|
controlSocketPath: (installationHash: string) => string;
|
|
11
4
|
prepareControlSocket: typeof removeControlSocket;
|
|
12
5
|
secureControlSocket: (path: string) => Promise<void>;
|
|
13
6
|
removeControlSocket: typeof removeControlSocket;
|
|
14
|
-
pathDelimiter: string;
|
|
15
|
-
environmentValue: (environment: Readonly<NodeJS.ProcessEnv>, name: string) => string | undefined;
|
|
16
|
-
executableExtensions: () => string[];
|
|
17
|
-
resolveExecutableTarget: (path: string) => Promise<string>;
|
|
18
|
-
executableLaunch: (command: string, args: readonly string[]) => {
|
|
19
|
-
command: string;
|
|
20
|
-
arguments: readonly string[];
|
|
21
|
-
};
|
|
22
|
-
spawnOptions: {
|
|
23
|
-
detached: true;
|
|
24
|
-
windowsHide: true;
|
|
25
|
-
};
|
|
26
|
-
signalCapturedProcesses: typeof signalCapturedProcesses;
|
|
27
|
-
terminateProcess: typeof terminateProcess;
|
|
28
7
|
validatePathPermissions: (path: string, directory: boolean, privateAccess: boolean, signal: AbortSignal) => Promise<void>;
|
|
29
8
|
};
|
|
30
9
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posix.d.ts","sourceRoot":"","sources":["../../../src/util/platform/posix.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"posix.d.ts","sourceRoot":"","sources":["../../../src/util/platform/posix.ts"],"names":[],"mappings":"AAMA,iBAAe,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ9D;AAED,eAAO,MAAM,eAAe;0CACc,MAAM;;gCAEV,MAAM;;oCAIF,MAAM,aAAa,OAAO,iBAAiB,OAAO,UAAU,WAAW;CAkBhH,CAAC"}
|
|
@@ -1,98 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { constants } from "node:fs";
|
|
3
|
-
import { access, chmod, lstat, realpath, unlink } from "node:fs/promises";
|
|
1
|
+
import { chmod, lstat, unlink } from "node:fs/promises";
|
|
4
2
|
import { tmpdir } from "node:os";
|
|
5
3
|
import { join } from "node:path";
|
|
6
4
|
import { LocalPathError } from "../filesystem/path-error.js";
|
|
7
|
-
const PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1_000;
|
|
8
|
-
const PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
9
|
-
export function parseProcessTable(output) {
|
|
10
|
-
const entries = [];
|
|
11
|
-
for (const line of output.split("\n")) {
|
|
12
|
-
const groups = /^\s*(?<pid>\d+)\s+(?<ppid>\d+)\s+(?<pgid>\d+)\s*$/.exec(line)?.groups;
|
|
13
|
-
if (groups === undefined) {
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
const processId = Number(groups["pid"]);
|
|
17
|
-
const parentProcessId = Number(groups["ppid"]);
|
|
18
|
-
const processGroupId = Number(groups["pgid"]);
|
|
19
|
-
if (!Number.isSafeInteger(processId) ||
|
|
20
|
-
processId <= 0 ||
|
|
21
|
-
!Number.isSafeInteger(parentProcessId) ||
|
|
22
|
-
parentProcessId < 0 ||
|
|
23
|
-
!Number.isSafeInteger(processGroupId) ||
|
|
24
|
-
processGroupId <= 0) {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
entries.push({ parentProcessId, processGroupId, processId });
|
|
28
|
-
}
|
|
29
|
-
return entries;
|
|
30
|
-
}
|
|
31
|
-
export function readProcessTableWithPs(executable) {
|
|
32
|
-
return new Promise((resolveTable) => {
|
|
33
|
-
execFile(executable, ["-axo", "pid=,ppid=,pgid="], {
|
|
34
|
-
encoding: "utf8",
|
|
35
|
-
maxBuffer: PROCESS_TABLE_OUTPUT_LIMIT_BYTES,
|
|
36
|
-
signal: AbortSignal.timeout(PROCESS_TABLE_TIMEOUT_MILLISECONDS),
|
|
37
|
-
timeout: PROCESS_TABLE_TIMEOUT_MILLISECONDS,
|
|
38
|
-
}, (error, stdout) => {
|
|
39
|
-
resolveTable(error === null ? parseProcessTable(stdout) : []);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
export function processExists(processId) {
|
|
44
|
-
try {
|
|
45
|
-
process.kill(processId, 0);
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
export function signalCapturedProcesses(processes, rootProcessId, signal) {
|
|
53
|
-
const processIds = new Set(processes.map((identity) => identity.processId));
|
|
54
|
-
const signalledGroups = new Set();
|
|
55
|
-
for (const identity of processes) {
|
|
56
|
-
const isRootProcessGroup = identity.processGroupId === rootProcessId;
|
|
57
|
-
if ((!isRootProcessGroup && !processIds.has(identity.processGroupId)) ||
|
|
58
|
-
signalledGroups.has(identity.processGroupId)) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
try {
|
|
62
|
-
process.kill(-identity.processGroupId, signal);
|
|
63
|
-
signalledGroups.add(identity.processGroupId);
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
// A concurrently exited group no longer needs cleanup.
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
for (const identity of processes) {
|
|
70
|
-
if (identity.processId === rootProcessId ||
|
|
71
|
-
identity.processGroupId === rootProcessId ||
|
|
72
|
-
signalledGroups.has(identity.processGroupId)) {
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
process.kill(identity.processId, signal);
|
|
77
|
-
}
|
|
78
|
-
catch {
|
|
79
|
-
// A concurrently exited process no longer needs cleanup.
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function terminateProcess(child, signal) {
|
|
84
|
-
if (child.exitCode !== null || child.signalCode !== null || child.pid === undefined) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
try {
|
|
88
|
-
process.kill(-child.pid, signal);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
// Fall through when the child did not create a process group.
|
|
93
|
-
}
|
|
94
|
-
child.kill(signal);
|
|
95
|
-
}
|
|
96
5
|
async function removeControlSocket(path) {
|
|
97
6
|
try {
|
|
98
7
|
await unlink(path);
|
|
@@ -110,18 +19,6 @@ export const posixOperations = {
|
|
|
110
19
|
await chmod(path, 0o600);
|
|
111
20
|
},
|
|
112
21
|
removeControlSocket,
|
|
113
|
-
pathDelimiter: ":",
|
|
114
|
-
environmentValue: (environment, name) => environment[name],
|
|
115
|
-
executableExtensions: () => [""],
|
|
116
|
-
resolveExecutableTarget: async (path) => {
|
|
117
|
-
const target = await realpath(path);
|
|
118
|
-
await access(target, constants.X_OK);
|
|
119
|
-
return target;
|
|
120
|
-
},
|
|
121
|
-
executableLaunch: (command, args) => ({ command, arguments: args }),
|
|
122
|
-
spawnOptions: { detached: true, windowsHide: true },
|
|
123
|
-
signalCapturedProcesses,
|
|
124
|
-
terminateProcess,
|
|
125
22
|
validatePathPermissions: async (path, directory, privateAccess, signal) => {
|
|
126
23
|
signal.throwIfAborted();
|
|
127
24
|
const metadata = await lstat(path);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posix.js","sourceRoot":"","sources":["../../../src/util/platform/posix.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"posix.js","sourceRoot":"","sources":["../../../src/util/platform/posix.ts"],"names":[],"mappings":"AAAA,OAAO,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EAAE,CAAC;YAChB,MAAM,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACjD,CAAC;QACD,MAAM,CAAC,cAAc,EAAE,CAAC;IAC5B,CAAC;CAQJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"windows.d.ts","sourceRoot":"","sources":["../../../src/util/platform/windows.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"windows.d.ts","sourceRoot":"","sources":["../../../src/util/platform/windows.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA6FtD,eAAO,MAAM,eAAe,EAAE,eAmB7B,CAAC"}
|