localAgentHostMetadata.ts ×14

Frontier kind: Joint frontier

unlabeled · c_fe7461b45e6c

5 tests · 4194 LOC · 23 files · introduces 1 test · 103 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
16 ranges103 lines · 2 files
Tests
1 test

Contains — complete concept membership

All code (extent)
572 ranges4194 lines · 23 files · Browse complete extent
All tests (intent)
5 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 specializationlocalAgentHostMetadata.ts ×4 · 19 introduced LOClocalAgentHostMetadata.t…localAgentHostMetadata.ts ×6 · 34 introduced LOClocalAgentHostMetadata.t…localAgentHostMetadata.test|title=Local Agent Host Endpoint Metadata writes owner-only socket directory permissions|occurrence=1, localAgentHostMetadata.test|title=Local Agent Host Endpoint Metadata uses a bounded path under the system temporary directory|occurrence=1 · 0 introduced LOClocalAgentHostMetadata.t…validation.ts ×4 · 8 introduced LOCvalidation.ts ×4validation.ts ×43 · 180 introduced LOCvalidation.ts ×43registry.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 ×3path.ts ×3 · 5 introduced LOCpath.ts ×3path.ts ×3 · 15 introduced LOCpath.ts ×3path.ts ×1 · 2 introduced LOCpath.ts ×1path.ts ×3 · 10 introduced LOCpath.ts ×3path.ts ×3 · 14 introduced LOCpath.ts ×3lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2path.ts ×1 · 1 introduced LOCpath.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1path.ts ×6 · 24 introduced LOCpath.ts ×6lifecycle.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 ×1path.ts ×2 · 3 introduced LOCpath.ts ×2lifecycle.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/common/validation.ts · 396 LOCcommon/validation.tssrc/vs/base/test/common/utils.ts · 107 LOCcommon/utils.tssrc/vs/nls.ts · 244 LOCvs/nls.tssrc/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/localAgentHostMetadata.ts · 199 LOCnode/localAgentHostMetad…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…localAgentHostMetadata.test|title=Local Agent Host Endpoint Metadata atomically replaces and owner-checks metadata|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/localAgentHostMetadata.test|title=Local Agent Host Endpoint Metadata atomically replaces and owner-checks metadata|occurrence=1localAgentHostMetadata.t…localAgentHostMetadata.test|title=Local Agent Host Endpoint Metadata creates scoped endpoint metadata|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/localAgentHostMetadata.test|title=Local Agent Host Endpoint Metadata creates scoped endpoint metadata|occurrence=1localAgentHostMetadata.t…localAgentHostMetadata.test|title=Local Agent Host Endpoint Metadata uses a bounded path under the system temporary directory|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/localAgentHostMetadata.test|title=Local Agent Host Endpoint Metadata uses a bounded path under the system temporary directory|occurrence=1localAgentHostMetadata.t…localAgentHostMetadata.test|title=Local Agent Host Endpoint Metadata writes owner-only metadata permissions|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/localAgentHostMetadata.test|title=Local Agent Host Endpoint Metadata writes owner-only metadata permissions|occurrence=1localAgentHostMetadata.t…localAgentHostMetadata.test|title=Local Agent Host Endpoint Metadata writes owner-only socket directory permissions|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/localAgentHostMetadata.test|title=Local Agent Host Endpoint Metadata writes owner-only socket directory permissions|occurrence=1localAgentHostMetadata.t…Focused concept · localAgentHostMetadata.ts ×14 · 103 introduced LOClocalAgentHostMetadata.t…

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.

1 test introduced at this concept.

Introduced code

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

