Compare commits

...
7 Commits
Author SHA1 Message Date
ZyyandCodex 1b92c552b9 chore: bump version to 3.60.4
Co-authored-by: Codex <noreply@openai.com>
2026-11-30 23:53:30 +08:00
ZyyandCodex c9fb2ac465 test(openai): align request fixtures with empty defaults
Use the empty country default in content preservation assertions and configure residency explicitly in routing header coverage.

Co-authored-by: Codex <noreply@openai.com>
2026-11-30 23:48:12 +08:00
ZyyandCodex 6bf109e784 test(store): initialize configuration revision baseline
Initialize configuration and settings revisions after test migrations so functional assertions remain independent of migration revision increments.

Co-authored-by: Codex <noreply@openai.com>
2026-11-30 23:25:46 +08:00
ZyyandCodex fa187c5031 fix(settings): keep help controls transparent and consistent
Use a shared 24px square help trigger for request settings and automatic
approval details. Align the UI dependency and submodule with the disabled
link background fix.

Co-authored-by: Codex <noreply@openai.com>
2026-11-30 23:17:02 +08:00
ZyyandCodex 5f7e1723f3 fix(openai): default request country and residency to empty
Use the empty country policy and leave residency and account routing unset.
Migrate existing follow-location policies and us residency values while
preserving custom settings and advancing the settings revision.
Update the settings UI, existing contract tests, and deployment guidance.

Co-authored-by: Codex <noreply@openai.com>
2026-11-30 23:02:45 +08:00
ZyyandCodex 7d34be5d02 fix(antigravity): preserve native signatures across model switches
Recognize known Claude and Gemini signature envelopes without wrapping
response signatures. Remove foreign thinking history while preserving
compatible or unknown signatures, ordinary text, and tool history.

Integrate cleanup into request field editing and reuse unchanged history.
Keep counting and unknown model families untouched, without session caches.
Cover native JSON/SSE, escaped fields, malformed envelopes, and model
switches; document recognition and account compatibility boundaries.

