aKode fase 2b-2: rimosso login ChatGPT e tutti i sottosistemi solo-ChatGPT

- Login: resta solo chiave API (+ header, Bedrock). Rimossi OAuth/browser,
  device code, refresh/revoke su auth.openai.com, PAT, agent/workload identity,
  runtime agent instance, backend-client e openapi-models, workspace routing.
- Rimossi: generazione immagini (ext + skill imagegen), history notes, plugin
  remoti (catalogo, sync, share), cyber access program, daybreak, cloud config
  e requirements (config_server ora fail-closed), attestation, frozen cloud
  skills, EMA MCP auth, Codex Apps/connettori, ricerca ospitata, header/zstd/
  routing/cookie del backend Codex, fallback OPENAI_API_KEY del realtime.
- Messaggi d'errore senza link a chatgpt.com.
- Chiavi di config legacy accettate e ignorate; feature rimosse = Stage::Removed.
- Test: cancellati solo quelli del codice rimosso; test di sicurezza
  (sandbox estensioni, permessi, redazione, auth storage, requirements)
  adattati. Restano solo fallimenti d'ambiente (code-mode-host/V8, ~/.agents).
- Istruzioni di sistema invariate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-10 16:20:15 +01:00
parent 82347a58ed
commit 6089fbde91
1573 changed files with 10289 additions and 177679 deletions

View File

