Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 9 additions & 21 deletions apps/codex-plus-manager/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions apps/codex-plus-manager/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export type RelayProfile = {
userAgent: string;
sub2apiEnabled: boolean;
sub2apiMultiplier: string;
standardOpenaiProtocol: boolean;
aggregate?: RelayAggregateConfig | null;
};

Expand Down Expand Up @@ -855,6 +856,7 @@ const defaultSettings: BackendSettings = {
userAgent: "",
sub2apiEnabled: false,
sub2apiMultiplier: "",
standardOpenaiProtocol: false,
},
],
relayCommonConfigContents: "",
Expand Down Expand Up @@ -5868,6 +5870,17 @@ function RelayProfileEditor({
</button>
</div>
</Field>
<Field className="relay-field-standard" label={t("纯标准协议")}>
<label className="inline-check">
<input
checked={profile.standardOpenaiProtocol}
onChange={(event) => updateDraft({ standardOpenaiProtocol: event.currentTarget.checked })}
type="checkbox"
/>
<span>{t("强制走标准 OpenAI 协议,不注入厂商私有 reasoning 参数")}</span>
</label>
<p className="field-hint">{t("面向只认Openai标准协议、拒绝厂商夹带私有参数的第三方网关。")}</p>
</Field>
<Field className="relay-field-sub2api" label="Sub2API">
<div className="sub2api-field">
<label className="inline-check">
Expand Down Expand Up @@ -7912,6 +7925,7 @@ function normalizeSettings(settings: BackendSettings): BackendSettings {
userAgent: "",
sub2apiEnabled: false,
sub2apiMultiplier: "",
standardOpenaiProtocol: false,
},
];
const activeRelayId = profiles.some((profile) => profile.id === settings.activeRelayId)
Expand Down Expand Up @@ -7989,6 +8003,7 @@ function normalizeRelayProfile(profile: RelayProfile, defaultContextSelection =
modelWindows: "",
sub2apiEnabled: false,
sub2apiMultiplier: "",
standardOpenaiProtocol: false,
},
null,
);
Expand Down Expand Up @@ -8019,6 +8034,7 @@ function normalizeRelayProfile(profile: RelayProfile, defaultContextSelection =
userAgent: profile.userAgent || "",
sub2apiEnabled: profile.sub2apiEnabled === true,
sub2apiMultiplier: profile.sub2apiEnabled === true ? profile.sub2apiMultiplier || "" : "",
standardOpenaiProtocol: profile.standardOpenaiProtocol === true,
aggregate: null,
};
return relayProfileUsesLiveFiles(normalized) ? deriveRelayProfileFromFiles(normalized) : normalized;
Expand Down Expand Up @@ -8667,6 +8683,7 @@ function createRelayProfile(settings: BackendSettings): RelayProfile {
userAgent: "",
sub2apiEnabled: false,
sub2apiMultiplier: "",
standardOpenaiProtocol: false,
};
return withGeneratedRelayFiles(next);
}
Expand Down Expand Up @@ -8703,6 +8720,7 @@ function createAggregateRelayProfile(settings: BackendSettings): RelayProfile {
userAgent: "",
sub2apiEnabled: false,
sub2apiMultiplier: "",
standardOpenaiProtocol: false,
aggregate: {
strategy: "failover",
members: candidates.slice(0, 1).map((profile) => ({ profileId: profile.id, weight: 1 })),
Expand Down Expand Up @@ -8825,6 +8843,7 @@ function normalizeAggregateRelayProfile(profile: RelayProfile, settings: Backend
authContents: "",
sub2apiEnabled: false,
sub2apiMultiplier: "",
standardOpenaiProtocol: false,
aggregate,
};
}
Expand Down
3 changes: 3 additions & 0 deletions apps/codex-plus-manager/src/i18n-en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ export const EN_PLAIN: Record<string, string> = {
"上次修复结果": "Last repair result",
"上次更新结果": "Last update result",
"上游协议": "Upstream protocol",
"纯标准协议": "Standard protocol only",
"强制走标准 OpenAI 协议,不注入厂商私有 reasoning 参数": "Force standard OpenAI protocol; do not inject vendor-specific reasoning parameters",
"面向只认Openai标准协议、拒绝厂商夹带私有参数的第三方网关。": "For third-party gateways that accept only the standard OpenAI protocol and reject vendor-bundled private parameters.",
"上一页": "Previous page",
"下一页": "Next page",
"下载并运行安装包": "Download and run installer",
Expand Down
1 change: 1 addition & 0 deletions apps/codex-plus-manager/src/model-windows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const _profileTypeCheck: RelayProfile = {
userAgent: "",
sub2apiEnabled: false,
sub2apiMultiplier: "",
standardOpenaiProtocol: false,
};

void _profileTypeCheck;
Expand Down
4 changes: 4 additions & 0 deletions apps/codex-plus-manager/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,10 @@ body {
grid-column: 1;
}

.relay-field-standard .inline-check {
width: 100%;
}

.protocol-options {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
Expand Down
1 change: 1 addition & 0 deletions crates/codex-plus-core/src/ccs_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pub fn relay_profile_from_ccs(
user_agent: String::new(),
sub2api_enabled: false,
sub2api_multiplier: String::new(),
standard_openai_protocol: false,
}
}

Expand Down
25 changes: 21 additions & 4 deletions crates/codex-plus-core/src/protocol_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ pub fn local_responses_proxy_base_url(port: u16) -> String {
}

pub fn responses_to_chat_completions(body: Value) -> anyhow::Result<Value> {
responses_to_chat_completions_with_options(body, false)
}

pub fn responses_to_chat_completions_with_options(
body: Value,
standard: bool,
) -> anyhow::Result<Value> {
let mut result = json!({});

if let Some(model) = body.get("model") {
Expand Down Expand Up @@ -181,7 +188,7 @@ pub fn responses_to_chat_completions(body: Value) -> anyhow::Result<Value> {
result["stream_options"] = stream_options;
}

apply_chat_reasoning_options(&mut result, &body, model);
apply_chat_reasoning_options(&mut result, &body, model, standard);

let tool_context = build_codex_tool_context(body.get("tools"));
let mut has_chat_tools = false;
Expand Down Expand Up @@ -840,7 +847,8 @@ async fn upstream_request_parts(
}
let mut body = match relay.protocol {
RelayProtocol::Responses => request_json,
RelayProtocol::ChatCompletions => responses_to_chat_completions(request_json)?,
RelayProtocol::ChatCompletions =>
responses_to_chat_completions_with_options(request_json, relay.standard_openai_protocol)?,
};

// Image handling (per-model): send-as-is / strip / VLM analysis
Expand Down Expand Up @@ -3989,11 +3997,20 @@ fn canonical_json_string(value: &Value) -> String {
}
}

fn apply_chat_reasoning_options(result: &mut Value, body: &Value, model: &str) {
fn apply_chat_reasoning_options(
result: &mut Value,
body: &Value,
model: &str,
standard: bool,
) {
let Some(reasoning_enabled) = reasoning_requested(body) else {
return;
};
let style = infer_chat_reasoning_style(model);
let style = if standard {
ChatReasoningStyle::Default
} else {
infer_chat_reasoning_style(model)
};

match style {
ChatReasoningStyle::Thinking => {
Expand Down
1 change: 1 addition & 0 deletions crates/codex-plus-core/src/provider_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ fn relay_profile_from_request(
user_agent: String::new(),
sub2api_enabled: false,
sub2api_multiplier: String::new(),
standard_openai_protocol: false,
}
}

Expand Down
5 changes: 5 additions & 0 deletions crates/codex-plus-core/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ pub struct RelayProfile {
skip_serializing_if = "String::is_empty"
)]
pub sub2api_multiplier: String,
#[serde(rename = "standardOpenaiProtocol", default)]
pub standard_openai_protocol: bool,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, Default)]
Expand Down Expand Up @@ -175,6 +177,7 @@ impl Default for RelayProfile {
user_agent: String::new(),
sub2api_enabled: false,
sub2api_multiplier: String::new(),
standard_openai_protocol: false,
}
}
}
Expand Down Expand Up @@ -592,6 +595,7 @@ impl BackendSettings {
user_agent: String::new(),
sub2api_enabled: false,
sub2api_multiplier: String::new(),
standard_openai_protocol: false,
};
}

Expand Down Expand Up @@ -643,6 +647,7 @@ impl BackendSettings {
user_agent: String::new(),
sub2api_enabled: false,
sub2api_multiplier: String::new(),
standard_openai_protocol: false,
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/codex-plus-core/tests/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,7 @@ async fn launch_starts_helper_when_chat_protocol_proxy_is_enabled() {
user_agent: String::new(),
sub2api_enabled: false,
sub2api_multiplier: String::new(),
standard_openai_protocol: false,
}],
active_relay_id: "relay-chat".to_string(),
..BackendSettings::default()
Expand Down
Loading