sandboxSettingsReader.ts ×5

Frontier kind: Code frontier

unlabeled · c_8d14c65935eb

9 tests · 12421 LOC · 62 files · introduces 0 tests · 77 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
5 ranges77 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1484 ranges12421 lines · 62 files · Browse complete extent
All tests (intent)
9 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.

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: 77 introduced LOC across 5 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/sandboxSettingsReader.ts 77 introduced LOC · 5 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- sandboxSettingsReader.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 { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js';
7 > import { ILogService } from '../../../../../platform/log/common/log.js';
8 > import { AgentNetworkDomainSettingId } from '../../../../../platform/networkFilter/common/settings.js';
9 > import { AgentSandboxSettingId } from '../../../../../platform/sandbox/common/settings.js';
10 > import { sandboxSettingIdToAgentHostKey } from '../../../../../platform/agentHost/common/sandboxConfigSchema.js';
11 >
12 > /** Setting IDs that affect the engine's sandbox configuration (modern + deprecated). */
13 > export const SANDBOX_SETTING_KEYS: readonly string[] = [
14 > AgentSandboxSettingId.AgentSandboxEnabled,
15 > AgentSandboxSettingId.AgentSandboxWindowsEnabled,
16 > AgentSandboxSettingId.AgentSandboxAllowNetwork,
17 > AgentSandboxSettingId.AgentSandboxAllowUnsandboxedCommands,
18 > AgentSandboxSettingId.AgentSandboxLinuxFileSystem,
19 > AgentSandboxSettingId.AgentSandboxMacFileSystem,
20 > AgentSandboxSettingId.AgentSandboxWindowsFileSystem,
21 > AgentSandboxSettingId.AgentSandboxWindowsSchemaVersion,
22 > AgentSandboxSettingId.AgentSandboxAdvancedRuntime,
23 > AgentSandboxSettingId.DeprecatedAgentSandboxEnabled,
24 > AgentSandboxSettingId.DeprecatedAgentSandboxLinuxFileSystem,
25 > AgentSandboxSettingId.DeprecatedAgentSandboxMacFileSystem,
26 > AgentNetworkDomainSettingId.AllowedNetworkDomains,
27 > AgentNetworkDomainSettingId.DeniedNetworkDomains,
28 > AgentNetworkDomainSettingId.DeprecatedSandboxAllowedNetworkDomains,
29 > AgentNetworkDomainSettingId.DeprecatedSandboxDeniedNetworkDomains,
30 > AgentNetworkDomainSettingId.DeprecatedOldAllowedNetworkDomains,
31 > AgentNetworkDomainSettingId.DeprecatedOldDeniedNetworkDomains,
32 > ];
33 >
34 > /**
35 > * Maps each modern sandbox setting ID to the ordered list of deprecated
36 > * setting IDs the workbench should fall back to when the modern key has not
37 > * been configured by the user. Consumers (engine adapter, agent-host
38 > * forwarder) only ever resolve values by modern key.
39 > */
40 > const DEPRECATED_SANDBOX_FALLBACKS: Readonly<Record<string, readonly string[]>> = {
41 > [AgentSandboxSettingId.AgentSandboxEnabled]: [AgentSandboxSettingId.DeprecatedAgentSandboxEnabled],
42 > [AgentSandboxSettingId.AgentSandboxLinuxFileSystem]: [AgentSandboxSettingId.DeprecatedAgentSandboxLinuxFileSystem],
43 > [AgentSandboxSettingId.AgentSandboxMacFileSystem]: [AgentSandboxSettingId.DeprecatedAgentSandboxMacFileSystem],
44 > [AgentNetworkDomainSettingId.AllowedNetworkDomains]: [AgentNetworkDomainSettingId.DeprecatedSandboxAllowedNetworkDomains, AgentNetworkDomainSettingId.DeprecatedOldAllowedNetworkDomains],
45 > [AgentNetworkDomainSettingId.DeniedNetworkDomains]: [AgentNetworkDomainSettingId.DeprecatedSandboxDeniedNetworkDomains, AgentNetworkDomainSettingId.DeprecatedOldDeniedNetworkDomains],
46 > };
47 >
48 > /**
49 > * Reads a single sandbox-related setting from `IConfigurationService`,
50 > * preferring the modern key and falling back to its deprecated peers in
51 > * order. Legacy boolean sandbox enabled values are normalized to the agent-host
52 > * `'on' | 'off'` enum. Returns `undefined` when no user value is configured.
53 > */
54 > export function readSandboxSetting<T>(configurationService: IConfigurationService, logService: ILogService, settingId: string): T | undefined {
55 > const modern = configurationService.inspect<T>(settingId);
56 > if (modern.userValue !== undefined) {
57 return normalizeSandboxSettingValue<T>(settingId, modern.value);
58 }
59 const deprecatedFallbacks = DEPRECATED_SANDBOX_FALLBACKS[settingId];
60 > if (deprecatedFallbacks?.length) { sandboxSettingsReader.ts
61 // Some deprecated keys are namespace parents of newer settings (e.g.
62 // `chat.agent.sandbox` vs `chat.agent.sandbox.fileSystem.linux`).
76 return normalizeSandboxSettingValue<T>(settingId, modern.value);
77 }
79 > /**
80 > * Reads the currently-configured sandbox values for forwarding to an agent
81 > * host. The returned record is keyed by the prefix-free agent-host sandbox
82 > * sub-keys ({@link AgentHostSandboxKey}); keys without a user value are
83 > * omitted entirely. Callers should nest this under the agent host's
84 > * top-level `sandbox` config key when dispatching a `RootConfigChanged`.
85 > */
86 > export function readAgentHostSandboxValues(configurationService: IConfigurationService, logService: ILogService): Record<string, unknown> {
87 const values: Record<string, unknown> = {};
88 for (const [settingId, sandboxKey] of Object.entries(sandboxSettingIdToAgentHostKey)) {
94 return values;
95 }
97 > /**
98 > * Coerce values into the canonical shape the agent-host schema expects.
99 > * Today the non-trivial cases are the boolean sandbox enabled settings,
100 > * which are forwarded as the `'on' | 'off' | 'allowNetwork'` enum for
101 > * agent-host compatibility.
102 > */
103 > function normalizeSandboxSettingValue<T>(settingId: string, value: T | undefined): T | undefined {
104 > if (settingId === AgentSandboxSettingId.AgentSandboxEnabled || settingId === AgentSandboxSettingId.AgentSandboxWindowsEnabled || settingId === AgentSandboxSettingId.DeprecatedAgentSandboxEnabled) {
105 > if (value === true) {
106 return 'on' as unknown as T;
107 }