import { Event } from "../../../base/common/event.js"; import { IPolicyData } from "../../../base/common/defaultAccount.js"; import { IManagedSettingsPolicyDefinitions, ManagedSettingValue, ManagedSettingsData } from "../../../base/common/policy.js"; import { IStringDictionary } from "../../../base/common/collections.js"; import { IConfigurationService } from "../../configuration/common/configuration.service.js"; import { PolicyDefinition } from "./policy.js"; import { IManagedSettingsService, type IFileManagedSettingsService, type INativeManagedSettingsService } from "./copilotManagedSettings.service.js"; export type { ManagedSettingsData } from "../../../base/common/policy.js"; export type RawManagedSettingsData = Readonly>; /** The temporary harness control does not contribute general presence-based governance. */ export declare function isManagedSettingGovernanceActive(key: string): boolean; /** Detect raw governance without counting the Local-only harness control or its containing object. */ export declare function hasRawManagedSettings(data: RawManagedSettingsData | undefined): boolean; /** Windows registry root for GitHub Copilot policies. */ export declare const GITHUB_COPILOT_WIN32_REGISTRY_PATH = "SOFTWARE\\Policies\\GitHubCopilot"; /** Windows product name passed to the native policy watcher. */ export declare const GITHUB_COPILOT_WIN32_POLICY_NAME = "GitHubCopilot"; /** macOS CFPreferences application ID for GitHub Copilot managed preferences. */ export declare const GITHUB_COPILOT_MACOS_BUNDLE_ID = "com.github.copilot"; /** MDM key for the V0 managed setting. */ export declare const COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY = "permissions.disableBypassPermissionsMode"; /** Managed setting that disables the Assisted permission mode. */ export declare const COPILOT_DISABLE_ASSISTED_PERMISSIONS_MODE_KEY = "permissions.disableAssistedPermissionsMode"; /** Managed setting for the starting permission mode of new sessions (`manual`, `assisted`, or `allow-all`). */ export declare const COPILOT_DEFAULT_PERMISSIONS_MODE_KEY = "permissions.defaultMode"; /** Runtime-owned rule lists that the Local harness cannot enforce. */ export declare const COPILOT_PERMISSION_RULES_KEYS: readonly [ "permissions.ask", "permissions.allow", "permissions.deny" ]; /** Managed-settings key for enterprise plugin enablement (carried as a JSON-encoded `{ [pluginId]: boolean }`). */ export declare const COPILOT_ENABLED_PLUGINS_KEY = "enabledPlugins"; /** Managed-settings key for enterprise marketplaces (carried as a JSON-encoded `{ [name]: url-or-shorthand }`). */ export declare const COPILOT_EXTRA_MARKETPLACES_KEY = "extraKnownMarketplaces"; /** Managed-settings key for the strict-marketplace allowlist (carried as a JSON-encoded array of source entries; absent = no restrictions, `[]` = lockdown). */ export declare const COPILOT_STRICT_MARKETPLACES_KEY = "strictKnownMarketplaces"; /** Managed-settings key for the per-server MCP allowlist (carried as a JSON-encoded array of matcher entries; absent = no allow restriction, `[]` = only servers matching an entry, i.e. block all). */ export declare const COPILOT_ALLOWED_MCP_SERVERS_KEY = "allowedMcpServers"; /** Managed-settings key for the per-server MCP denylist (carried as a JSON-encoded array of matcher entries; deny always takes precedence over allow). */ export declare const COPILOT_DENIED_MCP_SERVERS_KEY = "deniedMcpServers"; /** Managed-settings key that blocks standalone user/workspace customizations. */ export declare const COPILOT_STRICT_PLUGIN_ONLY_CUSTOMIZATION_KEY = "strictPluginOnlyCustomization"; /** Managed-settings key that makes the enterprise MCP allowlist authoritative. */ export declare const COPILOT_ALLOW_MANAGED_MCP_SERVERS_ONLY_KEY = "allowManagedMcpServersOnly"; /** Managed-settings key that allows hooks only from managed sources. */ export declare const COPILOT_ALLOW_MANAGED_HOOKS_ONLY_KEY = "allowManagedHooksOnly"; /** Managed-settings transport control that requires a fresh server fetch on startup. */ export declare const COPILOT_FORCE_REMOTE_SETTINGS_REFRESH_KEY = "forceRemoteSettingsRefresh"; /** Enterprise escape hatch for automatic Copilot harness routing in VS Code. */ export declare const COPILOT_TEMPORARY_DEFAULT_TO_LOCAL_HARNESS_KEY = "vscode.temporaryDefaultToLocalHarness"; /** Temporary managed permission for Local, Claude, and Codex harnesses; only false prohibits them. */ export declare const COPILOT_TEMPORARY_ALLOW_LOCAL_HARNESS_KEY = "vscode.temporaryAllowLocalHarness"; /** Policy-only configuration projection of the Local harness escape hatch. */ export declare const TemporaryDefaultToLocalHarnessSettingId = "chat.temporaryDefaultToLocalHarness"; /** * Enterprise-mandated sandbox floor (`sandbox.enabled` in the runtime's managed-settings schema). * The runtime owns composing and enforcing this floor — it is `force-on-wins`, so a managed `true` * cannot be loosened by the user. VS Code only *reads* it to decide which chat harness to offer, * and deliberately declares no configuration policy for it: the control is runtime-owned, and * mirroring it as a VS Code policy would invert ownership. */ export declare const COPILOT_SANDBOX_ENABLED_KEY = "sandbox.enabled"; /** Managed-settings key that requires MCP servers to remain sandboxed. */ export declare const COPILOT_SANDBOX_MCP_SERVERS_KEY = "sandbox.sandboxMcpServers"; /** Managed-settings key that requires LSP servers to remain sandboxed. */ export declare const COPILOT_SANDBOX_LSP_SERVERS_KEY = "sandbox.sandboxLspServers"; /** Managed-settings key that restricts HTTPS Git authentication inside the sandbox. */ export declare const COPILOT_SANDBOX_AUTH_GIT_KEY = "sandbox.auth.git"; /** Managed-settings key that restricts GitHub CLI authentication inside the sandbox. */ export declare const COPILOT_SANDBOX_AUTH_GH_KEY = "sandbox.auth.gh"; /** Managed-settings key that permits explicitly bypassing the sandbox. */ export declare const COPILOT_SANDBOX_ALLOW_BYPASS_KEY = "sandbox.allowBypass"; /** Managed-settings key that restricts outbound sandbox network access. */ export declare const COPILOT_SANDBOX_ALLOW_OUTBOUND_KEY = "sandbox.userPolicy.network.allowOutbound"; /** Managed-settings key that restricts local-network access from the sandbox. */ export declare const COPILOT_SANDBOX_ALLOW_LOCAL_NETWORK_KEY = "sandbox.userPolicy.network.allowLocalNetwork"; /** Managed-settings key that supplies the sandbox's network allowlist. */ export declare const COPILOT_SANDBOX_ALLOWED_HOSTS_KEY = "sandbox.userPolicy.network.allowedHosts"; /** Managed-settings key that supplies writable sandbox paths. */ export declare const COPILOT_SANDBOX_READWRITE_PATHS_KEY = "sandbox.userPolicy.filesystem.readwritePaths"; /** Managed-settings key that supplies read-only sandbox paths. */ export declare const COPILOT_SANDBOX_READONLY_PATHS_KEY = "sandbox.userPolicy.filesystem.readonlyPaths"; /** Managed-settings key that supplies denied sandbox paths. */ export declare const COPILOT_SANDBOX_DENIED_PATHS_KEY = "sandbox.userPolicy.filesystem.deniedPaths"; /** Managed-settings key that restricts developer tool access from the sandbox. */ export declare const COPILOT_SANDBOX_ALLOW_DEV_TOOL_ACCESS_KEY = "sandbox.allowDevToolAccess"; /** Auto startup default, read as one atomic value across managed delivery channels. */ export declare const COPILOT_AUTO_TIER_KEY = "autoTier"; /** * Agent Host Copilot runtime's Fusion tier (`standard`, `high`, `max`, `unmanaged`). Its presence in any channel * supersedes {@link COPILOT_AUTO_TIER_KEY} for that runtime, which owns the tier's routing. */ export declare const COPILOT_FUSION_TIER_KEY = "fusionTier"; /** * Managed-settings controls consumed by the delivery pipeline itself rather than by a * configuration policy. Native MDM must watch these even though no setting declares them. */ export declare const MANAGED_SETTINGS_CONTROL_DEFINITIONS: IManagedSettingsPolicyDefinitions; /** Policy-only configuration delivery slot for {@link COPILOT_STRICT_PLUGIN_ONLY_CUSTOMIZATION_KEY}. */ export declare const COPILOT_STRICT_PLUGIN_ONLY_CUSTOMIZATION_CONFIG = "chat.customizations.strictPluginOnlyCustomization"; /** Policy-only configuration delivery slot for {@link COPILOT_ALLOW_MANAGED_MCP_SERVERS_ONLY_KEY}. */ export declare const COPILOT_ALLOW_MANAGED_MCP_SERVERS_ONLY_CONFIG = "chat.mcp.allowManagedServersOnly"; /** Policy-only configuration delivery slot for {@link COPILOT_ALLOW_MANAGED_HOOKS_ONLY_KEY}. */ export declare const COPILOT_ALLOW_MANAGED_HOOKS_ONLY_CONFIG = "chat.hooks.allowManagedOnly"; /** * Legacy managed-settings key for the default chat model, nested under `permissions` so it flattens * to `permissions.model`. Retained for original-schema deployments; superseded by the top-level * {@link COPILOT_TOP_LEVEL_MODEL_KEY}, which wins when both are present (see {@link managedModelValue}). */ export declare const COPILOT_MODEL_KEY = "permissions.model"; /** * Canonical top-level managed-settings key for the default chat model (flattens to the bag key * `model`). Supersedes the legacy nested {@link COPILOT_MODEL_KEY} when both are present. */ export declare const COPILOT_TOP_LEVEL_MODEL_KEY = "model"; /** * Enterprise OTel managed-settings keys. These are the scalar leaves of the canonical * `telemetry` block from the cross-client managed-settings schema (see the CLI * `ManagedTelemetrySettings`); they flatten to dot-path bag keys via * {@link normalizeManagedSettings}, so no {@link STRUCTURED_MANAGED_SETTINGS} entry is needed. * The `telemetry.resourceAttributes` and `telemetry.headers` map fields are structured * ({@link STRUCTURED_MANAGED_SETTINGS} rows carry them as JSON-encoded objects under their nested * keys); `telemetry.serviceName` is a scalar. */ /** Managed-settings key for enterprise OTel enablement. */ export declare const COPILOT_OTEL_ENABLED_KEY = "telemetry.enabled"; /** Managed-settings key for the enterprise OTLP collector endpoint. */ export declare const COPILOT_OTEL_ENDPOINT_KEY = "telemetry.endpoint"; /** Managed-settings key for the enterprise OTel file export destination. */ export declare const COPILOT_OTEL_FILE_PATH_KEY = "telemetry.filePath"; /** Managed-settings key for the enterprise OTLP protocol (`http/json`, `http/protobuf`, or `grpc`). */ export declare const COPILOT_OTEL_PROTOCOL_KEY = "telemetry.protocol"; /** Managed-settings key for enterprise OTel content capture. */ export declare const COPILOT_OTEL_CAPTURE_CONTENT_KEY = "telemetry.captureContent"; /** Managed-settings key for independently governed OTel identity capture. */ export declare const COPILOT_OTEL_CAPTURE_IDENTITY_KEY = "telemetry.capture.identity"; /** Managed-settings key that prevents users from enabling OTel content capture themselves. */ export declare const COPILOT_OTEL_LOCK_CAPTURE_CONTENT_KEY = "telemetry.lockCaptureContent"; /** Managed-settings key for the OTel `service.name` resource attribute. */ export declare const COPILOT_OTEL_SERVICE_NAME_KEY = "telemetry.serviceName"; /** Managed-settings key for additional OTel resource attributes (a `{ [k]: string }` map). */ export declare const COPILOT_OTEL_RESOURCE_ATTRIBUTES_KEY = "telemetry.resourceAttributes"; /** Managed-settings key for extra OTLP exporter headers (a `{ [k]: string }` map). */ export declare const COPILOT_OTEL_HEADERS_KEY = "telemetry.headers"; /** * Standard pass-through `value` callback for a managed-settings-driven policy: locks the setting * to the managed value when the enterprise has set it, and returns `undefined` otherwise so the * user's own setting falls through. Use for the common case; policies that combine the managed * value with other conditions (e.g. `chat_preview_features_enabled`) keep a custom callback. * * The callback is memoized per key, so repeated calls for the same key return the SAME function * reference. That reference identity is what lets `isSamePolicyDefinition` skip needless * re-registration, and memoizing makes the guarantee hold regardless of where the helper is called. */ export declare function managedSettingValue(key: string): (policyData: IPolicyData) => ManagedSettingValue | undefined; export type IForceRemoteSettingsRefreshResolution = { readonly effective: true; readonly source: ManagedSettingsChannel; } | { readonly effective: false; }; /** * Resolve the fail-closed startup refresh control across every delivery channel, reusing * {@link pickManagedSettings} precedence rather than re-implementing it. A non-boolean value is * treated as absent, so a malformed high-precedence value cannot mask a well-formed lower one. */ export declare function resolveForceRemoteSettingsRefresh(nativeMdm: ManagedSettingsData | undefined, server: ManagedSettingsData | undefined, file: ManagedSettingsData | undefined): IForceRemoteSettingsRefreshResolution; export declare class NullManagedSettingsService implements IManagedSettingsService { readonly _serviceBrand: undefined; readonly onDidChangeManagedSettings: Event; getManagedSettings(): ManagedSettingsData; getManagedSettingValue(_key: string): ManagedSettingValue | undefined; } /** Non-empty or malformed managed deny lists require runtime enforcement; rule interpretation remains runtime-owned. */ export declare function hasManagedPermissionDenials(service: IManagedSettingsService): boolean; /** Whether an administrator has enabled the temporary Local harness escape hatch. */ export declare function isTemporaryDefaultToLocalHarnessEnabled(configurationService: IConfigurationService): boolean; /** Whether effective policy requires Agent Host; explicit Local disablement overrides the temporary Local escape hatch. */ export declare function requiresCopilotAgentHost(service: IManagedSettingsService, configurationService: IConfigurationService): boolean; /** * Normalizes a managed default-model value: trims it, treats a blank or whitespace-only value as unset, and * maps the Copilot Fusion alias to `auto`. */ export declare function normalizeManagedModelId(value: string | undefined): string | undefined; /** * `value` callback for the default-chat-model managed setting: resolves the top-level * {@link COPILOT_TOP_LEVEL_MODEL_KEY} first, falling back to the legacy nested {@link COPILOT_MODEL_KEY} * (each trimmed, blank treated as unset), so the top-level value wins when both are present. Memoized * so repeated calls return the same reference, matching the identity contract {@link managedSettingValue} * relies on for `isSamePolicyDefinition`. */ export declare function managedModelValue(): (policyData: IPolicyData) => ManagedSettingValue | undefined; /** * `value` callback for the `chat.defaultConfiguration` policy: projects the managed * {@link COPILOT_DEFAULT_PERMISSIONS_MODE_KEY} onto the setting's `approvals` property, as the * JSON-encoded object the setting expects. Like the Copilot runtime, an unrecognized mode starts * in Manual, as does a mode the explicit permission restrictions disable. */ export declare function managedDefaultConfigurationValue(policyData: IPolicyData): string | undefined; /** Forces a boolean setting off while the user is governed by managed settings. */ export declare function managedSettingsDisabledValue(policyData: IPolicyData): boolean | undefined; /** * `value` callback shared by the third-party agent harness policies (`Claude3PIntegration`, * `Codex3PIntegration`): forces the harness off when the account disables chat preview features, * when the user is governed by managed settings, or when Local harnesses are explicitly prohibited. * * Managed settings are composed and enforced by the Copilot runtime and never reach the Claude or * Codex harnesses, so leaving them available would hand a governed user an ungoverned path around * every managed control the enterprise set. */ export declare function thirdPartyAgentEnabledValue(policyData: IPolicyData): boolean | undefined; export declare class NullNativeManagedSettingsService implements INativeManagedSettingsService { readonly _serviceBrand: undefined; readonly managedSettings: ManagedSettingsData; readonly onDidChangeManagedSettings: Event; initialize(): Promise; updatePolicyDefinitions(): Promise; } /** * Aggregate the `managedSettings` declarations of every policy definition into a single * key -> definition map. This is the single source of truth for policy-backed Copilot * managed-settings keys and drives both server projection and the declaration-driven portion of * the native MDM watcher. Transport controls are declared separately. */ export declare function collectManagedSettingsDefinitions(policyDefinitions: IStringDictionary): IManagedSettingsPolicyDefinitions; /** * Whether any policy in `policyDefinitions` declares at least one managed-settings key. Cheap * existence check (short-circuits) used to decide whether the declaration-driven portion of the * native MDM watcher needs updating, without aggregating the full * {@link collectManagedSettingsDefinitions} map. */ export declare function hasManagedSettingsDefinitions(policyDefinitions: IStringDictionary): boolean; /** * Project a raw managed-settings bag onto the declared schema: keep only keys declared by a * policy definition whose runtime value matches the declared type. Undeclared keys and * type-mismatched values are dropped (with an optional warning). Values are validated, never * coerced, so a key declared as `string` keeps its string value untouched. * * This keeps the server endpoint and native MDM delivery aligned on the same * declaration-driven key set and value types. */ export declare function projectManagedSettings(values: ManagedSettingsData, definitions: IManagedSettingsPolicyDefinitions, onWarn?: (msg: string) => void): ManagedSettingsData; /** * A delivery channel that can provide managed settings. Managed settings can be delivered by more * than one channel, so this names the known sources to give policy evaluation and the Policy * Diagnostics report one shared vocabulary. Extend this union (and {@link MANAGED_SETTINGS_CHANNELS} * / {@link pickManagedSettings}) when adding a new channel. */ export type ManagedSettingsChannel = /** GitHub `/copilot_internal/managed_settings` endpoint (server-delivered). */ "server" /** Native MDM: OS registry (Windows) / managed preferences (macOS) via `@vscode/policy-watcher`. */ | "nativeMdm" /** File on a well-known disk path (`managed-settings.json`). */ | "file"; /** * The source attributed to an effective managed setting (or to the overall report). A * {@link ManagedSettingsChannel} once a channel has won, or `'none'` when no channel contributes. */ export type ManagedSettingsSource = ManagedSettingsChannel | "none"; /** * The delivery channels in fixed precedence order (highest first): native MDM → server-delivered → * file on disk. This single ordered list drives the per-key resolution in {@link pickManagedSettings} * and is the one place to extend when a new channel is introduced. Rationale for the order: the * server is harder to bypass than local MDM, and a local file is the most easily tampered with. */ export declare const MANAGED_SETTINGS_CHANNELS: readonly ManagedSettingsChannel[]; /** A single channel's contribution to a managed-settings key, for provenance in the resolution. */ export interface IManagedSettingsContribution { /** The channel that supplied this value. */ readonly channel: ManagedSettingsChannel; /** The value the channel supplied for the key. */ readonly value: ManagedSettingValue; } /** How a single managed-settings key was resolved across the delivery channels. */ export interface IManagedSettingResolution { /** The effective (winning) value applied for the key. */ readonly value: ManagedSettingValue; /** The highest-precedence channel supplying the effective value. */ readonly source: ManagedSettingsChannel; /** Every channel that supplied this key, in delivery precedence order. */ readonly contributions: readonly IManagedSettingsContribution[]; } /** The result of resolving managed settings across the delivery channels. */ export interface IManagedSettingsPick { /** The effective bag, excluding telemetry leaves found only in weaker managed sources. */ readonly values: ManagedSettingsData; /** Per-key provenance: how each key resolved and which channels were overridden. */ readonly resolutions: ReadonlyMap; /** Telemetry keys supplied only by weaker blocks, retained for diagnostics but never applied. */ readonly suppressedTelemetry: ReadonlyMap; /** The channels that supplied at least one *winning* key, in precedence order. */ readonly activeSources: readonly ManagedSettingsChannel[]; } /** * Merge the managed-settings bags from every delivery channel. * * Precedence (highest first): native MDM → server-delivered → file on disk. Unlike a single * authoritative source, the channels *are* merged key-by-key: for each key the highest-precedence * channel that supplies it wins, but a key that the higher channels never set is still filled in by * a lower channel. Telemetry instead selects the highest-priority block in its entirety, including * empty or unrecognized server/file object blocks; native delivery observes declared flat keys only. * Omitted leaves cannot inherit from a weaker managed source. * Sandbox enablement is force-on-wins; bypass, access and credential authentication are deny-wins so UI consumers * cannot discard a sandbox restriction from another channel. * * The parameter order matches the precedence so call sites read top-to-bottom. Centralizing the * resolution here (rather than inlining it at each call site) keeps policy evaluation * ({@link AccountPolicyService.getPolicyData}) and the Policy Diagnostics report from drifting apart, * and gives one obvious place to extend when a new channel is introduced. Empty or absent channels * contribute nothing. */ export declare function pickManagedSettings(nativeMdm: ManagedSettingsData | undefined, server: ManagedSettingsData | undefined, file: ManagedSettingsData | undefined): IManagedSettingsPick; /** macOS well-known path for file-based managed settings. */ export declare const MANAGED_SETTINGS_MACOS_FILE_PATH = "/Library/Application Support/GitHubCopilot/managed-settings.json"; /** Linux well-known path for file-based managed settings. */ export declare const MANAGED_SETTINGS_LINUX_FILE_PATH = "/etc/github-copilot/managed-settings.json"; /** Windows directory name under %ProgramFiles% for file-based managed settings. */ export declare const MANAGED_SETTINGS_WINDOWS_DIR = "GitHubCopilot"; /** Managed settings file name. */ export declare const MANAGED_SETTINGS_FILE_NAME = "managed-settings.json"; /** * Normalize a parsed managed-settings object (from the server `managed_settings` API, a file on * disk, or any other source using the managed-settings schema) into the canonical * `ManagedSettingsData` bag that the policy framework consumes. This is the **single** * normalization path for all delivery channels, so downstream projection and policy `value()` * callbacks behave identically regardless of source. It does not enforce the declared * `managedSettings` schema — dropping undeclared or type-mismatched keys happens later, at * {@link projectManagedSettings}. * * - Scalar leaves (`permissions.*` and any forward-compatible scalar keys) are flattened into * dot-separated keys. * - Structured settings (declared in {@link STRUCTURED_MANAGED_SETTINGS}) are carried as canonical * JSON strings under a single key each — the same shape an admin authors via native MDM. * `PolicyConfiguration` parses the JSON back into the object-typed setting on read. * `extraKnownMarketplaces` is normalized from the schema's `{ [id]: { source, autoUpdate? } }` * map to the policy-backed marketplace dict. * - Telemetry blocks with no representable leaves retain a JSON `{}` anchor under `telemetry`, * so an empty or future-only block still takes precedence over lower managed sources. * * Malformed marketplace entries are dropped (with an optional warning via {@link onWarn}) rather * than throwing, so a bad enterprise settings file degrades gracefully instead of blocking startup. */ export declare function normalizeManagedSettings(parsed: Record, onWarn?: (msg: string) => void): ManagedSettingsData; export declare class NullFileManagedSettingsService implements IFileManagedSettingsService { readonly _serviceBrand: undefined; readonly rawManagedSettings: RawManagedSettingsData; readonly managedSettings: ManagedSettingsData; readonly onDidChangeRawManagedSettings: Event; readonly onDidChangeManagedSettings: Event; initialize(): Promise; }