wslRemoteAgentHostHelpers.ts ×8

Frontier kind: Code frontier

unlabeled · c_26bb2a37d901

10 tests · 4201 LOC · 24 files · introduces 0 tests · 116 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges116 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
517 ranges4201 lines · 24 files · Browse complete extent
All tests (intent)
10 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Introduced files, introduced tests, and structurally relevant concept specializationwslRemoteAgentHostHelpers.ts ×3 · 6 introduced LOCwslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.ts ×1 · 2 introduced LOCwslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.ts ×3 · 6 introduced LOCwslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.ts ×2 · 4 introduced LOCwslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.ts ×6 · 34 introduced LOCwslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.ts ×3 · 14 introduced LOCwslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.ts ×1 · 2 introduced LOCwslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.ts ×1 · 2 introduced LOCwslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.ts ×1 · 2 introduced LOCwslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.ts ×1 · 1 introduced LOCwslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.ts ×1 · 2 introduced LOCwslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.ts ×2 · 6 introduced LOCwslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.ts ×2 · 7 introduced LOCwslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.ts ×2 · 2 introduced LOCwslRemoteAgentHostHelper…sshRemoteAgentHostHelpers.ts ×20 · 256 introduced LOCsshRemoteAgentHostHelper…registry.ts ×4 · 195 introduced LOCregistry.ts ×4actions.ts ×1 · 16 introduced LOCactions.ts ×1actions.ts ×1 · 238 introduced LOCactions.ts ×1uri.test|title=URI URI#file, win-speciale|occurrence=1, charCode.test|title=CharCode has good values|occurrence=1, +2 · 0 introduced LOCuri.test|title=URI URI#f…utils.ts ×3 · 9 introduced LOCutils.ts ×3lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×4 · 8 introduced LOClifecycle.ts ×4lifecycle.ts ×6 · 16 introduced LOClifecycle.ts ×6lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1map.ts ×97 · 3334 introduced LOCmap.ts ×97src/vs/base/common/arrays.ts · 949 LOCcommon/arrays.tssrc/vs/base/common/arraysFind.ts · 226 LOCcommon/arraysFind.tssrc/vs/base/common/assert.ts · 91 LOCcommon/assert.tssrc/vs/base/common/charCode.ts · 450 LOCcommon/charCode.tssrc/vs/base/common/collections.ts · 176 LOCcommon/collections.tssrc/vs/base/common/errors.ts · 357 LOCcommon/errors.tssrc/vs/base/common/functional.ts · 32 LOCcommon/functional.tssrc/vs/base/common/iterator.ts · 194 LOCcommon/iterator.tssrc/vs/base/common/lifecycle.ts · 974 LOCcommon/lifecycle.tssrc/vs/base/common/map.ts · 1016 LOCcommon/map.tssrc/vs/base/common/marshallingIds.ts · 33 LOCcommon/marshallingIds.tssrc/vs/base/common/path.ts · 1589 LOCcommon/path.tssrc/vs/base/common/platform.ts · 281 LOCcommon/platform.tssrc/vs/base/common/process.ts · 76 LOCcommon/process.tssrc/vs/base/common/types.ts · 410 LOCcommon/types.tssrc/vs/base/common/uri.ts · 754 LOCcommon/uri.tssrc/vs/base/test/common/utils.ts · 107 LOCcommon/utils.tssrc/vs/nls.ts · 244 LOCvs/nls.tssrc/vs/platform/agentHost/common/remoteAgentHostMetadata.ts · 95 LOCcommon/remoteAgentHostMe…src/vs/platform/agentHost/common/state/protocol/actions.ts · 16 LOCprotocol/actions.tssrc/vs/platform/agentHost/common/state/protocol/common/actions.ts · 238 LOCcommon/actions.tssrc/vs/platform/agentHost/common/state/protocol/version/registry.ts · 210 LOCversion/registry.tssrc/vs/platform/agentHost/node/sshRemoteAgentHostHelpers.ts · 449 LOCnode/sshRemoteAgentHostH…src/vs/platform/agentHost/node/wslRemoteAgentHostHelpers.ts · 323 LOCnode/wslRemoteAgentHostH…charCode.test|title=CharCode has good values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1charCode.test|title=Char…path.test|title=Paths (Node Implementation) path|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1path.test|title=Paths (N…uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1uri.test|title=URI File …uri.test|title=URI URI#file, win-speciale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1uri.test|title=URI URI#f…wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers decodeWslOutput decodes UTF-16LE input with BOM|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers decodeWslOutput decodes UTF-16LE input with BOM|occurrence=1wslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers decodeWslOutput decodes UTF-8 input|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers decodeWslOutput decodes UTF-8 input|occurrence=1wslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers decodeWslOutput detects null-padded UTF-16LE without BOM via heuristic|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers decodeWslOutput detects null-padded UTF-16LE without BOM via heuristic|occurrence=1wslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers decodeWslOutput returns empty string for empty buffer|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers decodeWslOutput returns empty string for empty buffer|occurrence=1wslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers decodeWslOutput strips UTF-8 BOM|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers decodeWslOutput strips UTF-8 BOM|occurrence=1wslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers parseRunningDistros parses a representative running list end-to-end|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers parseRunningDistros parses a representative running list end-to-end|occurrence=1wslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers parseRunningDistros returns empty for empty input|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers parseRunningDistros returns empty for empty input|occurrence=1wslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers parseWslListVerbose parses a representative listing end-to-end|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers parseWslListVerbose parses a representative listing end-to-end|occurrence=1wslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers parseWslListVerbose returns empty for empty input|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers parseWslListVerbose returns empty for empty input|occurrence=1wslRemoteAgentHostHelper…wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers parseWslListVerbose tolerates LF-only line endings and missing BOM|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/wslRemoteAgentHostHelpers.test|title=WSL Remote Agent Host Helpers parseWslListVerbose tolerates LF-only line endings and missing BOM|occurrence=1wslRemoteAgentHostHelper…Focused concept · wslRemoteAgentHostHelpers.ts ×8 · 116 introduced LOCwslRemoteAgentHostHelper…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 116 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/wslRemoteAgentHostHelpers.ts 116 introduced LOC · 8 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- wslRemoteAgentHostHelpers.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import * as cp from 'child_process';
7 > import { join } from '../../../base/common/path.js';
8 > import type { IWSLDistro } from '../common/wslRemoteAgentHost.js';
9 > import {
10 > buildAgentHostBaseCommand,
11 > buildCLIDownloadUrl,
12 > buildCleanupOldCLIsCommand,
13 > extractAgentHostWebSocketURL,
14 > getRemoteCLIBin,
15 > getRemoteCLIDataDir,
16 > getRemoteCLIInstallRoot,
17 > shellEscape,
18 > validateShellToken,
19 > } from './sshRemoteAgentHostHelpers.js';
20 >
21 > export { extractAgentHostWebSocketURL };
22 >
23 > /**
24 > * Locate `wsl.exe`. Prefer the absolute path under `%SystemRoot%\System32`
25 > * (defends against PATH hijacks on Windows hosts where `wsl.exe` is itself
26 > * a security boundary). Falls back to bare `wsl.exe` if `%SystemRoot%` is
27 > * unset so non-Windows hosts still produce a sensible value for testing.
28 > */
29 > export function getWslExePath(): string {
30 const systemRoot = process.env['SystemRoot'];
31 if (!systemRoot) {
34 return join(systemRoot, 'System32', 'wsl.exe');
35 }
37 > /**
38 > * Cheap probe for `wsl.exe --status`. Returns false on any non-Windows host,
39 > * on spawn failure (ENOENT), or on non-zero exit. Used by both the platform
40 > * capability check (renderer) and the picker gating logic (UI).
41 > */
42 export async function isWSLSupported(): Promise<boolean> {
43 if (process.platform !== 'win32') {
51 }
52 }
54 > export interface IRunWslCommandOptions {
55 > readonly timeout?: number;
56 > readonly distro?: string;
57 > }
58 >
59 > export interface IRunWslCommandResult {
60 > readonly stdout: string;
61 > readonly stderr: string;
62 > readonly exitCode: number;
63 > }
64 >
65 > /**
66 > * Spawn `wsl.exe` with `WSL_UTF8=1` and capture stdout/stderr. Modern WSL
67 > * builds honor `WSL_UTF8` and emit UTF-8; older builds emit null-padded
68 > * UTF-16LE regardless. We detect the latter by sniffing the first few bytes
69 > * and decode accordingly so a single helper covers both.
70 > *
71 > * Times out after {@link options.timeout} ms (default 30s); on timeout the
72 > * child is hard-killed and the promise rejects.
73 > */
74 > export function runWslCommand(args: readonly string[], options?: IRunWslCommandOptions): Promise<IRunWslCommandResult> {
75 return new Promise((resolve, reject) => {
76 const fullArgs = options?.distro ? ['-d', options.distro, ...args] : [...args];
122 });
123 }
125 > /**
126 > * Decode a `wsl.exe` output buffer that may be UTF-8 (modern builds with
127 > * `WSL_UTF8=1`) or UTF-16LE (older builds that ignore the env var). Strips
128 > * the BOM in either case.
129 > */
130 > export function decodeWslOutput(buffer: Buffer): string {
131 if (buffer.length === 0) {
132 return '';
164 return text;
165 }
167 > /**
168 > * Parse the output of `wsl --list --verbose`. Only WSL 2 distros are
169 > * returned — WSL 1 lacks the kernel features needed to host the agent.
170 > *
171 > * Robust against:
172 > * - BOM, CRLF and lone LF line endings
173 > * - header row with locale-dependent column names
174 > * - the leading `* ` marker on the default distro
175 > * - trailing whitespace and empty lines
176 > */
177 > export function parseWslListVerbose(output: string): IWSLDistro[] {
178 if (!output) {
179 return [];
230 return distros;
231 }
233 > /**
234 > * Parse the output of `wsl --list --running --quiet`. One distro per line.
235 > */
236 > export function parseRunningDistros(output: string): string[] {
237 if (!output) {
238 return [];
244 .filter(line => line.length > 0);
245 }
247 > export interface IComposeAgentHostBootstrapScriptArgs {
248 > readonly serverDataFolderName: string;
249 > readonly quality: string;
250 > readonly commit: string | undefined;
251 > readonly os: string;
252 > readonly arch: string;
253 > /** Dev override; when set, returned verbatim and all CLI bootstrap is skipped. */
254 > readonly remoteAgentHostCommand?: string;
255 > }
256 >
257 > /**
258 > * Compose the bash one-liner passed to `wsl.exe -d <distro> -e bash -lc`.
259 > *
260 > * Reuses the same install layout helpers as Remote-SSH
261 > * ({@link getRemoteCLIBin}, {@link buildCLIDownloadUrl},
262 > * {@link buildCleanupOldCLIsCommand}, {@link buildAgentHostBaseCommand}) so
263 > * a WSL-installed CLI and an SSH-installed CLI share the same
264 > * `~/<serverDataFolderName>/...` files inside the distro.
265 > *
266 > * SSH composes the same operations across multiple sequential `exec` calls
267 > * (so it can branch on lockfile reuse and CLI-install failures); WSL does
268 > * not have a control channel back to the host between commands and so
269 > * collapses the install+launch into one script per spawn. The shared layout
270 > * lives in the helper functions above, not in the composition itself.
271 > */
272 > export function composeAgentHostBootstrapScript(args: IComposeAgentHostBootstrapScriptArgs): string {
273 if (args.remoteAgentHostCommand) {
274 return args.remoteAgentHostCommand;
312 ].join(' && ');
313 }
315 > /**
316 > * Validate that a string is safe to interpolate as a `wsl.exe -d <distro>`
317 > * argument. WSL distro names are user-creatable so they could in principle
318 > * contain spaces or quotes, but every distro shipped through the Store
319 > * matches `[A-Za-z0-9._-]+`. Reject anything else as defense-in-depth.
320 > */
321 > export function validateDistroName(name: string): string {
322 return validateShellToken(name, 'WSL distro name');
323 }