@@ -52,10 +52,6 @@ pub enum PlanType {
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ProviderAccount {
ApiKey,
Chatgpt {
email: Option<String>,
plan_type: PlanType,
},
AmazonBedrock {
uses_codex_managed_credentials: bool,
},

View File

@@ -3,30 +3,16 @@ use serde::Serialize;
use strum_macros::Display;
use thiserror::Error;
/// Authentication mode for OpenAI-backed providers.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Display, Serialize, Deserialize)]
/// Authentication mode for stored or host-supplied provider credentials.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum AuthMode {
/// OpenAI API key provided by the caller and stored by Codex.
/// Provider API key supplied by the caller and stored by Codex.
ApiKey,
/// ChatGPT OAuth managed by Codex (tokens persisted and refreshed by Codex).
Chatgpt,
/// ChatGPT auth tokens supplied by an external host application.
#[serde(rename = "chatgptAuthTokens")]
#[strum(serialize = "chatgptAuthTokens")]
ChatgptAuthTokens,
/// Codex backend auth supplied as request headers.
/// Provider auth supplied as request headers by a host application.
#[serde(rename = "headers")]
#[strum(serialize = "headers")]
Headers,
/// Programmatic Codex auth backed by a registered Agent Identity.
#[serde(rename = "agentIdentity")]
#[strum(serialize = "agentIdentity")]
AgentIdentity,
/// Programmatic Codex auth backed by a personal access token.
#[serde(rename = "personalAccessToken")]
#[strum(serialize = "personalAccessToken")]
PersonalAccessToken,
/// Amazon Bedrock bearer token managed by Codex.
#[serde(rename = "bedrockApiKey")]
#[strum(serialize = "bedrockApiKey")]
@@ -37,32 +23,6 @@ pub enum AuthMode {
BedrockAccessKeys,
}
impl AuthMode {
/// Returns whether this mode represents an authenticated human ChatGPT account.
pub fn has_chatgpt_account(self) -> bool {
match self {
Self::Chatgpt | Self::ChatgptAuthTokens | Self::PersonalAccessToken => true,
Self::ApiKey
| Self::Headers
| Self::AgentIdentity
| Self::BedrockApiKey
| Self::BedrockAccessKeys => false,
}
}
/// Returns whether this mode is backed by Codex services rather than a direct model API.
pub fn uses_codex_backend(self) -> bool {
match self {
Self::Chatgpt
| Self::ChatgptAuthTokens
| Self::Headers
| Self::AgentIdentity
| Self::PersonalAccessToken => true,
Self::ApiKey | Self::BedrockApiKey | Self::BedrockAccessKeys => false,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PlanType {

View File

@@ -1,5 +1,4 @@
use crate::ThreadId;
use crate::auth::KnownPlan;
use crate::auth::PlanType;
pub use crate::auth::RefreshTokenFailedError;
pub use crate::auth::RefreshTokenFailedReason;
@@ -197,9 +196,7 @@ pub enum CodexErrorDetails {
ConnectionFailed(ConnectionFailedError),
#[error("Quota exceeded. Check your plan and billing details.")]
QuotaExceeded,
#[error(
"To use Codex with your ChatGPT plan, upgrade to Plus: https://chatgpt.com/explore/plus."
)]
#[error("Your model provider account does not include access to this model.")]
UsageNotIncluded,
#[error("We’re currently experiencing high demand, which may cause temporary errors.")]
InternalServerError,
@@ -788,7 +785,7 @@ pub struct UsageLimitReachedError {
impl std::fmt::Display for UsageLimitReachedError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// Reserve is a fallback for exhausted ordinary usage, so keep the standard
// promo/plan recovery copy below instead of suggesting another model.
// recovery copy below instead of suggesting another model.
if let Some(limit_name) = self
.rate_limits
.as_ref()
@@ -832,63 +829,16 @@ impl std::fmt::Display for UsageLimitReachedError {
);
}
RateLimitReachedType::RateLimitReached => {
// Generic limits intentionally use the existing promo or plan copy below.
// Generic limits use the neutral copy below.
}
}
}
if let Some(promo_message) = &self.promo_message {
return write!(
f,
"You’ve hit your usage limit. {promo_message},{}",
retry_suffix_after_or(self.resets_at.as_ref())
);
}
let message = match self.plan_type.as_ref() {
Some(PlanType::Known(KnownPlan::Plus)) => format!(
"You’ve hit your usage limit. Upgrade to Pro (https://chatgpt.com/explore/pro), visit https://chatgpt.com/settings/usage to purchase more credits{}",
retry_suffix_after_or(self.resets_at.as_ref())
),
Some(PlanType::Known(
KnownPlan::Team
| KnownPlan::SelfServeBusinessProLite
| KnownPlan::SelfServeBusinessUsageBased
| KnownPlan::Business
| KnownPlan::Ent26
| KnownPlan::EnterpriseCbpAutomation
| KnownPlan::EnterpriseCbpUsageBased
| KnownPlan::Sci
| KnownPlan::SciPlus,
)) => {
format!(
"You’ve hit your usage limit. To get more access now, send a request to your admin{}",
retry_suffix_after_or(self.resets_at.as_ref())
)
}
Some(PlanType::Known(KnownPlan::Free)) | Some(PlanType::Known(KnownPlan::Go)) => {
format!(
"You’ve hit your usage limit. Upgrade to Plus to continue using Codex (https://chatgpt.com/explore/plus),{}",
retry_suffix_after_or(self.resets_at.as_ref())
)
}
Some(PlanType::Known(KnownPlan::Pro | KnownPlan::ProLite | KnownPlan::ProMax)) => {
format!(
"You’ve hit your usage limit. Visit https://chatgpt.com/settings/usage to purchase more credits{}",
retry_suffix_after_or(self.resets_at.as_ref())
)
}
Some(PlanType::Known(
KnownPlan::Enterprise | KnownPlan::Edu | KnownPlan::EduPlus | KnownPlan::EduPro,
)) => format!(
"You’ve hit your usage limit.{}",
retry_suffix(self.resets_at.as_ref())
),
Some(PlanType::Unknown(_)) | None => format!(
"You’ve hit your usage limit.{}",
retry_suffix(self.resets_at.as_ref())
),
};
// Plan upsells and server promo copy are ChatGPT-specific; keep the message neutral.
let message = format!(
"You’ve hit your usage limit with the model provider.{}",
retry_suffix(self.resets_at.as_ref())
);
write!(f, "{message}")
}

View File

@@ -1,4 +1,5 @@
use super::*;
use crate::auth::KnownPlan;
use crate::exec_output::StreamOutput;
use crate::protocol::RateLimitWindow;
use chrono::DateTime;
@@ -166,7 +167,7 @@ fn usage_limit_reached_error_formats_plus_plan() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. Upgrade to Pro (https://chatgpt.com/explore/pro), visit https://chatgpt.com/settings/usage to purchase more credits or try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
@@ -175,7 +176,7 @@ fn usage_limit_reached_error_formats_rate_limit_reached_types() {
let cases = [
(
RateLimitReachedType::RateLimitReached,
"You’ve hit your usage limit. Upgrade to Pro (https://chatgpt.com/explore/pro), visit https://chatgpt.com/settings/usage to purchase more credits or try again later.",
"You’ve hit your usage limit with the model provider. Try again later.",
),
(
RateLimitReachedType::WorkspaceOwnerCreditsDepleted,
@@ -330,7 +331,7 @@ fn usage_limit_reached_error_formats_free_plan() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. Upgrade to Plus to continue using Codex (https://chatgpt.com/explore/plus), or try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
@@ -346,7 +347,7 @@ fn usage_limit_reached_error_formats_go_plan() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. Upgrade to Plus to continue using Codex (https://chatgpt.com/explore/plus), or try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
@@ -362,7 +363,7 @@ fn usage_limit_reached_error_formats_default_when_none() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. Try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
@@ -381,7 +382,7 @@ fn usage_limit_reached_error_formats_team_plan() {
rate_limit_reached_type: None,
};
let expected = format!(
"You’ve hit your usage limit. To get more access now, send a request to your admin or try again at {expected_time}."
"You’ve hit your usage limit with the model provider. Try again at {expected_time}."
);
assert_eq!(err.to_string(), expected);
});
@@ -404,7 +405,7 @@ fn usage_limit_reached_error_formats_business_plan_without_reset() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. To get more access now, send a request to your admin or try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
}
@@ -421,7 +422,7 @@ fn usage_limit_reached_error_formats_self_serve_business_prolite_plan() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. To get more access now, send a request to your admin or try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
@@ -437,7 +438,7 @@ fn usage_limit_reached_error_formats_self_serve_business_usage_based_plan() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. To get more access now, send a request to your admin or try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
@@ -453,7 +454,7 @@ fn usage_limit_reached_error_formats_enterprise_cbp_usage_based_plan() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. To get more access now, send a request to your admin or try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
@@ -475,7 +476,7 @@ fn usage_limit_reached_error_formats_default_for_other_plans() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. Try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
}
@@ -495,7 +496,7 @@ fn usage_limit_reached_error_formats_pro_plan_with_reset() {
rate_limit_reached_type: None,
};
let expected = format!(
"You’ve hit your usage limit. Visit https://chatgpt.com/settings/usage to purchase more credits or try again at {expected_time}."
"You’ve hit your usage limit with the model provider. Try again at {expected_time}."
);
assert_eq!(err.to_string(), expected);
});
@@ -516,9 +517,7 @@ fn usage_limit_reached_error_hides_upsell_for_non_codex_limit_name() {
limit_name: Some("codex_other".to_string()),
..rate_limit_snapshot()
})),
promo_message: Some(
"Visit https://chatgpt.com/settings/usage to purchase more credits".to_string(),
),
promo_message: Some("Server promo copy".to_string()),
rate_limit_reached_type: None,
};
let expected = format!(
@@ -542,7 +541,9 @@ fn usage_limit_reached_includes_minutes_when_available() {
promo_message: None,
rate_limit_reached_type: None,
};
let expected = format!("You’ve hit your usage limit. Try again at {expected_time}.");
let expected = format!(
"You’ve hit your usage limit with the model provider. Try again at {expected_time}."
);
assert_eq!(err.to_string(), expected);
});
}
@@ -593,7 +594,7 @@ fn unexpected_status_prefers_error_message_when_present() {
body: r#"{"error":{"message":"Workspace is not authorized in this region."},"status":401}"#
.to_string(),
user_message: None,
url: Some("https://chatgpt.com/backend-api/codex/responses".to_string()),
url: Some("https://api.example.com/v1/responses".to_string()),
cf_ray: None,
request_id: Some("req-123".to_string()),
identity_authorization_error: None,
@@ -603,7 +604,7 @@ fn unexpected_status_prefers_error_message_when_present() {
assert_eq!(
err.to_string(),
format!(
"unexpected status {status}: Workspace is not authorized in this region., url: https://chatgpt.com/backend-api/codex/responses, request id: req-123"
"unexpected status {status}: Workspace is not authorized in this region., url: https://api.example.com/v1/responses, request id: req-123"
)
);
}
@@ -637,7 +638,7 @@ fn unexpected_status_includes_cf_ray_and_request_id() {
status: StatusCode::UNAUTHORIZED,
body: "plain text error".to_string(),
user_message: None,
url: Some("https://chatgpt.com/backend-api/codex/responses".to_string()),
url: Some("https://api.example.com/v1/responses".to_string()),
cf_ray: Some("9c81f9f18f2fa49d-LHR".to_string()),
request_id: Some("req-xyz".to_string()),
identity_authorization_error: None,
@@ -647,7 +648,7 @@ fn unexpected_status_includes_cf_ray_and_request_id() {
assert_eq!(
err.to_string(),
format!(
"unexpected status {status}: plain text error, url: https://chatgpt.com/backend-api/codex/responses, cf-ray: 9c81f9f18f2fa49d-LHR, request id: req-xyz"
"unexpected status {status}: plain text error, url: https://api.example.com/v1/responses, cf-ray: 9c81f9f18f2fa49d-LHR, request id: req-xyz"
)
);
}
@@ -658,7 +659,7 @@ fn unexpected_status_includes_identity_auth_details() {
status: StatusCode::UNAUTHORIZED,
body: "plain text error".to_string(),
user_message: None,
url: Some("https://chatgpt.com/backend-api/codex/models".to_string()),
url: Some("https://api.example.com/v1/models".to_string()),
cf_ray: Some("cf-ray-auth-401-test".to_string()),
request_id: Some("req-auth".to_string()),
identity_authorization_error: Some("missing_authorization_header".to_string()),
@@ -668,7 +669,7 @@ fn unexpected_status_includes_identity_auth_details() {
assert_eq!(
err.to_string(),
format!(
"unexpected status {status}: plain text error, url: https://chatgpt.com/backend-api/codex/models, cf-ray: cf-ray-auth-401-test, request id: req-auth, auth error: missing_authorization_header, auth error code: token_expired"
"unexpected status {status}: plain text error, url: https://api.example.com/v1/models, cf-ray: cf-ray-auth-401-test, request id: req-auth, auth error: missing_authorization_header, auth error code: token_expired"
)
);
}
@@ -688,7 +689,7 @@ fn usage_limit_reached_includes_hours_and_minutes() {
rate_limit_reached_type: None,
};
let expected = format!(
"You’ve hit your usage limit. Upgrade to Pro (https://chatgpt.com/explore/pro), visit https://chatgpt.com/settings/usage to purchase more credits or try again at {expected_time}."
"You’ve hit your usage limit with the model provider. Try again at {expected_time}."
);
assert_eq!(err.to_string(), expected);
});
@@ -709,7 +710,9 @@ fn usage_limit_reached_includes_days_hours_minutes() {
promo_message: None,
rate_limit_reached_type: None,
};
let expected = format!("You’ve hit your usage limit. Try again at {expected_time}.");
let expected = format!(
"You’ve hit your usage limit with the model provider. Try again at {expected_time}."
);
assert_eq!(err.to_string(), expected);
});
}
@@ -728,13 +731,15 @@ fn usage_limit_reached_less_than_minute() {
promo_message: None,
rate_limit_reached_type: None,
};
let expected = format!("You’ve hit your usage limit. Try again at {expected_time}.");
let expected = format!(
"You’ve hit your usage limit with the model provider. Try again at {expected_time}."
);
assert_eq!(err.to_string(), expected);
});
}
#[test]
fn usage_limit_reached_with_promo_message() {
fn usage_limit_reached_ignores_server_promo_message() {
let base = Utc.with_ymd_and_hms(2024, 1, 1, 0, 0, 0).unwrap();
let resets_at = base + ChronoDuration::seconds(30);
with_now_override(base, move || {
@@ -750,7 +755,7 @@ fn usage_limit_reached_with_promo_message() {
rate_limit_reached_type: None,
};
let expected = format!(
"You’ve hit your usage limit. To continue using Codex, start a free trial of <PLAN> today, or try again at {expected_time}."
"You’ve hit your usage limit with the model provider. Try again at {expected_time}."
);
assert_eq!(err.to_string(), expected);
});

View File

@@ -163,9 +163,6 @@ pub struct AgentMessageDisplay {
pub block_type: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub cyber_trusted_access: Option<bool>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub check_trusted_contacts: Option<bool>,
}

View File

@@ -34,22 +34,12 @@ pub const OPENAI_STANDARD_FORM_INPUT_EXTENSION_ID: &str = "openai/standard-form-
pub const MCP_APP_UI_EXTENSION_ID: &str = "io.modelcontextprotocol/ui";
/// Host-supplied confirmation-policy documents for Node REPL-backed actor calls.
pub const CONFIRMATION_POLICIES_META_KEY: &str = "openai/confirmation_policies";
/// Extension ID for enterprise-managed MCP authorization via ID-JAG.
pub const ENTERPRISE_MANAGED_AUTHORIZATION_EXTENSION_ID: &str =
"io.modelcontextprotocol/enterprise-managed-authorization";
/// Returns whether a raw MCP server name identifies a Node REPL-backed server.
pub fn is_node_repl_backed_server(server: &str) -> bool {
matches!(server, "node_repl" | "cua_repl")
}
/// Returns whether an MCP server or registered connector is Node REPL-backed.
/// Callers must supply connector identity from registered tool metadata, never
/// from tool arguments or provider-supplied elicitation metadata.
pub fn is_node_repl_backed_connector(server: &str, connector_id: Option<&str>) -> bool {
is_node_repl_backed_server(server)
|| server == "codex_apps" && connector_id == Some("connector_openai_browser")
}
/// Recognizes Node REPL-backed tools in model-visible MCP namespaces or legacy
/// flat tool names. An explicit namespace takes precedence over the tool name.

View File

@@ -33,7 +33,6 @@ use crate::config_types::ServiceTier;
use crate::config_types::Verbosity;
use crate::protocol::MultiAgentVersion;
mod access_programs;
mod incremental_tools;
pub use incremental_tools::IncrementalToolMessages;
#[path = "openai_models/memento_v2.rs"]
@@ -58,14 +57,10 @@ mod guardian_v2;
#[path = "openai_models/reasoning_effort.rs"]
mod reasoning_effort;
pub use access_programs::ModelAccessPrograms;
pub use access_programs::SavedDaybreakChoice;
pub use guardian_v2::AsyncClassifierMode;
pub use guardian_v2::GuardianV2ModelConfig;
pub use guardian_v2::GuardianV2TranscriptModelConfig;
/// Backend model-catalog specialty identifying cybersecurity-focused models.
pub const MODEL_SPECIALTY_CYBER: &str = "cyber";
pub const SPEED_TIER_FAST: &str = "fast";
/// See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning
@@ -275,9 +270,6 @@ pub struct ModelPreset {
/// Catalog default service tier id for this model.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub default_service_tier: Option<String>,
/// Caller-specific explicit access programs, when discovery resolved them.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub available_access_programs: Option<ModelAccessPrograms>,
/// Whether this is the default model for new users.
pub is_default: bool,
/// recommended upgrade model
@@ -447,8 +439,6 @@ pub struct ModelInfo {
pub service_tiers: Vec<ModelServiceTier>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub default_service_tier: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub available_access_programs: Option<ModelAccessPrograms>,
pub availability_nux: Option<ModelAvailabilityNux>,
pub upgrade: Option<ModelInfoUpgrade>,
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -820,8 +810,6 @@ pub struct CodeModeToolMessages {
pub struct ModelTokenBudgetConfig {
#[serde(default)]
pub enabled: bool,
#[serde(default)]
pub use_history_notes_extension: bool,
pub reminder_threshold_tokens: i64,
pub reminder_message_template: String,
pub guidance_message: String,
@@ -1099,7 +1087,6 @@ impl From<ModelInfo> for ModelPreset {
additional_speed_tiers: info.additional_speed_tiers,
service_tiers: info.service_tiers,
default_service_tier: info.default_service_tier,
available_access_programs: info.available_access_programs,
is_default: false, // default is the highest priority available model
upgrade: info.upgrade.as_ref().map(|upgrade| ModelUpgrade {
id: upgrade.model.clone(),
@@ -1211,7 +1198,6 @@ mod tests {
additional_speed_tiers: Vec::new(),
service_tiers: Vec::new(),
default_service_tier: None,
available_access_programs: None,
availability_nux: None,
upgrade: None,
model_messages: spec,
@@ -2197,40 +2183,6 @@ mod tests {
);
}
#[test]
fn model_access_programs_preserve_explicit_selection_availability() {
use crate::turn_input::CyberAccessProgram;
for (metadata, expected) in [
(None, None),
(Some(serde_json::Value::Null), None),
(
Some(serde_json::json!({ "cyber": [] })),
Some(ModelAccessPrograms { cyber: vec![] }),
),
(
Some(serde_json::json!({
"cyber": ["standard", "daybreak_blue", "future_program", "daybreak_red"]
})),
Some(ModelAccessPrograms {
cyber: vec![
CyberAccessProgram::Standard,
CyberAccessProgram::DaybreakBlue,
CyberAccessProgram::DaybreakRed,
],
}),
),
] {
let mut value = serde_json::to_value(test_model(/*spec*/ None)).unwrap();
if let Some(metadata) = metadata {
value["available_access_programs"] = metadata;
}
let model: ModelInfo = serde_json::from_value(value).unwrap();
assert_eq!(model.available_access_programs, expected);
assert_eq!(ModelPreset::from(model).available_access_programs, expected);
}
}
#[test]
fn model_preset_supports_fast_mode_from_service_tiers() {
let preset = ModelPreset::from(ModelInfo {

View File

@@ -1,82 +0,0 @@
//! Caller-specific explicit access programs advertised by the model catalog.
//!
//! Discovery metadata does not grant access; inference still enforces authorization.
use schemars::JsonSchema;
use serde::Deserialize;
use serde::Deserializer;
use serde::Serialize;
use ts_rs::TS;
use crate::turn_input::CyberAccessProgram;
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, TS, JsonSchema)]
pub struct ModelAccessPrograms {
/// Accepted explicit selections. An empty list is distinct from missing metadata.
#[serde(deserialize_with = "deserialize_known_cyber_access_programs")]
pub cyber: Vec<CyberAccessProgram>,
}
/// Saved preference to resolve against the selected model's advertised programs.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SavedDaybreakChoice {
Unset,
On,
Off,
}
impl From<Option<bool>> for SavedDaybreakChoice {
fn from(enabled: Option<bool>) -> Self {
match enabled {
Some(true) => Self::On,
Some(false) => Self::Off,
None => Self::Unset,
}
}
}
impl ModelAccessPrograms {
/// Select only an advertised program for explicit saved intent. Unset and
/// unsupported choices remain omitted, including On without Daybreak support.
pub fn select_saved(&self, choice: SavedDaybreakChoice) -> Option<CyberAccessProgram> {
match choice {
SavedDaybreakChoice::On => self.daybreak(),
SavedDaybreakChoice::Off => self.standard(),
SavedDaybreakChoice::Unset => None,
}
}
/// Select the preferred Daybreak treatment advertised for this model.
pub fn daybreak(&self) -> Option<CyberAccessProgram> {
[
CyberAccessProgram::DaybreakBlue,
CyberAccessProgram::DaybreakRed,
]
.into_iter()
.find(|program| self.cyber.contains(program))
}
/// Select the standard treatment when it is advertised.
pub fn standard(&self) -> Option<CyberAccessProgram> {
self.cyber
.contains(&CyberAccessProgram::Standard)
.then_some(CyberAccessProgram::Standard)
}
}
fn deserialize_known_cyber_access_programs<'de, D>(
deserializer: D,
) -> Result<Vec<CyberAccessProgram>, D::Error>
where
D: Deserializer<'de>,
{
// New server programs must not prevent older clients from loading the catalog.
Ok(Vec::<String>::deserialize(deserializer)?
.into_iter()
.filter_map(|program| serde_json::from_value(serde_json::Value::String(program)).ok())
.collect())
}
#[cfg(test)]
#[path = "access_programs_tests.rs"]
mod tests;

View File

@@ -1,39 +0,0 @@
#![cfg(test)]
use super::ModelAccessPrograms;
use super::SavedDaybreakChoice;
use crate::turn_input::CyberAccessProgram;
use pretty_assertions::assert_eq;
#[test]
fn selects_only_advertised_programs_with_blue_preferred() {
use CyberAccessProgram::*;
for (cyber, expected_daybreak, expected_standard) in [
(
vec![Standard, DaybreakRed, DaybreakBlue],
Some(DaybreakBlue),
Some(Standard),
),
(vec![DaybreakRed], Some(DaybreakRed), None),
(vec![Standard], None, Some(Standard)),
(vec![], None, None),
] {
let programs = ModelAccessPrograms { cyber };
assert_eq!(
(
programs.daybreak(),
programs.standard(),
programs.select_saved(SavedDaybreakChoice::from(Some(true))),
programs.select_saved(SavedDaybreakChoice::from(Some(false))),
programs.select_saved(SavedDaybreakChoice::from(/* enabled */ None)),
),
(
expected_daybreak,
expected_standard,
expected_daybreak,
expected_standard,
None,
)
);
}
}

View File

@@ -8,7 +8,7 @@ use ts_rs::TS;
use super::ModelInfo;
use crate::ToolName;
use crate::mcp::is_node_repl_backed_connector;
use crate::mcp::is_node_repl_backed_server;
use crate::mcp::is_node_repl_backed_tool;
/// How Guardian handles an action when the user selects automatic approval.
@@ -126,12 +126,7 @@ pub enum GuardianScope {
impl GuardianScope {
pub fn for_mcp_server(server: &str) -> Self {
Self::for_mcp_connector(server, /*connector_id*/ None)
}
/// Classifies an MCP call using connector identity from registered tool metadata.
pub fn for_mcp_connector(server: &str, connector_id: Option<&str>) -> Self {
if is_node_repl_backed_connector(server, connector_id) {
if is_node_repl_backed_server(server) {
Self::ComputerUse
} else {
Self::Mcp

View File

@@ -60,7 +60,6 @@ use crate::plan_tool::UpdatePlanArgs;
use crate::request_permissions::RequestPermissionsEvent;
use crate::request_permissions::RequestPermissionsResponse;
use crate::request_user_input::RequestUserInputResponse;
use crate::turn_input::CyberAccessProgram;
use crate::turn_input::SuspendTurnOutcome;
use crate::turn_input::TurnInputMode;
use crate::turn_input::TurnInputRequest;
@@ -1566,12 +1565,6 @@ pub enum EventMsg {
/// Realtime session description protocol payload.
RealtimeConversationSdp(RealtimeConversationSdpEvent),
/// Model routing changed from the requested model to a different model.
ModelReroute(ModelRerouteEvent),
/// Backend recommends additional account verification for this turn.
ModelVerification(ModelVerificationEvent),
/// Backend moderation metadata intended for first-party turn presentation.
TurnModerationMetadata(TurnModerationMetadataEvent),
@@ -1854,8 +1847,6 @@ pub enum HookSource {
Mdm,
SessionFlags,
Plugin,
CloudRequirements,
CloudManagedConfig,
LegacyManagedConfigFile,
LegacyManagedConfigMdm,
#[default]
@@ -2370,32 +2361,6 @@ pub struct AuthRecoveryEvent {
pub message: String,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "snake_case")]
#[ts(rename_all = "snake_case")]
pub enum ModelRerouteReason {
HighRiskCyberActivity,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, JsonSchema, TS)]
pub struct ModelRerouteEvent {
pub from_model: String,
pub to_model: String,
pub reason: ModelRerouteReason,
}
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "snake_case")]
#[ts(rename_all = "snake_case")]
pub enum ModelVerification {
TrustedAccessForCyber,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, JsonSchema, TS)]
pub struct ModelVerificationEvent {
pub verifications: Vec<ModelVerification>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, JsonSchema, TS)]
pub struct TargetedAnswerModeration {
pub item_id: String,
@@ -3677,8 +3642,6 @@ pub struct TurnContextItem {
pub multi_agent_version: Option<MultiAgentVersion>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub realtime_active: Option<bool>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub cyber_access_program: Option<CyberAccessProgram>,
#[serde(skip_serializing_if = "Option::is_none")]
pub effort: Option<ReasoningEffortConfig>,
/// Legacy placeholder written as `Some(ReasoningSummaryConfig::None)` for older readers.
@@ -3711,7 +3674,6 @@ impl<'de> Deserialize<'de> for TurnContextItem {
collaboration_mode: Option<CollaborationMode>,
multi_agent_version: Option<MultiAgentVersion>,
realtime_active: Option<bool>,
cyber_access_program: Option<CyberAccessProgram>,
effort: Option<ReasoningEffortConfig>,
summary: Option<ReasoningSummaryConfig>,
}
@@ -3757,7 +3719,6 @@ impl<'de> Deserialize<'de> for TurnContextItem {
collaboration_mode: wire.collaboration_mode,
multi_agent_version: wire.multi_agent_version,
realtime_active: wire.realtime_active,
cyber_access_program: wire.cyber_access_program,
effort: wire.effort,
summary: wire.summary,
})
@@ -6645,6 +6606,24 @@ mod tests {
Ok(())
}
#[test]
fn turn_context_item_ignores_legacy_access_program_selection() -> Result<()> {
let item: TurnContextItem = serde_json::from_value(json!({
"cwd": test_path_buf("/tmp"),
"approval_policy": "never",
"sandbox_policy": { "type": "danger-full-access" },
"model": "gpt-5",
"cyber_access_program": "daybreak_blue",
}))?;
assert_eq!(item.model, "gpt-5");
assert_eq!(
serde_json::to_value(item)?.get("cyber_access_program"),
None
);
Ok(())
}
#[test]
fn turn_context_item_deserializes_legacy_on_failure_as_on_request() -> Result<()> {
let item: TurnContextItem = serde_json::from_value(json!({

View File

@@ -115,8 +115,6 @@ pub struct RecoverTurnRequest {
pub trace: Option<W3cTraceContext>,
/// Cache lifetime to reapply when resuming this turn.
pub prompt_cache_ttl: Option<PromptCacheTtl>,
/// Program recorded in the interrupted turn's persisted context.
pub cyber_access_program: Option<CyberAccessProgram>,
}
impl TurnInputRequest {
@@ -207,17 +205,6 @@ pub enum TurnInputMode {
Steer { expected_turn_id: String },
}
/// Requested cyber treatment for an OpenAI model turn.
/// Authorization and model-tier restrictions remain server-owned.
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "snake_case")]
#[ts(rename_all = "snake_case")]
pub enum CyberAccessProgram {
Standard,
DaybreakBlue,
DaybreakRed,
}
/// Minimum lifetime requested for new prompt cache entries.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
pub enum PromptCacheTtl {
@@ -254,9 +241,6 @@ pub struct TurnStartOptions {
pub initiating_agent_path: Option<AgentPath>,
/// Causal root turn lineage recorded if this request starts a new turn.
pub root_turn_id: Option<String>,
/// Explicit cyber treatment for this turn. Omission preserves the backend's
/// automatic behavior.
pub cyber_access_program: Option<CyberAccessProgram>,
}
/// What Core did with input submitted through `start_or_steer_turn`.