mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
566f7bf631
Responses API safety buffering metadata currently stops at the transport boundary, so app-server clients cannot render the in-progress safety review state. This change: - decodes and deduplicates `safety_buffering` metadata from Responses API SSE and WebSocket events without suppressing the original response event - emits a typed core event containing the requested model plus backend use cases and reasons - forwards that event as `turn/safetyBuffering/updated` through app-server v2 and updates generated protocol schemas - keeps the side-channel event out of persisted rollouts and turn timing This supports the Codex Apps buffering UX and depends on the Responses API backend work in https://github.com/openai/openai/pull/1044569 and https://github.com/openai/openai/pull/1044571. Validation: - focused `codex-core` safety-buffering integration test passes - `cargo check -p codex-core -p codex-app-server -p codex-app-server-protocol` - `just fix -p codex-api -p codex-protocol -p codex-core -p codex-app-server-protocol -p codex-app-server -p codex-rollout -p codex-rollout-trace -p codex-otel` - `just fmt` - broad package test run: 4,430/4,492 passed; 62 unrelated local-environment/concurrency failures involved unavailable test binaries, MCP subprocess setup, and app-server timeouts
176 lines
5.6 KiB
Rust
176 lines
5.6 KiB
Rust
use super::shared::v2_enum_from_core;
|
|
use codex_protocol::openai_models::InputModality;
|
|
use codex_protocol::openai_models::ModelAvailabilityNux as CoreModelAvailabilityNux;
|
|
use codex_protocol::openai_models::ReasoningEffort;
|
|
use codex_protocol::openai_models::default_input_modalities;
|
|
use codex_protocol::protocol::ModelRerouteReason as CoreModelRerouteReason;
|
|
use codex_protocol::protocol::ModelVerification as CoreModelVerification;
|
|
use schemars::JsonSchema;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
use serde_json::Value as JsonValue;
|
|
use ts_rs::TS;
|
|
|
|
v2_enum_from_core!(
|
|
pub enum ModelRerouteReason from CoreModelRerouteReason {
|
|
HighRiskCyberActivity
|
|
}
|
|
);
|
|
|
|
v2_enum_from_core!(
|
|
pub enum ModelVerification from CoreModelVerification {
|
|
TrustedAccessForCyber
|
|
}
|
|
);
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ModelProviderCapabilitiesReadParams {}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ModelProviderCapabilitiesReadResponse {
|
|
pub namespace_tools: bool,
|
|
pub image_generation: bool,
|
|
pub web_search: bool,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ModelListParams {
|
|
/// Opaque pagination cursor returned by a previous call.
|
|
#[ts(optional = nullable)]
|
|
pub cursor: Option<String>,
|
|
/// Optional page size; defaults to a reasonable server-side value.
|
|
#[ts(optional = nullable)]
|
|
pub limit: Option<u32>,
|
|
/// When true, include models that are hidden from the default picker list.
|
|
#[ts(optional = nullable)]
|
|
pub include_hidden: Option<bool>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ModelAvailabilityNux {
|
|
pub message: String,
|
|
}
|
|
|
|
impl From<CoreModelAvailabilityNux> for ModelAvailabilityNux {
|
|
fn from(value: CoreModelAvailabilityNux) -> Self {
|
|
Self {
|
|
message: value.message,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ModelServiceTier {
|
|
pub id: String,
|
|
pub name: String,
|
|
pub description: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct Model {
|
|
pub id: String,
|
|
pub model: String,
|
|
pub upgrade: Option<String>,
|
|
pub upgrade_info: Option<ModelUpgradeInfo>,
|
|
pub availability_nux: Option<ModelAvailabilityNux>,
|
|
pub display_name: String,
|
|
pub description: String,
|
|
pub hidden: bool,
|
|
pub supported_reasoning_efforts: Vec<ReasoningEffortOption>,
|
|
pub default_reasoning_effort: ReasoningEffort,
|
|
#[serde(default = "default_input_modalities")]
|
|
pub input_modalities: Vec<InputModality>,
|
|
#[serde(default)]
|
|
pub supports_personality: bool,
|
|
/// Deprecated: use `serviceTiers` instead.
|
|
#[serde(default)]
|
|
pub additional_speed_tiers: Vec<String>,
|
|
#[serde(default)]
|
|
pub service_tiers: Vec<ModelServiceTier>,
|
|
/// Catalog default service tier id for this model, when one is configured.
|
|
#[serde(default)]
|
|
pub default_service_tier: Option<String>,
|
|
// Only one model should be marked as default.
|
|
pub is_default: bool,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ModelUpgradeInfo {
|
|
pub model: String,
|
|
pub upgrade_copy: Option<String>,
|
|
pub model_link: Option<String>,
|
|
pub migration_markdown: Option<String>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ReasoningEffortOption {
|
|
pub reasoning_effort: ReasoningEffort,
|
|
pub description: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ModelListResponse {
|
|
pub data: Vec<Model>,
|
|
/// Opaque cursor to pass to the next call to continue after the last item.
|
|
/// If None, there are no more items to return.
|
|
pub next_cursor: Option<String>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ModelReroutedNotification {
|
|
pub thread_id: String,
|
|
pub turn_id: String,
|
|
pub from_model: String,
|
|
pub to_model: String,
|
|
pub reason: ModelRerouteReason,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ModelVerificationNotification {
|
|
pub thread_id: String,
|
|
pub turn_id: String,
|
|
pub verifications: Vec<ModelVerification>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct TurnModerationMetadataNotification {
|
|
pub thread_id: String,
|
|
pub turn_id: String,
|
|
pub metadata: JsonValue,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ModelSafetyBufferingUpdatedNotification {
|
|
pub thread_id: String,
|
|
pub turn_id: String,
|
|
pub model: String,
|
|
pub use_cases: Vec<String>,
|
|
pub reasons: Vec<String>,
|
|
}
|