mirror of
https://github.com/openai/codex.git
synced 2026-11-25 23:30:49 +00:00
sync guardian permission preset
This commit is contained in:
@@ -203,7 +203,7 @@ Example with notification opt-out:
|
||||
- `modelProvider/capabilities/read` — read provider-level capabilities for the currently configured model provider.
|
||||
- `experimentalFeature/list` — list feature flags with stage metadata (`beta`, `underDevelopment`, `stable`, etc.), enabled/default-enabled state, and cursor pagination. Pass `threadId` when showing feature state for an existing loaded thread so `enabled` is computed from that thread's refreshed config, including project-local config for the thread's cwd; if omitted, the server uses its default config resolution context. For non-beta flags, `displayName`/`description`/`announcement` are `null`.
|
||||
- `permissionProfile/list` — beta; list available permission profile ids with optional display `description` text and an `allowed` flag reflecting effective requirements, using cursor pagination. Pass `cwd` when the caller needs project-local `[permissions.<id>]` entries to be included in the current catalog view.
|
||||
- `permissionPreset/list` — experimental; list resolved, selectable permission presets for an optional `cwd`, using cursor pagination. Each preset includes an opaque `id`, `permissionProfileId`, `approvalPolicy`, `approvalsReviewer`, optional custom-profile `description`, and `isDefault`. The server applies managed requirements, omits unavailable profiles, and removes presets that resolve to the same settings; clients should preserve response order and apply the returned settings without reconstructing preset policy.
|
||||
- `permissionPreset/list` — experimental; list the complete resolved permission-preset catalog for an optional `cwd`, using cursor pagination. Each preset includes a stable `id`, exhaustive `kind`, optional `permissionProfileId` and `description`, resolved sandbox/approval/reviewer settings, and structured availability metadata. The response also identifies one allowed `defaultPresetId` and its `defaultSource`. Disallowed and equivalently resolved presets remain in the catalog so clients can preserve explicit selection identity without reconstructing permission policy.
|
||||
- `experimentalFeature/enablement/set` — patch the in-memory process-wide runtime feature enablement for currently supported feature keys. For each feature, precedence is: cloud requirements > --enable <feature_name> > config.toml > experimentalFeature/enablement/set (new) > code default. Invalid keys will be ignored.
|
||||
- `environment/add` — experimental; add or replace a named remote environment by `environmentId` and `execServerUrl` for later selection by `thread/start` or `turn/start`; optional `connectTimeoutMs` overrides the WebSocket connection timeout; returns `{}` and does not change the default environment.
|
||||
- `collaborationMode/list` — list available collaboration mode presets (experimental, no pagination). Built-in presets do not select a model; the Plan preset selects medium reasoning effort. This response omits built-in developer instructions; clients should either pass `settings.developer_instructions: null` when setting a mode to use Codex's built-in instructions, or provide their own instructions explicitly.
|
||||
|
||||
@@ -47,6 +47,7 @@ use std::path::PathBuf;
|
||||
|
||||
const SUPPORTED_EXPERIMENTAL_FEATURE_ENABLEMENT: &[&str] = &[
|
||||
"auth_elicitation",
|
||||
"guardian_approval",
|
||||
"memories",
|
||||
"mentions_v2",
|
||||
"remote_control",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::Result;
|
||||
@@ -5,6 +6,8 @@ use app_test_support::TestAppServer;
|
||||
use app_test_support::to_response;
|
||||
use codex_app_server_protocol::ApprovalsReviewer;
|
||||
use codex_app_server_protocol::AskForApproval;
|
||||
use codex_app_server_protocol::ExperimentalFeatureEnablementSetParams;
|
||||
use codex_app_server_protocol::ExperimentalFeatureEnablementSetResponse;
|
||||
use codex_app_server_protocol::JSONRPCResponse;
|
||||
use codex_app_server_protocol::PermissionPreset;
|
||||
use codex_app_server_protocol::PermissionPresetDefaultSource;
|
||||
@@ -98,6 +101,49 @@ guardian_approval = true
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn permission_preset_list_uses_runtime_guardian_enablement() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
let mut mcp = TestAppServer::new(codex_home.path()).await?;
|
||||
timeout(DEFAULT_TIMEOUT, mcp.initialize()).await??;
|
||||
|
||||
let enablement = BTreeMap::from([("guardian_approval".to_string(), false)]);
|
||||
let request_id = mcp
|
||||
.send_experimental_feature_enablement_set_request(
|
||||
ExperimentalFeatureEnablementSetParams {
|
||||
enablement: enablement.clone(),
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
let response: JSONRPCResponse = timeout(
|
||||
DEFAULT_TIMEOUT,
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(request_id)),
|
||||
)
|
||||
.await??;
|
||||
assert_eq!(
|
||||
to_response::<ExperimentalFeatureEnablementSetResponse>(response)?,
|
||||
ExperimentalFeatureEnablementSetResponse { enablement }
|
||||
);
|
||||
|
||||
let actual = list_permission_presets(
|
||||
&mut mcp,
|
||||
PermissionPresetListParams {
|
||||
cursor: None,
|
||||
limit: None,
|
||||
cwd: None,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
assert!(
|
||||
actual
|
||||
.data
|
||||
.iter()
|
||||
.all(|preset| preset.kind != PermissionPresetKind::GuardianApprovals)
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn permission_preset_list_keeps_allowed_config_default_provenance() -> Result<()> {
|
||||
let actual = list_permission_presets_from_config(
|
||||
|
||||
Reference in New Issue
Block a user