@@ -297,6 +297,52 @@ const permissionsProperty = schemaProperty<IPermissionsValue>({
297297 sessionMutable : true ,
298298} ) ;
299299
300+ /** Managed runtime restrictions synthesized from effective VS Code settings. */
301+ export interface IManagedPermissions {
302+ readonly disableBypassPermissionsMode ?: 'disable' ;
303+ /** Canonical all-shell prompt rule; active runtime rule policy defaults other governed kinds to ask. */
304+ readonly ask ?: readonly [ 'Shell' ] ;
305+ }
306+
307+ export const MANAGED_PERMISSION_TERMINAL_ASK_RULE = 'Shell' ;
308+
309+ /**
310+ * Treat the empty object used as the merge-safe root-config clear sentinel as
311+ * no managed policy.
312+ */
313+ export function normalizeManagedPermissions ( permissions : IManagedPermissions | undefined ) : IManagedPermissions | undefined {
314+ const disableBypassPermissionsMode = permissions ?. disableBypassPermissionsMode === 'disable' ;
315+ const askForShell = permissions ?. ask ?. includes ( MANAGED_PERMISSION_TERMINAL_ASK_RULE ) === true ;
316+ return disableBypassPermissionsMode || askForShell ? {
317+ ...( disableBypassPermissionsMode ? { disableBypassPermissionsMode : 'disable' as const } : { } ) ,
318+ ...( askForShell ? { ask : [ MANAGED_PERMISSION_TERMINAL_ASK_RULE ] as const } : { } ) ,
319+ } : undefined ;
320+ }
321+
322+ const managedPermissionsProperty = schemaProperty < IManagedPermissions > ( {
323+ type : 'object' ,
324+ title : localize ( 'agentHost.config.managedPermissions.title' , "Managed Permissions" ) ,
325+ description : localize ( 'agentHost.config.managedPermissions.description' , "Permission restrictions derived from effective VS Code settings and forwarded to the runtime as `managedSettings.permissions` at session startup." ) ,
326+ properties : {
327+ disableBypassPermissionsMode : {
328+ type : 'string' ,
329+ title : localize ( 'agentHost.config.managedPermissions.disableBypass' , "Disable bypass permissions mode" ) ,
330+ enum : [ 'disable' ] ,
331+ } ,
332+ ask : {
333+ type : 'array' ,
334+ title : localize ( 'agentHost.config.managedPermissions.ask' , "Required permission prompts" ) ,
335+ items : {
336+ type : 'string' ,
337+ title : localize ( 'agentHost.config.managedPermissions.rule' , "Permission rule" ) ,
338+ enum : [ MANAGED_PERMISSION_TERMINAL_ASK_RULE ] ,
339+ } ,
340+ } ,
341+ } ,
342+ // No default: `{}` is the wire-level clear sentinel and is normalized to
343+ // `undefined` before SDK launch, so `managedSettings` is omitted.
344+ } ) ;
345+
300346/**
301347 * Session-config properties owned by the platform itself — i.e. consumed
302348 * by the agent host rather than by any particular agent.
@@ -433,6 +479,24 @@ export const TERMINAL_AUTO_APPROVE_ENABLED_SETTING_ID = 'chat.tools.terminal.ena
433479 */
434480export const AgentHostGlobalAutoApproveEnabledConfigKey = 'globalAutoApproveEnabled' ;
435481
482+ /**
483+ * The VS Code setting ID for global auto approve. Defined here so renderer-side
484+ * agent-host clients can forward it without importing from `workbench/contrib/chat`.
485+ */
486+ export const GLOBAL_AUTO_APPROVE_SETTING_ID = 'chat.tools.global.autoApprove' ;
487+
488+ /**
489+ * Root config key forwarded from the renderer holding the {@link IManagedPermissions}
490+ * object. Synthesized by VS Code from the effective values of
491+ * `chat.tools.global.autoApprove` and
492+ * `chat.tools.terminal.enableAutoApprove`, and forwarded to the runtime as
493+ * `managedSettings.permissions` at SDK session startup. Absent when no policy applies.
494+ */
495+ export const AgentHostManagedPermissionsConfigKey = 'managedPermissions' ;
496+
497+ /** Marker written to diagnostic logs instead of enterprise-managed permission rules. */
498+ export const AgentHostManagedPermissionsLogRedaction = '<redacted>' ;
499+
436500/**
437501 * Root config key forwarded from the renderer when VS Code's `chat.autoReply`
438502 * setting changes. When `true`, the agent host auto-answers `ask_user`
@@ -714,6 +778,7 @@ export const platformRootSchema = createSchema({
714778 description : localize ( 'agentHost.config.globalAutoApproveEnabled.description' , "Whether VS Code's global auto-approve setting is enabled. When `true`, every tool call is auto-approved, equivalent to a session using Allow all." ) ,
715779 default : false ,
716780 } ) ,
781+ [ AgentHostManagedPermissionsConfigKey ] : managedPermissionsProperty ,
717782 [ AgentHostAutoReplyEnabledConfigKey ] : schemaProperty < boolean > ( {
718783 type : 'boolean' ,
719784 title : localize ( 'agentHost.config.autoReplyEnabled.title' , "Auto Reply" ) ,
0 commit comments