Co-authored-by: Codex <noreply@openai.com>
2026-11-30 23:02:44 +08:00
github-actions[bot] ebb3c4b1fa chore(release): update release channels to 3.60.3 2026-11-30 12:57:31 +00:00
31 changed files with 853 additions and 149 deletions
@@ -1540,7 +1540,7 @@ async fn runtime_settings_reject_incomplete_and_stale_replacements() {
);
assert_eq!(
initial["openaiRequestSettings"]["requestCountry"],
json!({"mode":"follow_location"})
json!({"mode":"default"})
);
let mut body = update_body();
body["configRevision"] = initial["configRevision"].clone();
@@ -40,7 +40,7 @@ impl Default for OpenAiRequestSettings {
Self {
request_country: Default::default(),
oauth_guardian_review_model: true,
residency: Some("us".to_owned()),
residency: None,
account_routing_override: None,
}
}
@@ -58,7 +58,7 @@ pub enum OpenAiRequestCountry {
impl Default for OpenAiRequestCountry {
fn default() -> Self {
Self::FollowLocation {}
Self::Default {}
}
}
@@ -2617,7 +2617,7 @@ fn global_request_location_should_be_frozen_when_snapshot_is_published() {
assert_eq!(
plan(&handle.acquire().unwrap()).openai_request_settings(),
&gateway_core::settings::OpenAiRequestSettings {
residency: None,
request_country: OpenAiRequestCountry::FollowLocation {},
..Default::default()
}
);
@@ -101,6 +101,15 @@ impl TestDatabase {
.run(&pool)
.await
.expect("apply test migrations");
// 功能测试从统一版本基线验证递增与回滚,不依赖数据迁移累计的版本
sqlx::query(
"update runtime_settings
set config_revision = 1, settings_revision = 1, account_error_protection_revision = 1
where id = 1",
)
.execute(&pool)
.await
.expect("initialize test runtime settings revisions");
Some(Self {
admin,
pool,
@@ -622,7 +622,7 @@ async fn openai_request_settings_round_trip_into_snapshot() {
.openai_request_settings()
.residency
.as_deref(),
Some("us")
None
);
assert!(
initial
@@ -632,7 +632,7 @@ async fn openai_request_settings_round_trip_into_snapshot() {
);
assert_eq!(
initial.settings.openai_request_settings().request_country,
OpenAiRequestCountry::FollowLocation {}
OpenAiRequestCountry::Default {}
);
for (enabled, country) in [
@@ -235,7 +235,7 @@ impl CloudCodeClient {
GenerateMode::Chat { .. } => None,
GenerateMode::Json | GenerateMode::Stream => Some(self.system_instruction.as_ref()),
};
let request = super::request::request_body(body, instruction, false)?;
let request = super::request::request_body(body, instruction, false, Some(model))?;
let request = if matches!(mode, GenerateMode::Json | GenerateMode::Stream)
&& model.starts_with("claude-")
{
@@ -289,7 +289,8 @@ impl CloudCodeClient {
headers: &[MiddlewareHeader],
) -> Result<Response, ProviderError> {
// Desktop 的计数封套只接受 Vertex CountTokensRequest,没有项目和生成控制字段
let request = super::request::request_body(body, Some(&self.system_instruction), true)?;
let request =
super::request::request_body(body, Some(&self.system_instruction), true, None)?;
#[derive(Serialize)]
struct Envelope<'a> {
request: &'a RawValue,
@@ -0,0 +1,84 @@
//! 在指定 JSON 对象字段上编辑原始字节,保留未知字段、顺序与数字表达
use serde::{
Deserialize, Deserializer,
de::{MapAccess, Visitor},
};
use serde_json::value::RawValue;
pub(super) enum Edit {
Keep,
Remove,
Replace(Box<RawValue>),
}
pub(super) fn edit_object(
body: &RawValue,
mut edit: impl FnMut(&str, &RawValue) -> Result<Edit, serde_json::Error>,
append: Option<(&str, &RawValue)>,
) -> Result<Box<RawValue>, serde_json::Error> {
let json = body.get();
let Fields(fields) = serde_json::from_str(json)?;
let mut output = String::with_capacity(json.len());
output.push('{');
let mut cursor = 1;
let mut retained = false;
for (name, value) in fields {
// RawValue 借自同一输入;位置由 serde JSON 解析器确定,不自行解析值或转码数字
let start = value.get().as_ptr() as usize - json.as_ptr() as usize;
let prefix = &json[cursor..start];
cursor = start + value.get().len();
let replacement = match edit(&name, value)? {
Edit::Keep => None,
Edit::Remove => continue,
Edit::Replace(value) => Some(value),
};
let comma = (!retained)
.then(|| prefix.bytes().position(|byte| !byte.is_ascii_whitespace()))
.flatten()
.filter(|&index| prefix.as_bytes()[index] == b',');
if let Some(index) = comma {
output.push_str(&prefix[..index]);
output.push_str(&prefix[index + 1..]);
} else {
output.push_str(prefix);
}
output.push_str(replacement.as_deref().unwrap_or(value).get());
retained = true;
}
if let Some((name, value)) = append {
if retained {
output.push(',');
}
output.push_str(&serde_json::to_string(name)?);
output.push(':');
output.push_str(value.get());
}
output.push_str(&json[cursor..]);
RawValue::from_string(output)
}
// 保留顺序和重复字段;身份字段的重复项也必须全部处理,不能被 Map 的最后值语义遗漏
pub(super) struct Fields<'a>(pub(super) Vec<(String, &'a RawValue)>);
impl<'de> Deserialize<'de> for Fields<'de> {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
struct ObjectVisitor;
impl<'de> Visitor<'de> for ObjectVisitor {
type Value = Fields<'de>;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("a JSON object")
}
fn visit_map<A: MapAccess<'de>>(self, mut map: A) -> Result<Self::Value, A::Error> {
let mut fields = Vec::new();
while let Some(name) = map.next_key()? {
fields.push((name, map.next_value()?));
}
Ok(Fields(fields))
}
}
deserializer.deserialize_map(ObjectVisitor)
}
}
@@ -4,9 +4,11 @@ mod client;
mod count;
mod failure;
mod headers;
mod json;
mod pool;
mod request;
mod response;
mod signatures;
mod tool_ids;
pub(crate) use client::{Catalog, CloudCodeClient, GenerateMode, Model, unwrap_frame};
pub(crate) use count::count_events;
@@ -1,18 +1,19 @@
//! 合成系统提示并改写 Cloud Code 身份字段,其他字段保留原始 JSON 字节
//! 合成系统提示、处理思考签名并改写身份字段,其他字段保留原始 JSON 字节
use serde::{
Deserialize, Deserializer,
de::{MapAccess, Visitor},
};
use serde::Deserialize;
use serde_json::value::RawValue;
use super::unsent;
use super::{
json::{Edit, Fields, edit_object},
unsent,
};
use gateway_core::error::{ProviderError, ProviderErrorKind};
pub(super) fn request_body(
body: &[u8],
instruction: Option<&RawValue>,
count: bool,
model: Option<&str>,
) -> Result<Box<RawValue>, ProviderError> {
let rewrite = || {
let raw: &RawValue = serde_json::from_slice(body)?;
@@ -22,6 +23,10 @@ pub(super) fn request_body(
edit_object(
raw,
|name, value| {
// 合并到已有的字段处理,避免为签名再解析、复制和校验整个请求
if name == "contents" {
return super::signatures::prepare_contents(value, model);
}
if (instruction.is_some()
&& matches!(name, "systemInstruction" | "system_instruction"))
|| (count
@@ -109,80 +114,3 @@ fn prepend_system_prompt(
Some(("parts", &parts)),
)
}
enum Edit {
Keep,
Remove,
Replace(Box<RawValue>),
}
fn edit_object(
body: &RawValue,
mut edit: impl FnMut(&str, &RawValue) -> Result<Edit, serde_json::Error>,
append: Option<(&str, &RawValue)>,
) -> Result<Box<RawValue>, serde_json::Error> {
let json = body.get();
let Fields(fields) = serde_json::from_str(json)?;
let mut output = String::with_capacity(json.len());
output.push('{');
let mut cursor = 1;
let mut retained = false;
for (name, value) in fields {
// RawValue 借自同一输入;位置由 serde JSON 解析器确定,不自行解析值或转码数字
let start = value.get().as_ptr() as usize - json.as_ptr() as usize;
let prefix = &json[cursor..start];
cursor = start + value.get().len();
let replacement = match edit(&name, value)? {
Edit::Keep => None,
Edit::Remove => continue,
Edit::Replace(value) => Some(value),
};
let comma = (!retained)
.then(|| prefix.bytes().position(|byte| !byte.is_ascii_whitespace()))
.flatten()
.filter(|&index| prefix.as_bytes()[index] == b',');
if let Some(index) = comma {
output.push_str(&prefix[..index]);
output.push_str(&prefix[index + 1..]);
} else {
output.push_str(prefix);
}
output.push_str(replacement.as_deref().unwrap_or(value).get());
retained = true;
}
if let Some((name, value)) = append {
if retained {
output.push(',');
}
output.push_str(&serde_json::to_string(name)?);
output.push(':');
output.push_str(value.get());
}
output.push_str(&json[cursor..]);
RawValue::from_string(output)
}
// 保留顺序和重复字段;身份字段的重复项也必须全部处理,不能被 Map 的最后值语义遗漏
struct Fields<'a>(Vec<(String, &'a RawValue)>);
impl<'de> Deserialize<'de> for Fields<'de> {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
struct ObjectVisitor;
impl<'de> Visitor<'de> for ObjectVisitor {
type Value = Fields<'de>;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("a JSON object")
}
fn visit_map<A: MapAccess<'de>>(self, mut map: A) -> Result<Self::Value, A::Error> {
let mut fields = Vec::new();
while let Some(name) = map.next_key()? {
fields.push((name, map.next_value()?));
}
Ok(Fields(fields))
}
}
deserializer.deserialize_map(ObjectVisitor)
}
}
@@ -0,0 +1,254 @@
//! 识别原生签名的已知封套,出站移除跨家族思考历史,兼容签名保持原样
use base64::{Engine, engine::general_purpose::STANDARD};
use serde::Deserialize;
use serde_json::value::{RawValue, to_raw_value};
use std::borrow::Cow;
use super::json::{Edit, edit_object};
const SKIP: &str = "skip_thought_signature_validator";
fn family(model: &str) -> Option<&'static str> {
["claude", "gemini"].into_iter().find(|family| {
model
.strip_prefix(family)
.is_some_and(|rest| rest.starts_with('-'))
})
}
fn source(signature: &str) -> Option<&'static str> {
// 预筛仅减少解码开销,来源由完整封套决定;不以首字母或密钥编号判定
if !matches!(signature.as_bytes().first(), Some(b'C' | b'E' | b'Q')) {
return None;
}
let mut decoded = STANDARD.decode(signature).ok()?;
if decoded.first() == Some(&b'C') {
decoded = STANDARD.decode(&decoded).ok()?;
}
// AGY CLI 1.5.18 实测:Claude 5.5 的 CAQS v4 封套包含 Google 通道、块类型和签名
// 只读取封套元数据,不解密、校验或重编码其中的签名,不推断账号或项目兼容性
if matches!(field(&decoded, 1), Some(Wire::Integer(4)))
&& matches!(field(&decoded, 3), Some(Wire::Integer(1)))
&& let Some(Wire::Bytes(container)) = field(&decoded, 2)
&& let Some(Wire::Bytes(channel)) = field(container, 1)
&& matches!(field(channel, 1), Some(Wire::Integer(_)))
&& matches!(field(channel, 2), Some(Wire::Integer(2)))
&& matches!(field(channel, 8), Some(Wire::Bytes(b"thinking")))
&& matches!(field(container, 5), Some(Wire::Bytes(signature)) if !signature.is_empty())
{
return Some("claude");
}
// Gemini 样本为独占的 2 → 1 字节字段,内部为 Tink 前缀和不透明密文
let container = sole_bytes(&decoded, 2)?;
let opaque = sole_bytes(container, 1)?;
(opaque.len() >= 21 && opaque[0] == 1).then_some("gemini")
}
enum Wire<'a> {
Integer(u64),
Bytes(&'a [u8]),
Fixed,
}
fn varint(input: &mut &[u8]) -> Option<u64> {
let mut result = 0;
for shift in (0..70).step_by(7) {
let (&byte, rest) = input.split_first()?;
*input = rest;
if shift == 63 && byte > 1 {
return None;
}
result |= u64::from(byte & 0x7f) << shift;
if byte < 0x80 {
return Some(result);
}
}
None
}
fn next_field<'a>(input: &mut &'a [u8]) -> Option<(u64, Wire<'a>)> {
let tag = varint(input)?;
let number = tag >> 3;
if number == 0 || number > 0x1fff_ffff {
return None;
}
let wire = tag & 7;
if wire == 0 {
return Some((number, Wire::Integer(varint(input)?)));
}
let len = match wire {
1 => 8,
2 => usize::try_from(varint(input)?).ok()?,
5 => 4,
_ => return None,
};
let value = input.get(..len)?;
*input = &input[len..];
Some((
number,
if wire == 2 {
Wire::Bytes(value)
} else {
Wire::Fixed
},
))
}
fn field(mut input: &[u8], wanted: u64) -> Option<Wire<'_>> {
let mut found = None;
while !input.is_empty() {
let (number, value) = next_field(&mut input)?;
// 识别字段有歧义或封套截断时保持未知,交由上游处理
if number == wanted && found.replace(value).is_some() {
return None;
}
}
found
}
fn sole_bytes(mut input: &[u8], wanted: u64) -> Option<&[u8]> {
let (number, Wire::Bytes(value)) = next_field(&mut input)? else {
return None;
};
(number == wanted && input.is_empty()).then_some(value)
}
#[derive(Deserialize)]
struct Content<'a> {
#[serde(default, borrow)]
role: Cow<'a, str>,
#[serde(default, borrow)]
parts: Vec<&'a RawValue>,
}
#[derive(Deserialize)]
struct Part<'a> {
#[serde(default)]
thought: Option<bool>,
#[serde(default, rename = "thoughtSignature", alias = "thought_signature")]
signature: Option<Cow<'a, str>>,
#[serde(default, borrow, rename = "functionCall", alias = "function_call")]
call: Option<&'a RawValue>,
}
pub(super) fn prepare_contents(
contents: &RawValue,
model: Option<&str>,
) -> Result<Edit, serde_json::Error> {
// AGY CLI 1.5.18 的 OAuth 路径在跨家族时去掉思考历史,Gateway GenAI 路径却保留签名
// 只清理可识别的异家族签名;计数和未知模型无需扫描历史,不增加会话缓存
let Some(target) = model.and_then(family) else {
return Ok(Edit::Keep);
};
let Ok(contents) = serde_json::from_str::<Vec<&RawValue>>(contents.get()) else {
return Ok(Edit::Keep);
};
let prepared = contents
.iter()
.map(|content| prepare_content(content, target))
.collect::<Result<Vec<_>, _>>()?;
if prepared
.iter()
.all(|content| matches!(content, Some(Cow::Borrowed(_))))
{
return Ok(Edit::Keep);
}
let prepared: Vec<_> = prepared.into_iter().flatten().collect();
to_raw_value(&prepared).map(Edit::Replace)
}
fn prepare_content<'a>(
raw: &'a RawValue,
target: &str,
) -> Result<Option<Cow<'a, RawValue>>, serde_json::Error> {
let Ok(content) = serde_json::from_str::<Content<'_>>(raw.get()) else {
return Ok(Some(Cow::Borrowed(raw)));
};
if content.role != "model" {
return Ok(Some(Cow::Borrowed(raw)));
}
let Ok(parts) = content
.parts
.iter()
.map(|part| serde_json::from_str::<Part<'_>>(part.get()))
.collect::<Result<Vec<_>, _>>()
else {
return Ok(Some(Cow::Borrowed(raw)));
};
let signatures: Vec<_> = parts
.iter()
.map(|part| part.signature.as_deref().and_then(source))
.collect();
let foreign = |source: &Option<&str>| source.is_some_and(|source| source != target);
if !signatures.iter().any(foreign) {
return Ok(Some(Cow::Borrowed(raw)));
}
let strip_thoughts = parts
.iter()
.zip(&signatures)
.all(|(part, signature)| part.signature.is_none() || foreign(signature));
let mut first_call = true;
let mut output = Vec::new();
for ((raw, part), signature) in content.parts.iter().zip(parts).zip(&signatures) {
let foreign = foreign(signature);
let strip_thought = part.thought == Some(true) && (foreign || strip_thoughts);
if strip_thought && part.call.is_none() {
continue;
}
// 对齐官方 CLI 1.5.18 的 ccpa.BuildRequest:导入历史缺少签名时只标记首个工具调用
let placeholder = target == "gemini"
&& first_call
&& part.call.is_some()
&& (part.signature.is_none() || foreign);
if part.call.is_some() {
first_call = false;
}
let replacement = placeholder.then(|| to_raw_value(SKIP)).transpose()?;
if !foreign && !placeholder && !strip_thought {
output.push(Cow::Borrowed(*raw));
continue;
}
let part = edit_object(
raw,
|name, _| {
Ok(
if (matches!(name, "thoughtSignature" | "thought_signature") && foreign)
|| (name == "thought" && strip_thought)
{
Edit::Remove
} else {
Edit::Keep
},
)
},
replacement
.as_deref()
.map(|signature| ("thoughtSignature", signature)),
)?;
// 只有签名的独立 part 在跨家族后不应变成无内容的对象
if !foreign
|| !serde_json::from_str::<super::json::Fields<'_>>(part.get())?
.0
.is_empty()
{
output.push(Cow::Owned(part));
}
}
if output.is_empty() {
return Ok(None);
}
let parts = to_raw_value(&output)?;
edit_object(
raw,
|name, _| {
Ok(if name == "parts" {
Edit::Replace(parts.clone())
} else {
Edit::Keep
})
},
None,
)
.map(|content| Some(Cow::Owned(content)))
}
@@ -4,4 +4,5 @@ mod client;
mod count;
mod pool;
mod request;
mod signatures;
mod tool_ids;
@@ -0,0 +1,408 @@
//! 原生签名透传、封套识别、模型互切清理和输入计数的历史保留
use crate::{
profile,
transport::{self, CloudCodeClient},
};
use base64::{Engine, engine::general_purpose::STANDARD};
use futures::TryStreamExt;
use gateway_core::{
lifecycle::{CancellationToken, Deadline},
routing::UpstreamModelId,
};
use serde_json::{Value, json, value::RawValue};
use wiremock::{Mock, MockServer, ResponseTemplate, matchers::path};
// 按官方 CLI 样本的封套构造,密文使用测试字节,不包含真实账号签名
fn bytes_field(number: u8, value: &[u8]) -> Vec<u8> {
let mut output = vec![(number << 3) | 2];
let mut len = value.len();
while len >= 128 {
output.push((len as u8 & 0x7f) | 0x80);
len >>= 7;
}
output.push(len as u8);
output.extend_from_slice(value);
output
}
fn claude_envelope(channel_id: u8) -> Vec<u8> {
let mut channel = vec![8, channel_id, 16, 2, 24, 2, 56, 1];
channel.extend(bytes_field(8, b"thinking"));
let mut container = bytes_field(1, &channel);
container.extend(bytes_field(5, &[0x42; 160]));
let mut envelope = vec![8, 4];
envelope.extend(bytes_field(2, &container));
envelope.extend([24, 1]);
envelope
}
fn claude_signature() -> String {
STANDARD.encode(STANDARD.encode(claude_envelope(20)))
}
fn gemini_envelope() -> Vec<u8> {
let mut opaque = vec![1, 2, 3, 4, 5];
opaque.extend([0x42; 160]);
bytes_field(2, &bytes_field(1, &opaque))
}
fn gemini_signature() -> String {
STANDARD.encode(gemini_envelope())
}
async fn fixture(reply: &str) -> (MockServer, CloudCodeClient) {
let server = MockServer::start().await;
Mock::given(path("/v1internal:generateContent"))
.respond_with(
ResponseTemplate::new(200)
.set_body_raw(format!(r#"{{"response":{reply}}}"#), "application/json"),
)
.mount(&server)
.await;
Mock::given(path("/v1internal:streamGenerateContent"))
.respond_with(ResponseTemplate::new(200).set_body_raw(
format!("id: signature-frame\ndata: {{\"response\":{reply}}}\n\n"),
"text/event-stream",
))
.mount(&server)
.await;
Mock::given(path("/v1internal:countTokens"))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({"totalTokens":42})))
.mount(&server)
.await;
let client = CloudCodeClient::new(
&server.uri().parse().unwrap(),
None,
&profile::Selection::default().resolve("2.34.0"),
)
.unwrap();
(server, client)
}
async fn response(client: &CloudCodeClient, model: &str, stream: bool) -> (String, Value) {
let response = client
.generate(
"project",
model,
"token",
br#"{"contents":[{"role":"user","parts":[{"text":"hi"}]}]}"#,
stream.into(),
&[],
)
.await
.unwrap();
let events = transport::events(
response,
transport::ResponseContext {
stream,
model: UpstreamModelId::new(model).unwrap(),
deadline: Deadline::default(),
cancel: CancellationToken::new(),
token: "token".into(),
pricing: None,
started_at: std::time::Instant::now(),
},
)
.try_collect::<Vec<_>>()
.await
.unwrap();
let wire = events[0].wire_event().unwrap();
let raw = if stream {
let sse = std::str::from_utf8(wire.raw_sse_frame().unwrap()).unwrap();
assert!(sse.contains("id: signature-frame"));
sse.lines()
.find_map(|line| line.strip_prefix("data: "))
.unwrap()
.to_owned()
} else {
std::str::from_utf8(wire.raw_json_body().unwrap())
.unwrap()
.to_owned()
};
let value = serde_json::from_str(&raw).unwrap();
(raw, value)
}
async fn sent(server: &MockServer) -> Value {
let requests = server.received_requests().await.unwrap();
serde_json::from_slice::<Value>(&requests.last().unwrap().body).unwrap()["request"].clone()
}
#[tokio::test]
async fn native_signature_round_trip_preserves_own_thoughts_and_removes_foreign_thoughts() {
// 官方 CLI Gateway 把 Claude 思考文本和末尾签名重排到同一 model 轮次的不同 part
for (source, other, original) in [
(
"claude-opus-5-5-medium",
"gemini-4-hydrogen-medium",
claude_signature(),
),
(
"gemini-4-hydrogen-medium",
"claude-opus-5-5-medium",
gemini_signature(),
),
] {
let reply = format!(
r#"{{ "responseId":"r","candidates":[{{"content":{{"role":"model","parts":[{{"thought":true,"text":"reasoning","thoughtSignature":"{original}"}}]}},"finishReason":"STOP"}}],"extension":1e+09,"extension":98765432109876543210987654 }}"#
);
let (server, client) = fixture(&reply).await;
for stream in [false, true] {
let (raw, value) = response(&client, source, stream).await;
let signature = value["candidates"][0]["content"]["parts"][0]["thoughtSignature"]
.as_str()
.unwrap();
assert_eq!(signature, original);
assert_eq!(raw, reply);
let history = json!({
"systemInstruction":{"parts":[{"text":"client instruction"}]},
"labels":{"client":"gateway","cascade_id":"conversation"},
"contents":[
{"role":"user","parts":[{"text":"first"}]},
{"role":"model","parts":[{"thought":true,"text":"reasoning"},{"text":"answer","thoughtSignature":signature}]},
{"role":"user","parts":[{"text":"next"}]}
]});
let body = serde_json::to_string(&history).unwrap();
// 借用视图遇到转义字符串仍须识别同一来源,并与身份字段、系统提示处理共存
let body = if stream {
body.replace(r#""contents""#, r#""con\u0074ents""#)
.replace(r#""model""#, r#""mo\u0064el""#)
.replace(
signature,
&format!(r"\u{:04x}{}", signature.as_bytes()[0], &signature[1..]),
)
} else {
body
};
for target in [source, other] {
client
.generate(
"project",
target,
"token",
body.as_bytes(),
stream.into(),
&[],
)
.await
.unwrap();
let request = sent(&server).await;
assert_eq!(request["labels"], json!({"cascade_id":"conversation"}));
assert_eq!(
request["systemInstruction"]["parts"]
.as_array()
.unwrap()
.last(),
Some(&history["systemInstruction"]["parts"][0])
);
assert_eq!(request["contents"][0], history["contents"][0]);
assert_eq!(request["contents"][2], history["contents"][2]);
let parts = &request["contents"][1]["parts"];
if target == source {
assert_eq!(parts[0], history["contents"][1]["parts"][0]);
assert_eq!(
parts[1],
json!({"text":"answer","thoughtSignature":original})
);
} else {
assert_eq!(parts, &json!([{"text":"answer"}]));
}
}
client
.count_tokens("token", body.as_bytes(), &[])
.await
.unwrap();
let request = sent(&server).await;
assert!(request.get("labels").is_none());
assert_eq!(
request["contents"][1]["parts"][0],
history["contents"][1]["parts"][0]
);
assert_eq!(
request["contents"][1]["parts"][1]["thoughtSignature"],
original
);
}
assert_eq!(response(&client, "other-model", true).await.0, reply);
}
}
#[tokio::test]
async fn foreign_tool_history_keeps_calls_results_and_valid_gemini_signatures() {
let (server, client) = fixture("{}").await;
let claude = claude_signature();
let gemini = gemini_signature();
let history = json!({"contents":[
{"role":"model","parts":[{"thought":true,"text":"old reasoning","thoughtSignature":claude},{"thoughtSignature":claude}]},
{"role":"model","parts":[{"thought":true,"text":"old reasoning"},
{"text":"old answer","thoughtSignature":claude},
{"functionCall":{"name":"first","args":{"thoughtSignature":"business data"}},"thought":true,"thoughtSignature":claude},
{"functionCall":{"name":"second","args":{}}}]},
{"role":"user","parts":[{"functionResponse":{"name":"first","response":{"ok":true}}},{"functionResponse":{"name":"second","response":{"ok":false}}}]},
{"role":"model","parts":[{"thought":true,"text":"current reasoning"},{"functionCall":{"name":"third","args":{}},"thoughtSignature":gemini}]}
]});
let body = serde_json::to_string(&history).unwrap().replace(
r#""args":{"thoughtSignature":"business data"}"#,
r#""args":{ "thoughtSignature":"business data", "n":1e+09,"n":98765432109876543210987654 }"#,
);
client
.generate(
"project",
"gemini-4-hydrogen-medium",
"token",
body.as_bytes(),
true.into(),
&[],
)
.await
.unwrap();
let request = sent(&server).await;
let requests = server.received_requests().await.unwrap();
assert!(std::str::from_utf8(&requests.last().unwrap().body).unwrap()
.contains(r#"{ "thoughtSignature":"business data", "n":1e+09,"n":98765432109876543210987654 }"#));
let contents = request["contents"].as_array().unwrap();
assert_eq!(contents.len(), 3);
assert_eq!(contents[0]["parts"][0], json!({"text":"old answer"}));
assert_eq!(
contents[0]["parts"][1]["thoughtSignature"],
"skip_thought_signature_validator"
);
assert_eq!(contents[0]["parts"][1]["functionCall"]["name"], "first");
assert!(contents[0]["parts"][1].get("thought").is_none());
assert_eq!(contents[0]["parts"][2], history["contents"][1]["parts"][3]);
assert_eq!(contents[1], history["contents"][2]);
assert_eq!(contents[2]["parts"][0], history["contents"][3]["parts"][0]);
assert_eq!(contents[2]["parts"][1]["thoughtSignature"], gemini);
}
#[tokio::test]
async fn unknown_or_malformed_history_is_not_reinterpreted() {
let (server, client) = fixture("{}").await;
for body in [
r#"{ "contents" : [ { "role":"model", "parts" : [{"thought":true,"text":"keep"},{"text":"answer","thoughtSignature":"b3BhcXVl"},{"functionCall":{"name":"x","args":{"n":1e+09,"n":98765432109876543210987654}}}] } ] }"#,
r#"{"contents":[{"role":"model","parts":[{"thoughtSignature":123}]}]}"#,
] {
client
.generate(
"project",
"gemini-4-hydrogen",
"token",
body.as_bytes(),
false.into(),
&[],
)
.await
.unwrap();
let requests = server.received_requests().await.unwrap();
let envelope: std::collections::BTreeMap<String, &RawValue> =
serde_json::from_slice(&requests.last().unwrap().body).unwrap();
let request: std::collections::BTreeMap<String, &RawValue> =
serde_json::from_str(envelope["request"].get()).unwrap();
let original: std::collections::BTreeMap<String, &RawValue> =
serde_json::from_str(body).unwrap();
assert_eq!(request["contents"].get(), original["contents"].get());
}
}
#[tokio::test]
async fn envelope_recognition_preserves_unknown_truncated_and_ambiguous_signatures() {
let (server, client) = fixture("{}").await;
let mut duplicate_version = claude_envelope(20);
duplicate_version.extend([8, 4]);
let mut duplicate_container = claude_envelope(20);
duplicate_container.extend(bytes_field(2, &[]));
let mut future_version = claude_envelope(20);
future_version[1] = 5;
let mut truncated = claude_envelope(20);
truncated.pop();
let mut gemini_with_trailer = gemini_envelope();
gemini_with_trailer.extend([24, 1]);
let mut claude_with_extension = claude_envelope(21);
claude_with_extension.extend([0x25, 1, 2, 3, 4]);
let mut rotated_key = vec![1, 9, 8, 7, 6];
rotated_key.extend([0x42; 32]);
let double = |value: Vec<u8>| STANDARD.encode(STANDARD.encode(value));
for (signature, source) in [
(double(claude_with_extension), Some("claude")),
(STANDARD.encode(claude_envelope(20)), Some("claude")),
(
STANDARD.encode(bytes_field(2, &bytes_field(1, &rotated_key))),
Some("gemini"),
),
(double(duplicate_version), None),
(double(duplicate_container), None),
(double(future_version), None),
(double(truncated), None),
(STANDARD.encode(gemini_with_trailer), None),
(
STANDARD.encode(bytes_field(2, &bytes_field(1, &[0x42; 160]))),
None,
),
(
STANDARD.encode([
0x12, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 2,
]),
None,
),
(STANDARD.encode([8, 4, 0, 0]), None),
("CA==".to_owned(), None),
("not-base64".to_owned(), None),
("skip_thought_signature_validator".to_owned(), None),
] {
let history = json!({"contents":[{"role":"model","parts":[
{"thought":true,"text":"reasoning"},
{"text":"answer","thought_signature":signature}
]}]});
let body = serde_json::to_vec(&history).unwrap();
for target in ["claude", "gemini"] {
client
.generate(
"project",
&format!("{target}-fixture"),
"token",
&body,
false.into(),
&[],
)
.await
.unwrap();
let request = sent(&server).await;
if source.is_some_and(|source| source != target) {
assert_eq!(request["contents"][0]["parts"], json!([{"text":"answer"}]));
} else {
assert_eq!(request["contents"], history["contents"]);
}
}
}
}
#[tokio::test]
async fn mixed_sources_do_not_assign_unsigned_thoughts_to_a_foreign_signature() {
let (server, client) = fixture("{}").await;
let history = json!({"contents":[{"role":"model","parts":[
{"thought":true,"text":"unsigned reasoning"},
{"thought":true,"text":"foreign reasoning","thoughtSignature":claude_signature()},
{"thought":true,"text":"unknown reasoning","thoughtSignature":"opaque"},
{"text":"answer","thoughtSignature":gemini_signature()}
]}]});
client
.generate(
"project",
"gemini-4-hydrogen",
"token",
&serde_json::to_vec(&history).unwrap(),
false.into(),
&[],
)
.await
.unwrap();
assert_eq!(
sent(&server).await["contents"][0]["parts"],
json!([
history["contents"][0]["parts"][0],
history["contents"][0]["parts"][2],
history["contents"][0]["parts"][3]
])
);
}
@@ -2030,7 +2030,7 @@ async fn provider_should_override_unclassified_time_contexts_over_websocket() {
body.pointer("/input/1/content/0/text"),
Some(&json!(desktop.replace("Asia/Shanghai", "Pacific/Auckland")))
);
assert_eq!(body.get("request_country"), Some(&json!("NZ")));
assert_eq!(body.get("request_country"), Some(&Value::Null));
assert_eq!(
body.pointer("/input/0/content/0/text"),
Some(&json!(
@@ -6342,6 +6342,7 @@ async fn runtime_routing_headers_override_request_identity_and_clear_when_unset(
{
let settings = if index == 0 {
gateway_core::settings::OpenAiRequestSettings {
residency: Some("us".to_owned()),
account_routing_override: Some("us_cr".to_owned()),
..Default::default()
}
@@ -13770,10 +13771,7 @@ async fn downstream_client_markers_preserve_instruction_content() {
let sent = capture_client_request(body.clone(), context, api_key).await;
let mut expected = body;
if !api_key {
expected.insert(
"request_country".to_owned(),
json!(global_request_location().country),
);
expected.insert("request_country".to_owned(), Value::Null);
}
assert_eq!(sent, expected);
}
@@ -92,13 +92,13 @@ async fn responses_options_follow_the_selected_upstream_on_both_transports() {
#[tokio::test]
async fn request_country_follows_the_selected_account_across_transports() {
use OpenAiRequestCountry::{Custom, Default, FollowLocation, Passthrough};
use OpenAiRequestCountry::{Custom, FollowLocation, Passthrough};
let location = global_request_location();
for (policy, location, input, oauth_country) in [
(FollowLocation {}, None, None, Some(Value::Null)),
(FollowLocation {}, Some(&location), None, Some(json!("NZ"))),
(
Default {},
OpenAiRequestCountry::default(),
Some(&location),
Some(json!("CA")),
Some(Value::Null),
@@ -150,7 +150,7 @@ async fn model_transports_apply_routing_settings_with_or_without_client_headers(
"x-openai-account-routing-override",
];
for (document, expected) in [
(r#"{}"#, [Some("us"), None]),
(r#"{}"#, [None, None]),
(
r#"{"residency":null,"accountRoutingOverride":null}"#,
[None, None],
@@ -161,7 +161,7 @@ async fn model_transports_apply_routing_settings_with_or_without_client_headers(
),
(
r#"{"accountRoutingOverride":"us_cr"}"#,
[Some("us"), Some("us_cr")],
[None, Some("us_cr")],
),
(
r#"{"residency":"custom-region"}"#,
@@ -173,7 +173,7 @@ async fn model_transports_apply_routing_settings_with_or_without_client_headers(
),
(
r#"{"accountRoutingOverride":"NO_CONSTRAINT"}"#,
[Some("us"), Some("NO_CONSTRAINT")],
[None, Some("NO_CONSTRAINT")],
),
] {
for (websocket, has_downstream_headers) in
+1
View File
@@ -50,3 +50,4 @@ e115a71b80faa08be4cf4f8747eec01e7b855ad3d8aa9622ca70b57300847b54 0046_account_a
c62495a0aff26b149381370fe1eea656091ab8d9d7d55aee27be4f56d5885fd3 0050_prompt_rewrite_rules.sql
c4cc50c137deabae7895b97a8a8681c618f2b856276455d591475a02956ee373 0051_account_platform_icons.sql
5911268734a4dddf099e747bdc684ef184b5861dd6fec0482c8da5f0eb35104c 0052_storage_write_efficiency.sql
8118a6176c69ee64e5503f9d07043604679345e5e9e16f9dc606a58bfbc64442 0053_openai_request_defaults.sql
@@ -0,0 +1,15 @@
alter table runtime_settings
alter column openai_request_settings_json set default '{"requestCountry":{"mode":"default"},"oauthGuardianReviewModel":true,"residency":null,"accountRoutingOverride":null}'::jsonb;
-- 仅调整旧默认值,保留自定义国家、透传模式及其他驻留和路由配置
update runtime_settings
set openai_request_settings_json = openai_request_settings_json
|| case when openai_request_settings_json->'requestCountry' = '{"mode":"follow_location"}'::jsonb
then '{"requestCountry":{"mode":"default"}}'::jsonb else '{}'::jsonb end
|| case when openai_request_settings_json->'residency' = '"us"'::jsonb
then '{"residency":null}'::jsonb else '{}'::jsonb end,
settings_revision = config_revision + 1,
config_revision = config_revision + 1,
updated_at = now()
where openai_request_settings_json->'requestCountry' = '{"mode":"follow_location"}'::jsonb
or openai_request_settings_json->'residency' = '"us"'::jsonb;
+4 -1
View File
@@ -418,7 +418,7 @@ PostgreSQL/Redis 启动密码。日常校验使用 `config --quiet`
| 并发与排队 | “系统设置 → 通用设置 → 并发与排队”分别配置 Key 与账号的排队容量和超时。账号排队失败后的处理在同页“重试与换号”中设置,见[排队规则](../docs/api.md#并发与排队) |
| 账号错误保护 | “系统设置 → 通用设置 → 错误保护”默认关闭,按[自定义规则](../docs/api.md#账号错误保护)暂停账号调度 |
| 全局请求位置 | “系统设置 → 平台设置 → OpenAI → 请求位置覆盖”,默认关闭 |
| Codex OAuth 请求国家 | “系统设置 → 平台设置 → OpenAI → 请求国家”,默认跟随位置,也可选择“空值”“透传”或“自定义” |
| Codex OAuth 请求国家 | “系统设置 → 平台设置 → OpenAI → 请求国家”,默认“空值”,也可选择“跟随位置”“透传”或“自定义” |
| OpenAI OAuth 同步审核模型 | “系统设置 → 平台设置 → OpenAI → 自动审批”中的“专用审核模型”默认开启,关闭后沿用客户端模型。[适用条件](../docs/api.md#正文兼容) |
| 代理位置 | “代理管理”;优先于全局位置,全局关闭时仍可独立生效 |
@@ -426,6 +426,9 @@ PostgreSQL/Redis 启动密码。日常校验使用 `config --quiet`
数据驻留与账号路由在“系统设置 → 平台设置 → OpenAI → 请求设置”中填写,支持自定义值,留空删除对应请求头。
保存后对新请求生效,无需重启。字段与适用范围见 [运行设置 API](../docs/api.md#数据驻留与路由)
已有部署若在 `config.yaml` 中设置了 `openai.residency` 或 `openai.account_routing_override`,升级后须在平台设置中重新保存,并删除配置文件中的旧字段
升级迁移会一次性清空数据驻留 `us`,并将请求国家“跟随位置”改为“空值”,其他已配置值保持不变。需要这两项原值的部署,升级后在平台设置中重新保存
OAuth 续期和额度刷新等后台操作使用对应平台的全局客户端身份。发布资料刷新不改写用户选择或 `config.yaml`,见 [Provider 客户端身份](../docs/api.md#provider-客户端身份)
### CPR 互联
+12 -8
View File
@@ -266,7 +266,7 @@ AGY 在 API Key 模式下使用 `gemini-3.1-flash-lite-preview` 发起同样的
| GET | `/v1beta/models`、`/v1beta/models/{model}` | Gemini 格式的模型列表与详情,见[模型目录](#模型目录) |
| POST | `/v1beta:{method}`(客户端后台指标) | 验证 Key 后返回 `{}`,不启动模型请求 |
普通生成从上游 JSON 的 `response` 中取出原生正文,流式生成逐个解开 SSE 数据帧。等待首帧和后续帧时,网关保持静默。首帧前的失败保留 HTTP 错误状态。原生正文保留工具参数、结果、思考签名和未知字段。客户端归属读取 `User-Agent`、`X-Goog-Api-Client`。网关错误使用 Google RPC 风格的 `error.code`、`error.status` 和 `error.message`。[Google 原生生成协议](https://ai.google.dev/api/generate-content)
普通生成从上游 JSON 的 `response` 中取出原生正文,流式生成逐个解开 SSE 数据帧。等待首帧和后续帧时,网关保持静默。首帧前的失败保留 HTTP 错误状态。原生正文保留工具参数、结果和未知字段,思考签名按下述来源规则处理。客户端归属读取 `User-Agent`、`X-Goog-Api-Client`。网关错误使用 Google RPC 风格的 `error.code`、`error.status` 和 `error.message`。[Google 原生生成协议](https://ai.google.dev/api/generate-content)
CPR 在 AGY 的原生与转换入口透传未被过滤的 HTTP 扩展头,保留同名多值的原始字节。下游鉴权、Cookie、账号身份、客户端画像和 HTTP 传输头不透传;认证、项目和 UA 由所选 OAuth 账号与冻结画像生成。`X-Goog-Api-Client` 与 Gateway 的 `X-Goog-Ext-525006001-Bin` 不进入 Cloud Code 请求。`X-Goog-User-Project` 属于调用方指定的计费项目,不能覆盖所选账号的项目,见 [Google 系统参数](https://docs.cloud.google.com/apis/docs/system-parameters)
@@ -274,6 +274,10 @@ Cloud Code 生成封套使用 `userAgent: "antigravity"` 与 `requestType: "agen
Claude 原生生成兼容缺失工具 ID 的历史:仅在相邻 `model`/`user` 轮次中,调用和结果的工具名各自唯一时补齐缺失的 `id`。一侧已有 ID 时沿用该 ID;两侧均缺失时生成确定性配对 ID,并避开正文已有 ID。已有字段、参数、结果和思考签名保持原样;同名并行调用、孤立结果、ID 冲突或格式错误不猜测配对,继续由上游校验。该兼容不作用于 Gemini、Chat 转换、独立搜索或输入计数
原生响应的思考签名保持上游原值,不添加网关标记。Claude/Gemini 生成根据已知原生封套识别来源,只移除可识别的异家族签名及对应思考内容,保留普通文本、工具调用和结果。导入 Gemini 的工具历史中,各轮首个工具调用缺少签名时使用官方 `skip_thought_signature_validator` 占位
签名处理不依赖服务端会话缓存。同家族、输入计数及无法识别的签名保持原样;封套识别不验证签名真伪,也不保证跨账号或项目复用。未知格式的旧历史切换模型仍可能被上游拒绝,此时需新建会话或 `/clear`
同账号及归属未知时保留追踪头;会话绑定或本次执行的已有账号归属明确发生切换时,CPR 清理入站或中间件带入的 `traceparent`、`tracestate`、`sentry-trace`、`baggage`。该清理作用于本次出站请求,不修改工具结果、思考签名或业务正文
原生生成依次使用 `X-Http-Session-Id`、`X-Session-Id`、正文 `sessionId`/`session_id` 识别会话,绑定按 Client Key、模型和入站协议隔离。会话识别只用于本地调度,保留客户端正文中的原值
@@ -284,10 +288,10 @@ AGY 上游计数与生成响应的 `usageMetadata.promptTokenCount` 口径不完
Antigravity 模型也可通过 `/v1/chat/completions` 调用,支持 JSON 与 SSE;不接受 Responses 或 Messages 的内置跨协议调用。
Chat 直接映射文本、图片/文档、函数与 custom 工具历史、生成参数和 JSON Schema。未知内容块或无法表达的语义返回请求错误,模型参数的实际支持范围由上游校验。
原生入口保留工具结果和思考签名;常规生成与计数共用上述系统指令合成规则
原生入口保留工具结果,思考签名按上述来源规则处理;常规生成与计数共用上述系统指令合成规则
Chat 工具多轮调用须携带完整助手输出和对应结果。Chat 只返回可读思考内容;对 Chat 历史中的工具调用使用 Google 的 `skip_thought_signature_validator` 标记,不增加服务端签名缓存。
原生 GenAI 的真实签名仍原样回传,见 [Google 签名规则](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/thinking/thought-signatures)
原生 GenAI 按上述来源规则保留真实签名,不以占位值替换同家族签名,见 [Google 签名规则](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/thinking/thought-signatures)
### Chat Completions 请求
@@ -2428,9 +2432,9 @@ Antigravity 不应用这组国家、区域、城市和时区覆盖,原生请
```json
{
"requestCountry": { "mode": "follow_location" },
"requestCountry": { "mode": "default" },
"oauthGuardianReviewModel": true,
"residency": "us",
"residency": null,
"accountRoutingOverride": null
}
```
@@ -2441,14 +2445,14 @@ Antigravity 不应用这组国家、区域、城市和时区覆盖,原生请
| 管理端选项 | 设置值 | 发往上游的字段 |
| --- | --- | --- |
| 跟随位置 | `{"mode":"follow_location"}` | 默认选项。先取代理位置,再取已开启的全局位置。两者都没有时发送 `null` |
| 空值 | `{"mode":"default"}` | 始终发送 `"request_country": null`,包括客户端传入国家、代理或全局位置已配置的情况 |
| 跟随位置 | `{"mode":"follow_location"}` | 先取代理位置,再取已开启的全局位置。两者都没有时发送 `null` |
| 空值 | `{"mode":"default"}` | 默认选项。始终发送 `"request_country": null`,包括客户端传入国家、代理或全局位置已配置的情况 |
| 透传 | `{"mode":"passthrough"}` | 保留客户端原值,包括显式 `null`;客户端省略时也省略 |
| 自定义 | `{"mode":"custom","country":"CA"}` | 始终发送指定的两位大写 ASCII 国家码,独立于城市、时区和全局位置开关 |
#### 数据驻留与路由
`openaiRequestSettings` 中的 `residency` 和 `accountRoutingOverride` 独立于客户端身份与请求位置,均为可选字符串,默认值分别为 `"us"` 和 `null`,分别设置 `x-openai-internal-codex-residency` 和
`openaiRequestSettings` 中的 `residency` 和 `accountRoutingOverride` 独立于客户端身份与请求位置,均为可选字符串,默认 `null`,分别设置 `x-openai-internal-codex-residency` 和
`x-openai-account-routing-override`。值必须能作为 HTTP/WebSocket 请求头发送(ASCII 文本),原样保留,不限制为固定选项。
参考值分别为 `us` 和 `us`、`us_cr`。字段省略或为 `null` 时删除对应请求头,空字符串发送空头值;管理端留空保存为 `null`
+1 -1
View File
@@ -605,7 +605,7 @@ Antigravity 目录声明原生 GenAI 和 Chat 转换能力,Responses、Message
`provider/chat.rs` 装配 Chat ↔ GenAI 直接转换;`transport` 负责 Cloud Code 封装、原生 wire 与调用事实,
原生生成与计数前置冻结画像的系统提示,普通 Chat 使用转换后的系统指令
Claude 原生生成的缺失工具 ID 兼容由 Antigravity `transport` 在出站副本上完成,只使用当前请求中可唯一配对的历史,不增加会话缓存或改变 Core 调度。配对边界见 [Antigravity 客户端原生生成](api.md#antigravity-客户端原生生成)
Claude 原生生成的缺失工具 ID 配对,以及 Claude/Gemini 原生签名封套识别和跨家族思考历史清理由 Antigravity `transport` 持有。签名处理并入请求字段编辑,兼容或未知来源的历史复用原始内容,响应不改写签名;不增加会话缓存或改变 Core 调度。处理边界见 [Antigravity 客户端原生生成](api.md#antigravity-客户端原生生成)
Antigravity 的业务头使用 API 保留的不透明多值字节,transport 统一执行账号身份、HTTP 传输及切号追踪头过滤。选号阶段从原会话绑定和 Core 的账号归属冻结切号事实,认领冲突后重新读取,不从重试排除集合推测归属
+1 -1
View File
@@ -16,7 +16,7 @@
"build:source": "vue-tsc -p tsconfig.source.json --noEmit && vite build --mode source"
},
"dependencies": {
"@codex-proxy/ui": "github:zyycn/codex-proxy-ui#6ae11ac8b3509307a7efd54e6e4c2fc8fae98b89",
"@codex-proxy/ui": "github:zyycn/codex-proxy-ui#5f38c8bacd53e4669c0cfa57b961c8d97085ff9f",
"@fontsource-variable/inter": "^5.3.0",
"@fontsource-variable/jetbrains-mono": "^5.3.0",
"@lobehub/icons-vue": "1.2.0",
+5 -5
View File
@@ -192,8 +192,8 @@ importers:
.:
dependencies:
'@codex-proxy/ui':
specifier: github:zyycn/codex-proxy-ui#6ae11ac8b3509307a7efd54e6e4c2fc8fae98b89
version: https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/6ae11ac8b3509307a7efd54e6e4c2fc8fae98b89(axios@1.21.1(debug@4.4.3))(change-case@5.4.4)(jiti@2.7.0)(postcss@8.5.30)(vite@8.4.0(@types/node@26.6.11)(jiti@2.7.0)(yaml@2.9.0))(vue@3.5.46(typescript@6.0.3))(yaml@2.9.0)
specifier: github:zyycn/codex-proxy-ui#5f38c8bacd53e4669c0cfa57b961c8d97085ff9f
version: https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/5f38c8bacd53e4669c0cfa57b961c8d97085ff9f(axios@1.21.1(debug@4.4.3))(change-case@5.4.4)(jiti@2.7.0)(postcss@8.5.30)(vite@8.4.0(@types/node@26.6.11)(jiti@2.7.0)(yaml@2.9.0))(vue@3.5.46(typescript@6.0.3))(yaml@2.9.0)
'@fontsource-variable/inter':
specifier: ^5.3.0
version: 5.3.0
@@ -451,8 +451,8 @@ packages:
resolution: {integrity: sha512-dlT1m5e/0yUL0kRNcQn7yGLVThkgbB0Ga/1AmfDDC/8ik6AIiSf2QLQO2zPYvefsHP0aFgxO93cVLCCfDp7kzQ==}
engines: {node: '>= 20.12.0'}
'@codex-proxy/ui@https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/6ae11ac8b3509307a7efd54e6e4c2fc8fae98b89':
resolution: {gitHosted: true, integrity: sha512-HpFUCs+1qvcOtMrt8uoRdF/nABwnMeT2ziObJr3r+SMulIS9JKdMSQc3f+ZfsEn0iPR2Fmh6xXg/5QgWx8KNqA==, tarball: https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/6ae11ac8b3509307a7efd54e6e4c2fc8fae98b89}
'@codex-proxy/ui@https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/5f38c8bacd53e4669c0cfa57b961c8d97085ff9f':
resolution: {gitHosted: true, integrity: sha512-mwiaZaxYlA2MeAErOGCr5MlsLmxJSTySEA9fUErfaAFl0AZoaIsfTo+Bd6L+x8/kTL5xRIK8VVfju2MQXqNPrA==, tarball: https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/5f38c8bacd53e4669c0cfa57b961c8d97085ff9f}
version: 0.14.0
engines: {node: '>=24'}
peerDependencies:
@@ -3559,7 +3559,7 @@ snapshots:
fast-wrap-ansi: 0.2.2
sisteransi: 1.0.5
'@codex-proxy/ui@https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/6ae11ac8b3509307a7efd54e6e4c2fc8fae98b89(axios@1.21.1(debug@4.4.3))(change-case@5.4.4)(jiti@2.7.0)(postcss@8.5.30)(vite@8.4.0(@types/node@26.6.11)(jiti@2.7.0)(yaml@2.9.0))(vue@3.5.46(typescript@6.0.3))(yaml@2.9.0)':
'@codex-proxy/ui@https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/5f38c8bacd53e4669c0cfa57b961c8d97085ff9f(axios@1.21.1(debug@4.4.3))(change-case@5.4.4)(jiti@2.7.0)(postcss@8.5.30)(vite@8.4.0(@types/node@26.6.11)(jiti@2.7.0)(yaml@2.9.0))(vue@3.5.46(typescript@6.0.3))(yaml@2.9.0)':
dependencies:
'@ant-design/colors': 8.0.1
'@ant-design/fast-color': 3.0.1
+1 -1
View File
@@ -11,7 +11,7 @@ const canHover = useMediaQuery('(hover: hover)')
<template>
<ZPopover class="h-4 items-center" :trigger="canHover ? 'hover-click' : 'click'" placement="top-start" :hover-delay="240">
<template #reference="{ open }">
<ZIconButton variant="link" size="small" class="w-4!" :aria-label="label" :aria-expanded="open" aria-haspopup="dialog">
<ZIconButton variant="link" size="small" class="size-6!" :aria-label="label" :aria-expanded="open" aria-haspopup="dialog">
<CircleAlert class="size-3" aria-hidden="true" />
</ZIconButton>
</template>
+1 -1
View File
@@ -816,7 +816,7 @@
"residencyPlaceholder": "us",
"accountRoutingOverride": "Account routing",
"accountRoutingPlaceholder": "us / us_cr",
"residencyHelp": "Defaults to us, sends the residency header as entered, clearing the field removes the header",
"residencyHelp": "Blank by default, sends the residency header as entered, clearing the field removes the header",
"accountRoutingOverrideHelp": "Defaults to blank, reference values are us and us_cr, sends the routing header as entered, clearing the field removes the header",
"description": "Configure parameters sent to the upstream provider"
},
@@ -816,7 +816,7 @@
"residencyPlaceholder": "us",
"accountRoutingOverride": "账号路由",
"accountRoutingPlaceholder": "us / us_cr",
"residencyHelp": "默认 us,按填写值发送数据驻留请求头,留空则删除此请求头",
"residencyHelp": "默认留空,按填写值发送数据驻留请求头,留空则删除此请求头",
"accountRoutingOverrideHelp": "默认留空,可填写 us 或 us_cr,按填写值发送账号路由请求头,留空则删除此请求头",
"description": "配置发往上游的请求参数"
},
@@ -816,7 +816,7 @@
"residencyPlaceholder": "us",
"accountRoutingOverride": "帳號路由",
"accountRoutingPlaceholder": "us / us_cr",
"residencyHelp": "預設 us,依填寫值傳送資料駐留請求標頭,留空則刪除此標頭",
"residencyHelp": "預設留空,依填寫值傳送資料駐留請求標頭,留空則刪除此標頭",
"accountRoutingOverrideHelp": "預設留空,可填寫 us 或 us_cr,依填寫值傳送帳號路由請求標頭,留空則刪除此標頭",
"description": "配置發往上游的請求參數"
},
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { ZCard, ZFormItem, ZIconButton, ZInput, ZPopover, ZSwitch } from '@codex-proxy/ui'
import { CircleAlert } from '@lucide/vue'
import { ZCard, ZFormItem, ZInput, ZSwitch } from '@codex-proxy/ui'
import { useI18n } from 'vue-i18n'
import HelpPopover from '@/components/HelpPopover.vue'
@@ -34,17 +33,12 @@ const reservedConcurrency = defineModel<string>('reservedConcurrency', { require
</ZFormItem>
<ZFormItem :show-message="Boolean(reservedConcurrency.trim())" prop="openaiGuardianReservedConcurrency" :label="t('settings.concurrency.autoReview.label')" :description="t('settings.concurrency.autoReview.description')">
<template #label-extra>
<ZPopover class="-my-1" trigger="hover-click" placement="top-start">
<template #reference="{ open }">
<ZIconButton variant="link" :aria-label="t('settings.concurrency.autoReview.helpTitle')" :aria-expanded="open" class="size-6!">
<CircleAlert class="size-3.5" aria-hidden="true" />
</ZIconButton>
</template>
<div class="max-w-72 space-y-2 px-3 py-2 text-z-sm leading-relaxed text-z-text-secondary">
<HelpPopover :label="t('settings.concurrency.autoReview.helpTitle')">
<div class="space-y-2">
<p>{{ t('settings.scheduling.autoReviewSlotsHelp') }}</p>
<p>{{ t('settings.scheduling.autoReviewQueueHelp') }}</p>
</div>
</ZPopover>
</HelpPopover>
</template>
<ZInput v-model="reservedConcurrency" :aria-label="t('settings.concurrency.autoReview.label')" :disabled="disabled" type="number" min="0" max="4294967295" step="1" />
</ZFormItem>
@@ -42,7 +42,7 @@ export function useSettingsForm() {
streamIdleTimeoutMs: null as number | null,
},
openaiRequestSettings: {
requestCountry: { mode: 'follow_location' } as OpenAiRequestCountry,
requestCountry: { mode: 'default' } as OpenAiRequestCountry,
oauthGuardianReviewModel: true,
residency: '',
accountRoutingOverride: '',
+13 -11
View File
@@ -1,15 +1,17 @@
# v3.60.3
# v3.60.4
## 优化改进
- Codex 出站 HTTP/2 使用与官方客户端一致的 h2 0.4.19
> [!IMPORTANT]
> **OpenAI 请求默认值与数据库升级**
>
> - 请求国家:默认由“跟随位置”改为“空值”(`request_country: null`)
> - 数据驻留:默认由 `us` 改为留空,不再发送驻留请求头
> - 账号路由覆盖:默认仍为留空,已有配置保持不变
>
> 升级会一次性将数据库中的“跟随位置”改为“空值”,并清空驻留值 `us`,包括手动保存的同值设置;自定义国家、透传模式和其他驻留值保持不变
>
> 仍需原值的部署,请在升级后进入“系统设置 → 平台设置 → OpenAI”重新保存
## 问题修复
- 修复 Antigravity 原生调用 Claude 时因历史缺少工具 ID 导致的请求失败,自动补齐可唯一配对的工具调用和结果 ID
- 插件取消发送与确认等待分别使用宿主排队期限(默认各 30 秒),避免批量取消时误关正常会话
- 对齐 xAI 与 Grok CLI 的连接行为,原生 Responses 保留上游 SSE 帧,并过滤来自下游的代理和客户端环境头
## 升级须知
- xAI 原生续接失效时返回 `previous_response_not_found`,由客户端携带完整历史重发
- 修复 Antigravity 在 Claude 与 Gemini 之间切换时的已知思考签名冲突,保留同家族及无法识别的原生签名
- 修复系统设置帮助按钮的背景与尺寸不一致,统一请求设置和自动审批的提示交互
+5 -5
View File
@@ -1,7 +1,7 @@
version: 3.60.3
version: 3.60.4
published:
'3':
stable: 3.60.2
rc: 3.60.2
beta: 3.60.2
alpha: 3.60.2
stable: 3.60.3
rc: 3.60.3
beta: 3.60.3
alpha: 3.60.3