sandboxConfigForSdk.ts ×1

Frontier kind: Code frontier

unlabeled · c_91bde1e5075f

437 tests · 6910 LOC · 37 files · introduces 0 tests · 85 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
1 range85 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
561 ranges6910 lines · 37 files · Browse complete extent
All tests (intent)
437 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: 85 introduced LOC across 1 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/copilot/sandboxConfigForSdk.ts 85 introduced LOC · 1 range

Open complete file

1 > /*--------------------------------------------------------------------------------------------- sandboxConfigForSdk.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 { AgentSandboxEnabledValue } from '../../../sandbox/common/settings.js';
7 > import { AgentHostSandboxKey, type ISandboxConfigValue } from '../../common/sandboxConfigSchema.js';
8 >
9 > /**
10 > * Whether the SDK sandbox is supported on Windows. Not enabled yet, so the
11 > * builders bail out early on `win32`; the Windows handling is kept so support
12 > * can be turned on by flipping this flag once the runtime is ready. Typed as
13 > * `boolean` (not the `false` literal) so the Windows branches are not flagged
14 > * as unreachable by control-flow narrowing.
15 > */
16 > const WINDOWS_SANDBOX_SUPPORTED: boolean = false;
17 >
18 > /**
19 > * Per-platform filesystem rule bundle accepted under each `fileSystem.<os>`
20 > * sub-key (`AgentHostSandboxKey.LinuxFileSystem` etc.) in the AgentHost root
21 > * sandbox config bag. Mirrors the workbench's `chat.agent.sandbox.fileSystem.*`
22 > * shape so the workbench-side forwarder can copy values verbatim.
23 > */
24 > export interface IAgentSandboxFileSystemSetting {
25 > allowRead?: string[];
26 > allowWrite?: string[];
27 > denyRead?: string[];
28 > denyWrite?: string[];
29 > }
30 >
31 > /**
32 > * SDK-side sandbox configuration produced by {@link buildSandboxConfigForSdk}.
33 > *
34 > * Structurally a narrowed form of the SDK's `SandboxConfig` type (from
35 > * `@github/copilot-sdk`'s `SessionUpdateOptionsParams.sandboxConfig`) — the
36 > * same shape the Copilot extension produces via its own `buildSandboxConfigForCLI`.
37 > * Defined locally because `SandboxConfig` is not re-exported from the SDK's
38 > * public entry point; this shape stays assignable to it.
39 > */
40 > export interface ISdkSandboxConfig {
41 > enabled: true;
42 > allowBypass?: boolean;
43 > userPolicy: {
44 > filesystem: {
45 > readwritePaths?: string[];
46 > readonlyPaths?: string[];
47 > deniedPaths?: string[];
48 > };
49 > network: {
50 > allowOutbound: boolean;
51 > allowedHosts?: string[];
52 > blockedHosts?: string[];
53 > };
54 > };
55 > }
56 >
57 > /**
58 > * Translate the AgentHost's host-side sandbox configuration into the
59 > * opaque `sandboxConfig` shape the Copilot SDK forwards to the runtime
60 > * via `session.options.update`.
61 > *
62 > * Used when {@link CopilotCliConfigKey.EnableCustomTerminalTool} is OFF — the
63 > * SDK's built-in shell tool runs the user's commands, so we have to push the
64 > * sandbox policy down into the SDK itself. When the custom terminal tool is
65 > * ON, the AgentHost's own {@link TerminalSandboxEngine} wraps commands and
66 > * this function is not consulted.
67 > *
68 > * Mirrors `buildSandboxConfigForCLI` in
69 > * `extensions/copilot/src/extension/chatSessions/copilotcli/node/copilotcliSessionService.ts`
70 > * so the two surfaces behave the same:
71 > * - Path precedence: `denyRead` > `denyWrite` > `allowWrite` > `allowRead`.
72 > * Each path appears in exactly one of `deniedPaths` / `readonlyPaths` /
73 > * `readwritePaths`.
74 > * - Network: `allowNetwork` opens outbound to everything and drops the
75 > * allow/deny lists. Otherwise the allow/deny lists open outbound when
76 > * set so they're actually enforced; host lists are currently disabled on
77 > * all platforms (fail closed) because the runtime does not yet enforce
78 > * them reliably everywhere.
79 > *
80 > * Windows is not supported yet, so this bails out early and returns `undefined`
81 > * there. The Windows handling below is intentionally kept (and exercised when
82 > * {@link WINDOWS_SANDBOX_SUPPORTED} is flipped) so support can be turned on once
83 > * the runtime is ready.
84 > */
85 > export function buildSandboxConfigForSdk(
86 platform: NodeJS.Platform,
87 sandbox: ISandboxConfigValue | undefined,