2 files ranked by introduced lines: 103 introduced LOC across 16 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/localAgentHostMetadata.ts 99 introduced LOC · 14 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- localAgentHostMetadata.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 { execFile } from 'child_process';
7 > import { createHash, randomBytes } from 'crypto';
8 > import * as fs from 'fs';
9 > import * as os from 'os';
10 > import { join } from '../../../base/common/path.js';
11 > import { vArray, vLiteral, vNumber, vObj, vString } from '../../../base/common/validation.js';
12 > import { PROTOCOL_VERSION } from '../common/state/protocol/version/registry.js';
13 >
14 > const metadataSchemaVersion = 1;
15 > const metadataDirectoryName = 'agent-host';
16 > const endpointDirectoryName = 'local-endpoint';
17 > const metadataFileName = 'metadata.json';
18 >
19 > export interface ILocalAgentHostEndpointMetadata {
20 > readonly type: 'editor';
21 > readonly schemaVersion: typeof metadataSchemaVersion;
22 > readonly pid: number;
23 > readonly instanceId: string;
24 > readonly endpointPath: string;
25 > readonly connectionToken: string;
26 > readonly protocolVersion: string;
27 > }
28 >
29 > const metadataValidator = vArray(vObj({
30 > type: vLiteral('editor'),
31 > schemaVersion: vNumber(),
32 > pid: vNumber(),
33 > instanceId: vString(),
34 > endpointPath: vString(),
35 > connectionToken: vString(),
36 > protocolVersion: vString(),
37 > }));
38 >
39 > export function createLocalAgentHostEndpointMetadata(userDataPath: string): ILocalAgentHostEndpointMetadata {
40 > const instanceId = randomBytes(16).toString('base64url');
41 > return {
42 > type: 'editor',
43 > schemaVersion: metadataSchemaVersion,
44 > pid: process.pid,
45 > instanceId,
46 > endpointPath: getEndpointPath(userDataPath, instanceId),
47 > connectionToken: randomBytes(32).toString('base64url'),
48 > protocolVersion: PROTOCOL_VERSION,
49 > };
50 > }
51 >
52 > export async function prepareLocalAgentHostEndpointMetadataDirectory(userDataPath: string): Promise<void> {
53 > const directory = getMetadataDirectory(userDataPath);
54 > await fs.promises.mkdir(directory, { recursive: true, mode: 0o700 });
55 > const stat = await fs.promises.lstat(directory);
56 > if (!stat.isDirectory() || stat.isSymbolicLink()) {
57 throw new Error(`Local agent host endpoint metadata directory is not a directory: ${directory}`);
58 }
60 > if (process.platform === 'win32') {
61 await applyWindowsOwnerOnlyAcl(directory);
63 > if (process.getuid && stat.uid !== process.getuid()) {
64 throw new Error(`Local agent host endpoint metadata directory is not owned by the current user: ${directory}`);
65 }
66 > await fs.promises.chmod(directory, 0o700); localAgentHostMetadata.ts
67 > }
68 > }
69 >
70 > export async function prepareLocalAgentHostEndpointSocketDirectory(userDataPath: string): Promise<void> {
71 > if (process.platform !== 'win32') {
72 > const directory = getSocketDirectory(userDataPath);
73 > await fs.promises.mkdir(directory, { recursive: true, mode: 0o700 });
74 > const stat = await fs.promises.lstat(directory);
75 > if (!stat.isDirectory() || stat.isSymbolicLink()) {
76 throw new Error(`Local agent host endpoint socket directory is not a directory: ${directory}`);
77 }
78 > if (process.getuid && stat.uid !== process.getuid()) { localAgentHostMetadata.ts
79 throw new Error(`Local agent host endpoint socket directory is not owned by the current user: ${directory}`);
80 }
81 > await fs.promises.chmod(directory, 0o700); localAgentHostMetadata.ts
82 > }
83 > }
84 >
85 export async function publishLocalAgentHostEndpointMetadata(userDataPath: string, metadata: ILocalAgentHostEndpointMetadata): Promise<void> {
86 const metadataPath = getMetadataPath(userDataPath);
102 }
103 }
105 > export function cleanupLocalAgentHostEndpointMetadataSync(userDataPath: string, owner: ILocalAgentHostEndpointMetadata): void {
106 const metadataPath = getMetadataPath(userDataPath);
107 const entries = readMetadata(metadataPath);
116 }
117 }
119 > export function cleanupLocalAgentHostEndpointSocketSync(endpointPath: string): void {
120 if (process.platform !== 'win32') {
121 fs.rmSync(endpointPath, { force: true });
122 }
123 }
125 > function getMetadataDirectory(userDataPath: string): string {
126 > return join(userDataPath, metadataDirectoryName, endpointDirectoryName);
127 > }
128 >
129 function getMetadataPath(userDataPath: string): string {
130 return join(getMetadataDirectory(userDataPath), metadataFileName);
131 }
133 > function getSocketDirectory(userDataPath: string): string {
134 > const owner = process.getuid?.().toString() ?? '';
135 > const hash = createHash('sha256').update(`${owner}:${userDataPath}`).digest('hex').slice(0, 12);
136 > return join(os.tmpdir(), `vscode-ah-${hash}`);
137 > }
138 >
139 > function getEndpointPath(userDataPath: string, instanceId: string): string {
140 > if (process.platform === 'win32') {
141 const userDataHash = createHash('sha256').update(userDataPath).digest('hex');
142 return `\\\\.\\pipe\\vscode-agent-host-${userDataHash}-${instanceId}`;
143 }
144 > return join(getSocketDirectory(userDataPath), `${instanceId}.sock`); localAgentHostMetadata.ts
145 > }
146 >
147 function readMetadata(path: string): ILocalAgentHostEndpointMetadata[] {
148 try {
165 }
166 }
168 async function applyWindowsOwnerOnlyAcl(path: string): Promise<void> {
169 const systemRoot = process.env.SystemRoot ?? process.env.WINDIR;
188 ]);
189 }
191 function runWindowsCommand(command: string, args: readonly string[]): Promise<string> {
192 return new Promise((resolve, reject) => {
194 });
195 }
197 function isNotFound(error: unknown): boolean {
198 return (error as NodeJS.ErrnoException | undefined)?.code === 'ENOENT';
src/vs/base/common/validation.ts 4 introduced LOC · 2 ranges

Open complete file

335 class LiteralValidator<T extends string> extends ValidatorBase<T> {
336 constructor(private readonly value: T) {
337 > super(); validation.ts
338 > }
339
340 validate(content: unknown): { content: T; error: undefined } | { content: undefined; error: ValidationError } {
354
355 export function vLiteral<T extends string>(value: T): ValidatorBase<T> {
356 > return new LiteralValidator(value); validation.ts
357 > }
358
359 class LazyValidator<T> extends ValidatorBase<T> {