ide на основе vs code
Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
This file documents the managed-settings modality: how an enterprise admin's Copilot configuration (delivered to VS Code via native MDM or the GitHub server) flows into VS Code's policy stack and locks a setting. It is a companion to SKILL.md — read that first for the general policy lifecycle (policy: field, export, artifacts).
Managed settings layer on top of the existing policy framework. They do not introduce a new IPolicyService; they feed IPolicyData.managedSettings, which the existing policy.value(policyData) callback already consumes via AccountPolicyService.
Every enterprise-managed Copilot setting resolves through a single normalized bag:
// src/vs/base/common/policy.ts
export type PolicyValue = string | number | boolean;
export type ManagedSettingValue = PolicyValue;
export type ManagedSettingsData = Readonly<Record<string, ManagedSettingValue>>;…surfaced on IPolicyData.managedSettings (src/vs/base/common/defaultAccount.ts). The real JSDoc there summarizes it as: a normalized bag keyed by dot-separated paths (e.g. permissions.disableBypassPermissionsMode), the single channel for enterprise-managed config so server-delivered and native MDM settings resolve identically, with structured settings (e.g. enabledPlugins, extraKnownMarketplaces) carried as canonical JSON strings:
export interface IPolicyData {
// ...
readonly managedSettings?: ManagedSettingsData;
}Keys are flat dot-paths. Scalar leaves flatten directly. Structured values (objects/arrays such as enabledPlugins / extraKnownMarketplaces) are carried as a JSON string under a single key — the same shape an admin authors via native MDM — and parsed back into the object-typed setting on read by PolicyConfiguration.
VS Code implements three channels feeding the bag, matching the external schema's described delivery slots (native MDM, server-managed, and file-based).
| Channel | Where it's read | Implementation | Lands on | |---------|-----------------|----------------|----------| | Native MDM (Windows registry / macOS plist) | OS managed preferences | NativeManagedSettingsService (src/vs/platform/policy/node/nativeManagedSettingsService.ts) via @vscode/policy-watcher | INativeManagedSettingsService.managedSettings | | Server-managed (/copilot_internal/managed_settings) | GitHub endpoint; per the code comment in managedSettings.ts, it returns the enterprise's .github/copilot/settings.json content | adaptManagedSettings (src/vs/workbench/services/accounts/browser/managedSettings.ts) → DefaultAccountService.policyData | accountPolicyData.managedSettings | | File-based (managed-settings.json) | well-known per-OS disk path (e.g. /Library/Application Support/GitHubCopilot/ on macOS), read in the main process and exposed to renderer windows over IPC | FileManagedSettingsService (src/vs/platform/policy/common/fileManagedSettingsService.ts) | IFileManagedSettingsService.rawManagedSettings + .managedSettings |
All three VS Code channels converge in AccountPolicyService.getPolicyData().
Precedence: native MDM managed settings win over the server-delivered channel, which in turn wins over the file-based channel (pickManagedSettings in copilotManagedSettings.ts). Precedence is resolved per key: for each key the highest-precedence channel that supplies it wins, but a key that the higher channels leave unset is still filled in by a lower channel. A value an admin locks via native MDM therefore cannot be overwritten by the server or a file, while keys the higher channels never set remain available to lower ones. Rationale for the order: the server is harder to bypass than local MDM, and a local file is the most easily tampered with. The merged bag is then projected onto the declared schema (see below). Client-side merging still happens *within* a channel's value (e.g. enabledPlugins, extraKnownMarketplaces).
When the developer has copilot-agent-runtime checked out side-by-side, reference copilot-agent-runtime/schema/managed-settings-schema.json as the authoritative shape. It is aligned with the managed_settings API output and is the schema for all delivery channels (MDM plist/registry, file-based, server-managed). The runtime schema also contains keys that VS Code never projects because their behavior is runtime-owned. The table below contains selected VS Code-projected examples with non-obvious composition or encoding. It is not an inventory; derive the current key set from policy declarations and the runtime schema.
The schema is nested, whereas the VS Code bag is flattened to dot-paths — e.g. the schema's nested permissions.disableBypassPermissionsMode becomes the flat bag key of the same name (the COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY constant):
| Schema property (path) | Type in schema | Composition (x-composition.strategy) | |------------------------|----------------|----------------------------------------| | permissions.disableBypassPermissionsMode | string enum "disable" \| "allow-auto-only" | most-restrictive-wins (sticky once set) | | model | string (auto, a model family name, or a full model id) | — | | permissions.model | string (legacy location for model) | — | | forceRemoteSettingsRefresh | boolean | MDM wins; controls the server cache rather than a configuration setting | | enabledPlugins | { "PLUGIN@MARKETPLACE": boolean } | deny-wins (false beats true; enterprise denials immutable) | | extraKnownMarketplaces | { name: { source, autoUpdate? } }, source github \| git \| directory | most-restrictive-wins (higher layer is the complete allowlist); explicit autoUpdate overrides the client's global plugin auto-update setting for that marketplace | | strictKnownMarketplaces | array of source descriptors | most-restrictive-wins (empty array = lockdown) |
> Current schema ↔ runtime divergence (treat managed-settings-schema.json as the > API source of truth, and keep the VS Code managedSettings declarations aligned with > what the server actually projects into the bag): > - extraKnownMarketplaces: the schema permits source kinds github / git / > directory, but the VS Code normalizer only accepts github and git — > directory (and any other kind) is dropped with a warning > (managedSettings.ts normalizeExtraKnownMarketplaces; IExtraKnownMarketplaceEntry > in base/common/managedSettings.ts only types github/git). > > Note every structured key — enabledPlugins, extraKnownMarketplaces, > strictKnownMarketplaces — is declared on its policy as `{ type: 'string' }`: the > object/array value is carried as a JSON string in the bag and parsed back on read (see > Structured settings). The *setting's* own type is > the real shape — e.g. chat.plugins.strictMarketplaces is ['array', 'null']
Note the schema's x-composition describes the server/runtime layering across enterprise/org/user. Inside VS Code the bag has already been collapsed to a single projected ManagedSettingsData before a policy.value() callback ever sees it.
> Multi-key precedence (`model`). The channel merge in pickManagedSettings only resolves the > *same* key across delivery channels; it does not know that top-level model supersedes the legacy > nested permissions.model. That cross-key precedence is resolved in the policy's value() > callback (managedModelValue in copilotManagedSettings.ts), which reads the top-level key first > and falls back to the legacy key (treating a blank value as unset). Because it is key-level, a > non-empty top-level model wins even when permissions.model was supplied by a > higher-precedence channel. The ChatDefaultModel policy declares both keys in its > managedSettings so native MDM watches each and projection keeps them.
A policy that should be driven by a managed-settings key declares two things on its IPolicy object (src/vs/base/common/policy.ts):
1. managedSettings — the dot-path keys it reads, with their value type. 2. A value(policyData) callback that reads policyData.managedSettings?.[KEY].
Use the exported key constants from src/vs/platform/policy/common/copilotManagedSettings.ts — never inline the strings:
import {
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY,
} from '../../../../platform/policy/common/copilotManagedSettings.js';
// chat.tools.global.autoApprove — owns ChatToolsAutoApprove (existing policy, shown verbatim)
policy: {
name: 'ChatToolsAutoApprove',
category: PolicyCategory.InteractiveSession,
minimumVersion: '1.99', // existing value — for a NEW policy use package.json major.minor (see SKILL.md Step 1)
value: (policyData) =>
policyData.managedSettings?.[COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY] === 'disable'
|| policyData.chat_preview_features_enabled === false
? false
: undefined,
managedSettings: {
[COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY]: { type: 'string' },
},
localization: { description: { /* ... */ } },
}Key rules for the value callback:
policyData.managedSettings?.[KEY] — never a typed field on IPolicyData (the typed enabledPlugins / extraKnownMarketplaces / strictKnownMarketplaces fields were removed; everything is the canonical bag now).
undefined otherwise(so the user's setting falls through).
chat_preview_features_enabled === false token-entitlement check. Preserve it when maintaining those policies, but do not add it to a new control.
For the common pass-through case — lock to the managed value, otherwise fall through to the user's setting — use the managedSettingValue(KEY) helper instead of hand-writing the callback:
import { managedSettingValue } from '../../../../platform/policy/common/copilotManagedSettings.js';
value: managedSettingValue(COPILOT_ENABLED_PLUGINS_KEY),Existing policies that combine the managed value with historical conditions (like ChatToolsAutoApprove above) keep a custom callback. The helper returns a callback memoized per key (the same function reference for a given key on every call), preserving the policy-definition reference identity that lets isSamePolicyDefinition avoid needless re-registration.
For settings whose type is 'object' or 'array', the policy still declares the managed-settings key as a string (the JSON is carried as a string), and the value callback returns that raw string. The { type: 'string' } is mandatory and must be `'string'` for these keys, not filler: projectManagedSettings keeps a bag value only when typeof value === type, and the native MDM watcher reads the registry/plist value as that type. type is a required field whose only allowed values are 'string' | 'number' | 'boolean' (IManagedSettingPolicyDefinition in base/common/policy.ts), so omitting it or declaring 'object' / 'array' is a *compile* error. Declaring 'number' / 'boolean' compiles, but because the structured value travels as a JSON string it then flunks that typeof check at *runtime* and gets dropped, so the managed setting silently never applies. When the policy value is a string but the setting's type is not, PolicyConfiguration parses it back into the typed value on read via its own lenient JSONC parser (PolicyConfiguration.parse() using a json.visit streaming visitor — *not* JSON.parse
// chat.plugins.enabledPlugins — setting type: 'object'; managed key carried as a string
value: managedSettingValue(COPILOT_ENABLED_PLUGINS_KEY),
managedSettings: { [COPILOT_ENABLED_PLUGINS_KEY]: { type: 'string' } },ChatExtraMarketplaces (chat.plugins.extraMarketplaces) is policy-only (included: false) — there is no user-writable surface for it; it exists solely as a delivery slot for the managed value.
copilotManagedSettings.ts)| Function | Role | |----------|------| | flattenManagedSettings(obj) | Flattens a nested response into dot-path scalars (used by normalizeManagedSettings). | | normalizeManagedSettings(parsed, onWarn?) | The single normalizer shared by every channel: turns a parsed managed-settings object (server response, file on disk, …) into the canonical bag. Scalar leaves flatten; structured keys (declared in the STRUCTURED_MANAGED_SETTINGS table) are JSON-encoded under a single key each. The server adapter adaptManagedSettings and the file channel both call it. | | collectManagedSettingsDefinitions(policyDefinitions) | Aggregates every policy's managedSettings into one key → { type } map. Single source of truth for policy-backed keys and types; drives server projection and the declaration-driven portion of the MDM watcher. | | MANAGED_SETTINGS_CONTROL_DEFINITIONS | Fixed schema for transport controls consumed by the managed-settings pipeline itself. These keys are always added to the native MDM watcher but are not projected as configuration policies. | | hasManagedSettingsDefinitions(policyDefinitions) | Cheap short-circuiting existence check (does *any* policy declare a managed key?) — used to decide whether the declaration-driven watcher schema needs updating, without building the full aggregate. | | projectManagedSettings(values, definitions, onWarn?) | Keeps only declared keys whose runtime value matches the declared type. Undeclared keys and type mismatches are dropped (validated, never coerced), with an optional warning. | | pickManagedSettings(nativeMdm, server, file) | Merges the channels per key by precedence (native MDM → server → file): the highest-precedence channel that sets a key wins, lower channels fill in keys the higher ones leave unset, and every contribution is recorded for provenance.
IPolicyData.managedSettingsActive is true when any channel supplies any managed setting — i.e. the user is governed at all, independent of which keys were set. It is set in AccountPolicyService.getPolicyData from pickManagedSettings(...).activeSources, and unlike IPolicyData.managedSettings it is not projected onto the keys VS Code declares, so it also reflects runtime-owned keys VS Code never reads.
The Claude3PIntegration and Codex3PIntegration policies both use thirdPartyAgentEnabledValue, which forces its setting to false when the account disables chat preview features or when managedSettingsActive is true. Rationale: managed settings are composed and enforced by the Copilot runtime and never reach the Claude or Codex harnesses, so leaving those harnesses available would hand a governed user an ungoverned path around every control the enterprise set. This mirrors the runtime-owned sandbox.enabled floor retiring the local harness (IAgentHostEnablementService.managedSandboxEnforced).
Invariants:
managedSettings keys — they must not be added to the native MDM watcher schema.
AccountPolicyService.resolvePolicyValue probes for this presence dependence (re-evaluating the callback with managedSettingsActive: false) so Developer: Policy Diagnostics attributes the value to the governing channel rather than to the account.
value callback stays pure and deterministic — attribution evaluates it more than once.normalizeManagedSettings (copilotManagedSettings.ts) turns a parsed managed-settings object into the canonical bag, and is shared by every channel — the server adapter adaptManagedSettings (managedSettings.ts) is a thin wrapper around it, and the file channel calls it directly. Scalar leaves flatten directly; structured (object/array) keys are JSON-encoded under a single bag key. The per-key knowledge for the structured ones lives in one table, STRUCTURED_MANAGED_SETTINGS. Each row declares the key (the source field name read from the input, which is also the canonical bag key the JSON string is stored under — identical for structured settings by contract) and an encode(raw, onWarn?) that normalizes the value before JSON.stringify. Adding a structured key is one descriptor row (plus the server IManagedSettingsResponse field and the policy declaration) — no new bespoke branch in the normalizer. The adaptManagedSettings / normalizeManagedSettings tests are the drift backstop.
Constants (also in copilotManagedSettings.ts):
| Constant | Value | |----------|-------| | GITHUB_COPILOT_WIN32_REGISTRY_PATH | SOFTWARE\Policies\GitHubCopilot | | GITHUB_COPILOT_WIN32_POLICY_NAME | GitHubCopilot (productName for the watcher) | | GITHUB_COPILOT_MACOS_BUNDLE_ID | com.github.copilot (CFPreferences app id) | | COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY | permissions.disableBypassPermissionsMode | | COPILOT_TOP_LEVEL_MODEL_KEY | model (canonical; wins over the legacy nested key) | | COPILOT_MODEL_KEY | permissions.model (legacy; retained for original-schema deployments) | | COPILOT_ENABLED_PLUGINS_KEY | enabledPlugins | | COPILOT_EXTRA_MARKETPLACES_KEY | extraKnownMarketplaces | | COPILOT_STRICT_MARKETPLACES_KEY | strictKnownMarketplaces | | COPILOT_FORCE_REMOTE_SETTINGS_REFRESH_KEY | forceRemoteSettingsRefresh |
Native MDM is desktop-main only (src/vs/code/electron-main/main.ts). The real wiring constructs the platform service first (Windows / macOS only), then registers it — falling back to NullNativeManagedSettingsService on Linux (abbreviated):
let nativeManagedSettingsService: NativeManagedSettingsService | undefined;
if (isWindows) {
nativeManagedSettingsService = new NativeManagedSettingsService(
logService, GITHUB_COPILOT_WIN32_POLICY_NAME, { registryPath: GITHUB_COPILOT_WIN32_REGISTRY_PATH });
} else if (isMacintosh) {
nativeManagedSettingsService = new NativeManagedSettingsService(
logService, GITHUB_COPILOT_MACOS_BUNDLE_ID);
}
if (nativeManagedSettingsService) {
services.set(INativeManagedSettingsService, nativeManagedSettingsService);
} else {
services.set(INativeManagedSettingsService, new NullNativeManagedSettingsService());
}It is exposed to the renderer over IPC via NativeManagedSettingsChannel / NativeManagedSettingsChannelClient (nativeManagedSettingsIpc.ts), registered as the nativeManagedSettings channel in app.ts. AccountPolicyService subscribes to onDidChangeManagedSettings and re-evaluates policy values when managed settings change.
The service watches keys that policies declare plus the fixed transport controls in MANAGED_SETTINGS_CONTROL_DEFINITIONS. updatePolicyDefinitions combines those schemas, then @vscode/policy-watcher watches exactly those keys.
The file-based channel is wired the same way (src/vs/code/electron-main/main.ts): FileManagedSettingsService reads managed-settings.json from the per-OS well-known path (MANAGED_SETTINGS_* constants in copilotManagedSettings.ts), falling back to NullFileManagedSettingsService when no path applies. It is exposed to the renderer over IPC via FileManagedSettingsChannel / FileManagedSettingsChannelClient (fileManagedSettingsIpc.ts), registered as the fileManagedSettings channel in app.ts, and AccountPolicyService subscribes to its onDidChangeManagedSettings too. The service also retains the parsed source object as rawManagedSettings with a separate change event. That raw snapshot is diagnostics-only; policy evaluation continues to consume the normalized managedSettings bag.
Developer: Policy Diagnostics shows each delivery channel as a pipeline:
1. Source input (the server response, parsed file, or definition-scoped native watcher values). 2. Canonical normalized bag from normalizeManagedSettings. 3. VS Code policy projection from projectManagedSettings.
It then shows per-key channel precedence, the merged normalized bag, and the final bag delivered to VS Code policy callbacks. Runtime-owned settings can therefore remain visible in a raw source even when VS Code has no corresponding policy declaration and the projected bag is empty.
The report separately queries capable Agent Host providers for their own effective managed-settings snapshot. Copilot uses the platform runtime package's public sdk/index.js#getManagedSettings() API, which returns the same payload as session.managed_settings_resolved without requiring an active session. This runtime snapshot is not treated as another VS Code delivery channel because the runtime owns its schema and authority resolution independently.
Follow this checklist only after the root SKILL.md routes the control to a VS Code or split runtime/editor policy. Runtime-only managed settings need no VS Code constant, configuration policy, or policy-data export.
1. Pick the canonical dot-path and add it as a constant in copilotManagedSettings.ts. It must match the server managed_settings API field / the managed-settings-schema.json key exactly. 2. Attach it to a policy on the governing setting: add managedSettings: { [KEY]: { type } } and a value callback. For a plain pass-through use value: managedSettingValue(KEY); only hand-write the callback when combining with another condition. A transport control with no governing configuration setting is the exception: add its schema to MANAGED_SETTINGS_CONTROL_DEFINITIONS and consume it in the delivery pipeline instead. 3. If the value is structured (object/array), declare the managed key as 'string' and let PolicyConfiguration parse the JSON back on read. Then teach the shared normalizer by adding one row to STRUCTURED_MANAGED_SETTINGS in copilotManagedSettings.ts (the key and an encode that normalizes the raw shape into what an admin would author in MDM) plus the matching field on the server IManagedSettingsResponse. That table is the single place structured-key handling lives, and it applies to every channel (server, file-based, …) because they all funnel through normalizeManagedSettings. 4. Keep the schema aligned. The runtime, the server endpoint, and managed-settings-schema.json must agree on the key name and value type. The declaration-driven projection (
forceRemoteSettingsRefreshforceRemoteSettingsRefresh is not a user configuration setting. It controls whether the server-managed-settings cache may satisfy startup, so VS Code preserves it in the cached raw server bag and always includes it in the native MDM watch schema. DefaultAccountProvider resolves the control across native MDM, cached server, and managed-file delivery before using the server cache. When the result is true, only a fresh successful server response for the current account, authentication provider, and endpoint satisfies the requirement. A failed refresh may retain cached restrictions and the flag itself, but the Account Policy gate keeps AI features disabled until a retry succeeds. Authentication remains available so users can recover from missing or expired credentials.
Reference tests:
src/vs/platform/policy/test/common/copilotManagedSettings.test.tssrc/vs/platform/policy/test/node/nativeManagedSettingsService.test.tssrc/vs/workbench/services/policies/test/browser/accountPolicyService.test.tssrc/vs/workbench/services/accounts/test/browser/managedSettings.test.ts(includes an end-to-end equivalence test: a server JSON string and a native MDM JSON string resolve to the identical typed object).
src/vs/platform/policy/test/common/fileManagedSettingsService.test.ts (covers normalizeManagedSettings and the file-based channel reader).
Manual/local testing: use the mock policy server to serve arbitrary managed_settings (and entitlement/token) responses and apply them via Developer: Sync Account Policy — see local-testing.md.
policyReference)A single enterprise policy can lock more than one setting — e.g. gate an agent in both the editor window and the Agents window. This is the policyReference mechanism (src/vs/base/common/policy.ts → IPolicyReference).
policy: { name, … } (type, metadata, runtime value/managedSettings). Exactly one setting may own a given policy name.
policyReference: { name } pointing at that owner's policy name.A reference is a pure pointer: no type, no value, no localization. It only contributes the name so the setting is gated and the OS watcher observes the name in processes where the owner module isn't loaded.
// Owner: chat.agentHost.codexAgent.enabled (existing policy, shown verbatim;
// `minimumVersion: '1.126'` is its historical value — a NEW policy uses package.json major.minor)
policy: { name: 'Codex3PIntegration', category: PolicyCategory.InteractiveSession,
minimumVersion: '1.126', value: (d) => d.chat_preview_features_enabled === false ? false : undefined,
localization: { /* ... */ } }
// Reference: sessions.chat.claudeAgent.enabled and chat.agentHost.claudeAgent.enabled
policyReference: { name: 'Claude3PIntegration' } // owned by github.copilot.chat.claudeAgent.enabledRules & internals:
policy and policyReference on the same setting (rejected at registration in configurationRegistry.ts).
type must match the owner's (enforced when exporting the catalog).ConfigurationRegistry.getPolicyReferenceConfigurations() returns name → Set<settingKey>. PolicyConfiguration applies the owner's resolved policy value to every reference key too.
toSerializablePolicyDefinition() strips the non-cloneable value() callback so a policy registered in the main process survives structured-clone to the renderer. AbstractPolicyService.updatePolicyDefinitions replaces per name, so a late-registering owner supersedes an earlier-registered reference (and removing the owner falls back to the reference's bare type).
PolicyDto gains referencedSettings: string[] (sorted; omitted when a policy governs only its owner). The exporter only captures references that are registered/loaded at export time, so the checked-in policyData.jsonc can list fewer references than the source declares — e.g. Claude3PIntegration lists only chat.agentHost.claudeAgent.enabled, not the sessions.chat.claudeAgent.enabled reference declared in the sessions contribution. At runtime, the Developer: Policy Diagnostics report (developerActions.ts) lists every registered setting each policy governs, owner + references.
| PR | Change | |----|--------| | #318623 | Wire /copilot_internal/managed_settings into AccountPolicyService/IPolicyData; add chat.plugins.enabledPlugins/extraMarketplaces/strictMarketplaces settings + adaptManagedSettings shape adaptation. No new IPolicyService. | | #320991 | Add native MDM delivery: NativeManagedSettingsService + @vscode/policy-watcher; let policies declare managedSettings mappings; wire the first V0 key permissions.disableBypassPermissionsMode → force ChatToolsAutoApprove=false. | | #321218 | Make IPolicyData.managedSettings the single channel: server + native MDM project into one canonical bag; structured settings carried as canonical JSON strings; remove the typed enabledPlugins/extraKnownMarketplaces
'string''string'type'string' | 'number' | 'boolean''object''array''number''boolean'typeof value === typeconfigurations.tschat.shared.contribution.tsManagedSettingsChannelMANAGED_SETTINGS_CHANNELSmanagedSettingValue(key)valuepolicyData => policyData.managedSettings?.[key]thirdPartyAgentEnabledValue(policyData)valueprojectManagedSettingsnpm run typecheck-clientnpm run export-policy-datapolicyData.jsoncstrictKnownMarketplacespolicyReferenceClaude3PIntegrationCodex3PIntegration