import { type IConfigurationValue } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration"; import { type IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service"; import type { IMcpServerConfiguration } from "@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpPlatformTypes"; import { TelemetryConfiguration, TelemetryLevel } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry"; import type { SessionConfigPropertySchema, SessionConfigSchema } from "@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/commands"; /** * A schema property with a phantom TypeScript type and a precomputed * runtime validator. * * The `` type parameter is the developer's assertion about the * property's runtime shape; the validator derived from `protocol` * (`type`, `enum`, `items`, `properties`, `required`) enforces it at * runtime. */ export interface ISchemaProperty { readonly protocol: SessionConfigPropertySchema; /** * Returns `true` iff `value` conforms to {@link protocol}. Narrows * the type to `T` for callers. The boolean form is preferred for * control flow; use {@link assertValid} when you want a descriptive * error for the offending path. */ validate(value: unknown): value is T; /** * Throws a {@link ProtocolError} with `JsonRpcErrorCodes.InvalidParams` * describing the offending path (e.g. `'permissions.allow[2]'`) when * `value` does not conform to {@link protocol}. Otherwise returns and * narrows the type to `T`. * * @param path Dotted path prefix to embed in error messages. Defaults * to empty (the value itself). */ assertValid(value: unknown, path?: string): asserts value is T; } /** * Defines a strongly-typed schema property whose runtime validator is * derived from the supplied JSON-schema descriptor. */ export declare function schemaProperty(protocol: SessionConfigPropertySchema): ISchemaProperty; export type SchemaDefinition = Record>; export type SchemaValue

