mirror of
https://github.com/openai/codex.git
synced 2026-11-19 22:30:42 +00:00
fix(plugins): close host capability gating gaps
This commit is contained in:
@@ -98,7 +98,8 @@ Clients declare host features available to runtime plugins with
|
||||
compatibility signals, not authorization grants; omitted or `null`
|
||||
capabilities are treated as an empty set. The capability set is fixed for the
|
||||
lifetime of a loaded thread, so clients must use the same set when resuming or
|
||||
starting turns on that thread.
|
||||
performing model-visible runtime operations on that thread. Capability-independent
|
||||
settings updates remain available; the next `turn/start` enforces compatibility.
|
||||
|
||||
Plugin manifests declare all-of host requirements with
|
||||
`{"requires":{"hostCapabilities":["codex.inline_visualization"]}}`. A plugin
|
||||
@@ -1835,7 +1836,7 @@ Use `app/list` to fetch available apps (connectors). Each entry includes metadat
|
||||
} }
|
||||
```
|
||||
|
||||
When `threadId` is provided, app feature gating (`Feature::Apps`) is evaluated using that thread's config snapshot. When omitted, the latest global config is used.
|
||||
When `threadId` is provided, app feature gating (`Feature::Apps`) is evaluated using that thread's config snapshot, and the requesting connection must have the same host capability set as the loaded thread. When omitted, the latest global config is used.
|
||||
|
||||
`app/list` returns after both accessible apps and directory apps are loaded. Set `forceRefetch: true` to bypass app caches and fetch fresh data from sources. Cache entries are only replaced when those refetches succeed.
|
||||
|
||||
|
||||
@@ -1136,7 +1136,12 @@ impl MessageProcessor {
|
||||
}
|
||||
ClientRequest::ThreadRollback { params, .. } => {
|
||||
self.thread_processor
|
||||
.thread_rollback(&request_id, params, app_server_client_info.name.as_deref())
|
||||
.thread_rollback(
|
||||
&request_id,
|
||||
params,
|
||||
app_server_client_info.name.as_deref(),
|
||||
host_capabilities.clone(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
ClientRequest::ThreadList { params, .. } => {
|
||||
@@ -1280,7 +1285,7 @@ impl MessageProcessor {
|
||||
}
|
||||
ClientRequest::TurnInterrupt { params, .. } => {
|
||||
self.turn_processor
|
||||
.turn_interrupt(&request_id, params)
|
||||
.turn_interrupt(&request_id, params, host_capabilities.clone())
|
||||
.await
|
||||
}
|
||||
ClientRequest::ThreadRealtimeStart { params, .. } => {
|
||||
|
||||
@@ -52,7 +52,14 @@ impl AppsRequestProcessor {
|
||||
let installed_start = Instant::now();
|
||||
let reload = params.force_refetch;
|
||||
let thread = if let Some(thread_id) = params.thread_id.as_deref() {
|
||||
let (_, loaded_thread) = self.load_thread(thread_id).await?;
|
||||
let (thread_id, loaded_thread) = self.load_thread(thread_id).await?;
|
||||
ensure_thread_host_capabilities(
|
||||
thread_id,
|
||||
loaded_thread.as_ref(),
|
||||
&host_capabilities,
|
||||
"list apps",
|
||||
)
|
||||
.await?;
|
||||
Some(loaded_thread)
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -669,12 +669,13 @@ impl ThreadRequestProcessor {
|
||||
request_id: &ConnectionRequestId,
|
||||
params: ThreadRollbackParams,
|
||||
app_server_client_name: Option<&str>,
|
||||
host_capabilities: HostCapabilities,
|
||||
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
|
||||
if app_server_client_name != Some(CODEX_TUI_CLIENT_NAME) {
|
||||
self.send_thread_rollback_deprecation_notice(request_id.connection_id)
|
||||
.await;
|
||||
}
|
||||
self.thread_rollback_inner(request_id, params)
|
||||
self.thread_rollback_inner(request_id, params, host_capabilities)
|
||||
.await
|
||||
.map(|()| None)
|
||||
}
|
||||
@@ -1750,14 +1751,17 @@ impl ThreadRequestProcessor {
|
||||
&self,
|
||||
request_id: &ConnectionRequestId,
|
||||
params: ThreadRollbackParams,
|
||||
host_capabilities: HostCapabilities,
|
||||
) -> Result<(), JSONRPCErrorError> {
|
||||
self.thread_rollback_start(request_id, params).await
|
||||
self.thread_rollback_start(request_id, params, host_capabilities)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn thread_rollback_start(
|
||||
&self,
|
||||
request_id: &ConnectionRequestId,
|
||||
params: ThreadRollbackParams,
|
||||
host_capabilities: HostCapabilities,
|
||||
) -> Result<(), JSONRPCErrorError> {
|
||||
let ThreadRollbackParams {
|
||||
thread_id,
|
||||
@@ -1769,6 +1773,13 @@ impl ThreadRequestProcessor {
|
||||
}
|
||||
|
||||
let (thread_id, thread) = self.load_thread(&thread_id).await?;
|
||||
ensure_thread_host_capabilities(
|
||||
thread_id,
|
||||
thread.as_ref(),
|
||||
&host_capabilities,
|
||||
"roll back",
|
||||
)
|
||||
.await?;
|
||||
|
||||
let request = request_id.clone();
|
||||
|
||||
|
||||
@@ -208,8 +208,9 @@ impl TurnRequestProcessor {
|
||||
&self,
|
||||
request_id: &ConnectionRequestId,
|
||||
params: TurnInterruptParams,
|
||||
host_capabilities: HostCapabilities,
|
||||
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
|
||||
self.turn_interrupt_inner(request_id, params)
|
||||
self.turn_interrupt_inner(request_id, params, host_capabilities)
|
||||
.await
|
||||
.map(|response| response.map(Into::into))
|
||||
}
|
||||
@@ -1389,11 +1390,19 @@ impl TurnRequestProcessor {
|
||||
&self,
|
||||
request_id: &ConnectionRequestId,
|
||||
params: TurnInterruptParams,
|
||||
host_capabilities: HostCapabilities,
|
||||
) -> Result<Option<TurnInterruptResponse>, JSONRPCErrorError> {
|
||||
let TurnInterruptParams { thread_id, turn_id } = params;
|
||||
let is_startup_interrupt = turn_id.is_empty();
|
||||
|
||||
let (thread_uuid, thread) = self.load_thread(&thread_id).await?;
|
||||
ensure_thread_host_capabilities(
|
||||
thread_uuid,
|
||||
thread.as_ref(),
|
||||
&host_capabilities,
|
||||
"interrupt a turn",
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Record turn interrupts so we can reply when TurnAborted arrives. Startup
|
||||
// interrupts do not have a turn and are acknowledged after submission.
|
||||
|
||||
@@ -356,6 +356,68 @@ async fn host_capabilities_are_normalized_and_sticky_for_loaded_threads() -> Res
|
||||
inject_error.error.message
|
||||
);
|
||||
|
||||
send_request(
|
||||
&mut mismatched_client,
|
||||
"app/list",
|
||||
/*id*/ 11,
|
||||
Some(json!({
|
||||
"threadId": thread_id,
|
||||
})),
|
||||
)
|
||||
.await?;
|
||||
let apps_error = read_error_for_id(&mut mismatched_client, /*id*/ 11)
|
||||
.await
|
||||
.context("mismatched-client app/list error")?;
|
||||
assert!(apps_error.error.message.contains("cannot list apps"));
|
||||
|
||||
send_request(
|
||||
&mut mismatched_client,
|
||||
"thread/rollback",
|
||||
/*id*/ 12,
|
||||
Some(json!({
|
||||
"threadId": thread_id,
|
||||
"numTurns": 1,
|
||||
})),
|
||||
)
|
||||
.await?;
|
||||
let rollback_error = read_error_for_id(&mut mismatched_client, /*id*/ 12)
|
||||
.await
|
||||
.context("mismatched-client thread/rollback error")?;
|
||||
assert!(rollback_error.error.message.contains("cannot roll back"));
|
||||
|
||||
send_request(
|
||||
&mut mismatched_client,
|
||||
"turn/interrupt",
|
||||
/*id*/ 13,
|
||||
Some(json!({
|
||||
"threadId": thread_id,
|
||||
"turnId": "turn-under-test",
|
||||
})),
|
||||
)
|
||||
.await?;
|
||||
let interrupt_error = read_error_for_id(&mut mismatched_client, /*id*/ 13)
|
||||
.await
|
||||
.context("mismatched-client turn/interrupt error")?;
|
||||
assert!(
|
||||
interrupt_error
|
||||
.error
|
||||
.message
|
||||
.contains("cannot interrupt a turn")
|
||||
);
|
||||
|
||||
send_request(
|
||||
&mut mismatched_client,
|
||||
"thread/settings/update",
|
||||
/*id*/ 14,
|
||||
Some(json!({
|
||||
"threadId": thread_id,
|
||||
})),
|
||||
)
|
||||
.await?;
|
||||
read_response_for_id(&mut mismatched_client, /*id*/ 14)
|
||||
.await
|
||||
.context("mismatched-client thread/settings/update response")?;
|
||||
|
||||
process
|
||||
.kill()
|
||||
.await
|
||||
@@ -951,7 +1013,13 @@ pub(super) async fn send_initialize_request(
|
||||
id: i64,
|
||||
client_name: &str,
|
||||
) -> Result<()> {
|
||||
send_initialize_request_with_host_capabilities(stream, id, client_name, None).await
|
||||
send_initialize_request_with_host_capabilities(
|
||||
stream,
|
||||
id,
|
||||
client_name,
|
||||
/*host_capabilities*/ None,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn send_initialize_request_with_host_capabilities(
|
||||
|
||||
Reference in New Issue
Block a user