= P extends ISchemaProperty ? T : never; export type SchemaValues = { [K in keyof D]?: SchemaValue; }; /** * A bundle of named schema properties plus helpers for serializing to the * protocol shape, validating a values bag at write sites, and validating * a single key at read sites. */ export interface ISchema { readonly definition: D; /** Returns the protocol-serializable schema for this bundle. */ toProtocol(): SessionConfigSchema; /** * Validates each known key in `values` against its schema and returns * a new plain record. Throws a {@link ProtocolError} with a path like * `'permissions.allow[2]'` when any supplied value fails validation. * Unknown keys are passed through untouched for forward-compatibility. */ values(values: SchemaValues): Record; /** * Returns `true` iff `value` validates against the schema for `key`. * Unknown keys return `false`. */ validate(key: K, value: unknown): value is SchemaValue; /** * Throws a {@link ProtocolError} describing the offending path when * `value` does not validate against the schema for `key`, or when * `key` is not defined in the schema. */ assertValid(key: K, value: unknown): asserts value is SchemaValue; /** * Returns a fully-typed values bag by validating each key of the * schema against `values` and falling back to the default when * the incoming value is missing or fails validation. * * Semantics: for every key declared in the schema `definition`: * - if `values[key]` validates, it is kept; * - else if `key` is present in `defaults`, the default is used; * - else the key is omitted from the result. * * This means callers MAY supply defaults for only a subset of the * schema — keys not present in `defaults` are simply left unset * when the incoming value is missing or invalid. This is useful * when some properties (e.g. per-session `permissions`) should be * inherited from a higher scope rather than materialized on every * new session. * * Intended for sanitizing untrusted input at protocol boundaries * (e.g. `resolveSessionConfig`). Keys that fail validation are * silently replaced with their default or dropped; use * {@link values} or {@link assertValid} when you want a descriptive * {@link ProtocolError} instead. */ validateOrDefault; }>>(values: { [K in keyof T]?: unknown; } | undefined, defaults: T): T; } export declare function createSchema(definition: D): ISchema; export type AutoApproveLevel = "default" | "autoApprove"; export type SessionMode = "interactive" | "plan" | "autopilot"; export interface IPermissionsValue { readonly allow: readonly string[]; readonly deny: readonly string[]; } /** * Session-config properties owned by the platform itself — i.e. consumed * by the agent host rather than by any particular agent. * * Agents extend this schema by spreading `platformSessionSchema.definition` * into their own {@link createSchema} call together with any * provider-specific properties. */ export declare const platformSessionSchema: ISchema<{ autoApprove: ISchemaProperty; permissions: ISchemaProperty; mode: ISchemaProperty; }>; /** * Rewrites a legacy `autoApprove='autopilot'` config value — used before * Autopilot moved from the `autoApprove` axis onto the orthogonal `mode` * axis — into the current two-axis shape: * * - `autoApprove='autopilot'` + `mode='plan'` → `mode='plan'`, `autoApprove='default'` * (legacy `plan` took precedence over autopilot when resolving the SDK mode). * - `autoApprove='autopilot'` + any other mode → `mode='autopilot'`, `autoApprove='default'`. * * Returns a shallow copy with the migration applied, or the original * reference unchanged when no legacy value is present. Safe to call on * `undefined`. * * Without this, a session persisted (or a "remembered" picker value seeded) * with `autoApprove='autopilot'` would fail the new schema's enum validation * and silently fall back to `default`, downgrading the session from * autonomous Autopilot to manual per-tool confirmation. */ export declare function migrateLegacyAutopilotConfig | undefined>(config: T): T; /** * Root (agent host) config properties owned by the platform itself. * * Root config acts as the baseline that applies to every session: * * - {@link SessionConfigKey.Permissions} — host-wide allow/deny lists * unioned with each session's own permissions when evaluating tool * auto-approval. See `SessionPermissionManager` for the evaluation * rules. */ export declare const AgentHostTelemetryLevelConfigKey = "telemetryLevel"; /** * Root config key forwarded from the renderer when VS Code's * `chat.sessionSync.enabled` setting changes. Controls the `remote` flag * passed to the copilot-sdk `CopilotClientOptions`. */ export declare const AgentHostSessionSyncEnabledConfigKey = "sessionSyncEnabled"; /** * Root config key forwarded from the renderer carrying the experiment-aware * value of `chat.agentHost.codexAgent.enabled`. The host registers the Codex * provider when this is `true`; disabling requires an agent host restart. */ export declare const AgentHostCodexEnabledConfigKey = "codexAgentEnabled"; /** * Root config key forwarded from the renderer when VS Code's * `chat.tools.terminal.enableAutoApprove` setting changes. Controls whether * agent-host shell permission checks may apply terminal auto-approve rules. */ export declare const AgentHostTerminalAutoApproveEnabledConfigKey = "terminalAutoApproveEnabled"; /** * The VS Code setting ID for terminal auto approve enablement. Defined here so * renderer-side agent-host clients can forward it without importing from * workbench terminal contributions. */ export declare const TERMINAL_AUTO_APPROVE_ENABLED_SETTING_ID = "chat.tools.terminal.enableAutoApprove"; /** * Root config key forwarded from the renderer when VS Code's * `chat.tools.global.autoApprove` setting changes. When `true`, the global * auto-approve ("approve everything") setting is enabled and the agent host * treats every tool call as auto-approved — equivalent to a session running * with Bypass Approvals. */ export declare const AgentHostGlobalAutoApproveEnabledConfigKey = "globalAutoApproveEnabled"; /** * The VS Code setting ID for global auto approve. Defined here so renderer-side * agent-host clients can forward it without importing from `workbench/contrib/chat`. */ export declare const GLOBAL_AUTO_APPROVE_SETTING_ID = "chat.tools.global.autoApprove"; /** * Root config key forwarded from the renderer when VS Code's `chat.autoReply` * setting changes. When `true`, the agent host auto-answers `ask_user` * questions instead of blocking on the user — the user is treated as * unavailable and the agent is told to use its best judgment, mirroring the * behavior of `autopilot` mode. */ export declare const AgentHostAutoReplyEnabledConfigKey = "autoReplyEnabled"; /** * The VS Code setting ID for auto-reply. Defined here so renderer-side * agent-host clients can forward it without importing from `workbench/contrib/chat`. */ export declare const AUTO_REPLY_SETTING_ID = "chat.autoReply"; /** * Root config key forwarded from the renderer when VS Code's * `chat.tools.terminal.autoApprove` setting changes. Holds the effective * terminal auto-approve rule object for agent-host shell permission checks. */ export declare const AgentHostTerminalAutoApproveRulesConfigKey = "terminalAutoApproveRules"; export interface IAgentHostTerminalAutoApproveRule { readonly approve: boolean; readonly matchCommandLine?: boolean; } export type AgentHostTerminalAutoApproveRuleValue = boolean | null | IAgentHostTerminalAutoApproveRule; export type AgentHostTerminalAutoApproveRules = Record; /** * The VS Code setting IDs for terminal auto approve rules. Defined here so * renderer-side agent-host clients can forward them without importing from * workbench terminal contributions. */ export declare const TERMINAL_AUTO_APPROVE_SETTING_ID = "chat.tools.terminal.autoApprove"; export declare const TERMINAL_IGNORE_DEFAULT_AUTO_APPROVE_RULES_SETTING_ID = "chat.tools.terminal.ignoreDefaultAutoApproveRules"; export declare function getAgentHostTerminalAutoApproveRulesConfig(configurationService: IConfigurationService): AgentHostTerminalAutoApproveRules; export declare function normalizeAgentHostTerminalAutoApproveRulesConfig(config: AgentHostTerminalAutoApproveRules | undefined, configInspectValue: IConfigurationValue>, ignoreDefaults: boolean): AgentHostTerminalAutoApproveRules; /** * Root config key holding agent-host-level MCP server definitions. * * The value is a map of server name → {@link IMcpServerConfiguration} * (the same `servers` shape used by `mcp.json`). These servers are * exposed to every session created by the host, merged with any * plugin-provided MCP servers when launching the copilot-sdk client. */ export declare const AgentHostMcpServersConfigKey = "mcpServers"; /** * Map of server name → MCP server configuration, as stored in the * {@link AgentHostMcpServersConfigKey} root config value. */ export type AgentHostMcpServers = Record; /** * The VS Code setting ID for session sync. Defined here so the platform * layer (renderer-side forwarding) can reference it without importing from * `workbench/contrib/chat`. */ export declare const SESSION_SYNC_ENABLED_SETTING_ID = "chat.sessionSync.enabled"; export declare function telemetryLevelToAgentHostConfigValue(telemetryLevel: TelemetryLevel): TelemetryConfiguration; export declare function agentHostConfigValueToTelemetryLevel(value: unknown): TelemetryLevel | undefined; export declare const platformRootSchema: ISchema<{ permissions: ISchemaProperty; telemetryLevel: ISchemaProperty; sessionSyncEnabled: ISchemaProperty; codexAgentEnabled: ISchemaProperty; terminalAutoApproveEnabled: ISchemaProperty; globalAutoApproveEnabled: ISchemaProperty; autoReplyEnabled: ISchemaProperty; terminalAutoApproveRules: ISchemaProperty; mcpServers: ISchemaProperty; }>;