mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-12-04 08:00:59 +00:00
Compare commits
8
Commits
v3.61.1-rc.4
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c71e6176c5 | ||
|
|
28d3e3c2cb | ||
|
|
dd793a84ab | ||
|
|
5ed8b626d7 | ||
|
|
96d8b25d0b | ||
|
|
a193de4eba | ||
|
|
e296bef65e | ||
|
|
89092272a1 |
@@ -16,6 +16,8 @@ description: Codex Proxy RS 的需求评估、排障、开发、代码审查与
|
||||
|
||||
评估功能建议、排障、开发和审查时,先按[问题与方案依据](../../../CONTRIBUTING.md#问题与方案依据)核实使用者要完成什么、当前行为造成了什么影响。反馈直接给出改法时,先弄清提出这个改法的原因
|
||||
|
||||
先确定正常使用时应得到的结果。设计校验、回退或故障恢复时,同时看它防住的具体风险和它可能挡住的正常用法。按协议、隔离要求和实际部署条件选择对正常路径影响最小的做法。只在假设的部署场景下才需要的处理,留到有相应需求时再做
|
||||
|
||||
排查故障时,从症状沿实际调用链回溯,定位行为最早偏离预期的环节,用源码、诊断或对照复现说明触发条件如何导致结果。原因尚未确定时,区分已知事实与假设,指出哪项证据能区分可能原因。确认根因后,在负责该行为的模块修复,用原触发场景验证
|
||||
|
||||
涉及 Codex 时,以对应版本的官方源码核实客户端行为,默认透明转发,只做必要适配。建议宿主接管已有决定时,指出需要它介入的网关职责或实际约束。若只是个别部署希望采用不同策略,说明不建议内置的原因。实现可行性不能证明宿主应当承担这项需求
|
||||
@@ -56,7 +58,7 @@ description: Codex Proxy RS 的需求评估、排障、开发、代码审查与
|
||||
- 移动或重命名测试时,核对受影响的场景覆盖是否保留;涉及子进程调用或名称过滤时,同步更新调用入口并实际运行,确认目标用例确实执行且行为断言通过
|
||||
- 清理只证明旧字段、旧路由或旧实现已经消失的用例与附带断言;未知字段校验使用合法请求基线加无业务含义的未知字段,避免因缺少必填项等其他错误而误通过
|
||||
- 同一层对同一行为的重复覆盖合并为清晰的场景矩阵,复用相邻测试夹具;跨层测试确有不同职责或失败路径时保留,不为统一而扩大测试辅助抽象
|
||||
- 断言可观察的行为与业务不变量,避免复述结构体赋值、罗列表列或字段清单、匹配 SQL 文本与源码布局
|
||||
- 断言可观察的行为与业务不变量,避免复述实现细节。验收上游兼容行为时,先从对应版本的上游实现确定预期,再核对网关对同一输入的处理。例如历史应增量续接时,要看出站请求是否只含预期的增量,因为回退全量也可能返回成功
|
||||
- 维护项目明确要求的架构边界检查;发现漏检时,对照规则核实扫描范围、排除项与被检查的依赖关系,优先补齐现有检查中能稳定判定的缺口
|
||||
- 当前协议兼容、数据读取兼容、安全边界、并发和资源生命周期仍需覆盖,不按 `old`、`legacy` 等名称机械删除,也不能用改名代替无效用例清理
|
||||
- 不在仓库中新增或保留迁移 SQL 专项测试,包括迁移文本、schema 演变与指定版本升级用例;需要验证迁移执行、数据保留或回滚时,在临时目录编写一次性验证并使用隔离数据库,测试通过即可,临时脚本不纳入维护测试集
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
[](https://github.com/zyycn/codex-proxy-rs/pkgs/container/codex-proxy-rs)
|
||||
[](LICENSE)
|
||||
|
||||
[快速预览](#快速预览) · [快速开始](#快速开始) · [文档](#文档) · [社区](#社区) · [贡献者](#贡献者) · [Star History](#star-history) · [支持项目](#支持项目) · [许可证](#许可证)
|
||||
[快速预览](#快速预览) · [快速开始](#快速开始) · [文档](#文档) · [贡献者](#贡献者) · [Star History](#star-history) · [社区](#社区) · [支持项目](#支持项目) · [许可证](#许可证)
|
||||
|
||||
</div>
|
||||
|
||||
@@ -49,12 +49,6 @@ curl -fsSL https://raw.githubusercontent.com/zyycn/codex-proxy-rs/main/deploy/in
|
||||
| 开发宿主 | [开发与源码联调](docs/development.md) · [系统架构](docs/architecture.md) · [管理端主题](docs/theme.md) · [数据库迁移](backend/migrations/README.md) |
|
||||
| 参与协作 | [贡献、审查与验证](CONTRIBUTING.md) |
|
||||
|
||||
## 社区
|
||||
|
||||
问题反馈与功能建议请使用 [GitHub Issues](https://github.com/zyycn/codex-proxy-rs/issues),填写要求见 [贡献说明](CONTRIBUTING.md#提交-issue)
|
||||
|
||||
感谢 [LINUX DO](https://linux.do) 社区提供开放、友善的技术交流平台
|
||||
|
||||
## 贡献者
|
||||
|
||||
[<img src="https://contrib.rocks/image?repo=zyycn/codex-proxy-rs&columns=10" alt="查看 GitHub 贡献者列表" width="480">](https://github.com/zyycn/codex-proxy-rs/graphs/contributors)
|
||||
@@ -68,6 +62,18 @@ curl -fsSL https://raw.githubusercontent.com/zyycn/codex-proxy-rs/main/deploy/in
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
## 社区
|
||||
|
||||
点击或扫码加入 Telegram 群 [小酒馆][telegram-group]
|
||||
|
||||
[<img src="docs/community/telegram-qr.png" alt="扫码加入小酒馆 Telegram 群" width="138">][telegram-group]
|
||||
|
||||
[telegram-group]: https://t.me/+9tk761zbNAMyNWY9
|
||||
|
||||
问题反馈与功能建议请使用 [GitHub Issues](https://github.com/zyycn/codex-proxy-rs/issues),填写要求见 [贡献说明](CONTRIBUTING.md#提交-issue)
|
||||
|
||||
感谢 [LINUX DO](https://linux.do) 社区提供开放、友善的技术交流平台
|
||||
|
||||
## 支持项目
|
||||
|
||||
如果 Codex Proxy RS 帮助到你了,欢迎请我喝杯咖啡 ☕
|
||||
|
||||
@@ -79,7 +79,11 @@ impl Providers {
|
||||
)
|
||||
.await?;
|
||||
environment.host.report_startup_ready("OpenAI Provider");
|
||||
let antigravity = provider_antigravity::initialize(ports.clone()).await?;
|
||||
let antigravity = provider_antigravity::initialize(
|
||||
ports.clone(),
|
||||
environment.host.runtime_data_dir().join("antigravity"),
|
||||
)
|
||||
.await?;
|
||||
environment
|
||||
.host
|
||||
.report_startup_ready("Antigravity Provider");
|
||||
|
||||
@@ -262,7 +262,8 @@ async fn request_middleware_sees_original_chat_and_preserves_the_endpoint() {
|
||||
{"role":"developer","content":"brief"},
|
||||
{"role":"system","content":null},
|
||||
{"role":"assistant","tool_calls":[]},
|
||||
{"role":"user","content":[{"type":"text","text":null},{"type":"text","text":"hello"}]}
|
||||
{"role":"user","content":[{"type":"text","text":null},{"type":"text","text":"hello"}]},
|
||||
{"role":"tool","name":"notifications","namespace":"agent","content":"notice"}
|
||||
]);
|
||||
let response = fixture.post(request.clone()).await;
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
|
||||
@@ -117,6 +117,11 @@ pub async fn initialize_command_line(mut config: HostConfig) -> Result<HostBundl
|
||||
}
|
||||
|
||||
impl HostBundle {
|
||||
/// 宿主配置解析后的运行数据目录,供需要磁盘空间的内置服务使用。
|
||||
pub fn runtime_data_dir(&self) -> &std::path::Path {
|
||||
self.config.runtime_data_dir()
|
||||
}
|
||||
|
||||
/// 向启动控制台报告一个组装阶段已就绪
|
||||
pub fn report_startup_ready(&self, service: &'static str) {
|
||||
tracing::info!(target: "gateway_startup", service, "服务启动正常");
|
||||
|
||||
@@ -59,11 +59,13 @@ pub fn validate_request(body: &Map<String, Value>) -> Result<(), ChatError> {
|
||||
}
|
||||
}
|
||||
if role == "tool" {
|
||||
string(
|
||||
message.get("tool_call_id"),
|
||||
&format!("{path}.tool_call_id"),
|
||||
false,
|
||||
)?;
|
||||
// Responses 的独立工具输出通过名称标识,不依赖前序调用
|
||||
let field = if message.get("tool_call_id").is_none_or(Value::is_null) {
|
||||
"name"
|
||||
} else {
|
||||
"tool_call_id"
|
||||
};
|
||||
string(message.get(field), &format!("{path}.{field}"), false)?;
|
||||
} else if message
|
||||
.get("tool_call_id")
|
||||
.is_some_and(|v| !v.is_null() && v != "")
|
||||
|
||||
@@ -166,12 +166,7 @@ fn messages(value: Value) -> Result<Vec<Value>, RequestDecodeError> {
|
||||
let mut message = object(value, &path)?;
|
||||
let role = required_string(&mut message, "role", &format!("{path}.role"), false)?;
|
||||
if role == "tool" {
|
||||
let call_id = required_string(
|
||||
&mut message,
|
||||
"tool_call_id",
|
||||
&format!("{path}.tool_call_id"),
|
||||
false,
|
||||
)?;
|
||||
let call_id = optional(&mut message, "tool_call_id");
|
||||
let content_path = format!("{path}.content");
|
||||
let content = required(&mut message, "content", &content_path)?;
|
||||
let output = if content.is_string() {
|
||||
@@ -179,15 +174,24 @@ fn messages(value: Value) -> Result<Vec<Value>, RequestDecodeError> {
|
||||
} else {
|
||||
content_parts(content, &role, &content_path, false)?.into()
|
||||
};
|
||||
let kind = if custom_calls.contains(&call_id) {
|
||||
let kind = if call_id
|
||||
.as_ref()
|
||||
.and_then(Value::as_str)
|
||||
.is_some_and(|id| custom_calls.contains(id))
|
||||
{
|
||||
"custom_tool_call_output"
|
||||
} else {
|
||||
"function_call_output"
|
||||
};
|
||||
let mut item = json!({"type": kind, "call_id": call_id, "output": output});
|
||||
if let Some(name) = optional(&mut message, "name").filter(|name| name != "") {
|
||||
string(&name, &format!("{path}.name"), true)?;
|
||||
item["name"] = name;
|
||||
let mut item = json!({"type": kind, "output": output});
|
||||
if let Some(call_id) = call_id {
|
||||
item["call_id"] = call_id;
|
||||
}
|
||||
for field in ["name", "namespace"] {
|
||||
if let Some(value) = optional(&mut message, field).filter(|value| value != "") {
|
||||
string(&value, &format!("{path}.{field}"), true)?;
|
||||
item[field] = value;
|
||||
}
|
||||
}
|
||||
input.push(item);
|
||||
continue;
|
||||
@@ -377,12 +381,13 @@ fn tools(value: Value) -> Result<Vec<Value>, RequestDecodeError> {
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(index, value)| {
|
||||
let path = format!("tools[{index}]");
|
||||
let mut path = format!("tools[{index}]");
|
||||
let mut tool = object(value, &path)?;
|
||||
let kind = required_string(&mut tool, "type", &format!("{path}.type"), false)?;
|
||||
if matches!(kind.as_str(), "function" | "custom") {
|
||||
if let Some(nested) = optional(&mut tool, &kind) {
|
||||
tool = object(nested, &format!("{path}.{kind}"))?;
|
||||
path = format!("{path}.{kind}");
|
||||
tool = object(nested, &path)?;
|
||||
}
|
||||
if tool.get("description") == Some(&Value::Null) {
|
||||
tool.remove("description");
|
||||
@@ -395,6 +400,14 @@ fn tools(value: Value) -> Result<Vec<Value>, RequestDecodeError> {
|
||||
// Chat 的缺省是宽松 schema,不能让 Responses 收紧参数合同
|
||||
tool.insert("strict".into(), false.into());
|
||||
}
|
||||
} else if let Some(format) = tool.get_mut("format").and_then(Value::as_object_mut)
|
||||
&& format.get("type").and_then(Value::as_str) == Some("grammar")
|
||||
&& let Some(grammar) = optional(format, "grammar")
|
||||
{
|
||||
// Chat 将语法嵌套在 grammar,Responses 使用同层的 syntax 和 definition
|
||||
let grammar = object(grammar, &format!("{path}.format.grammar"))?;
|
||||
format.extend(grammar);
|
||||
format.insert("type".into(), "grammar".into());
|
||||
}
|
||||
}
|
||||
// hosted 工具采用原生 Responses 结构,支持范围由选中的 Provider 决定
|
||||
|
||||
@@ -63,14 +63,48 @@ fn invalid_envelopes_and_chat_controls_keep_safe_field_errors() {
|
||||
|
||||
#[test]
|
||||
fn invalid_tool_history_reports_source_path() {
|
||||
let request = json!({"model":"m","messages":[{"role":"tool","content":"ok"}]});
|
||||
assert_eq!(
|
||||
parse_request(&serde_json::to_vec(&request).unwrap())
|
||||
.err()
|
||||
for (identity, parameter) in [
|
||||
(json!({}), "messages[0].name"),
|
||||
(json!({"name":null}), "messages[0].name"),
|
||||
(json!({"name":" "}), "messages[0].name"),
|
||||
(json!({"name":17}), "messages[0].name"),
|
||||
(
|
||||
json!({"name":"notifications","tool_call_id":""}),
|
||||
"messages[0].tool_call_id",
|
||||
),
|
||||
(
|
||||
json!({"name":"notifications","tool_call_id":17}),
|
||||
"messages[0].tool_call_id",
|
||||
),
|
||||
] {
|
||||
let mut message = json!({"role":"tool","content":"ok"});
|
||||
message
|
||||
.as_object_mut()
|
||||
.unwrap()
|
||||
.parameter(),
|
||||
Some("messages[0].tool_call_id")
|
||||
);
|
||||
.extend(identity.as_object().unwrap().clone());
|
||||
let request = json!({"model":"m","messages":[message]});
|
||||
let error = parse_request(&serde_json::to_vec(&request).unwrap()).unwrap_err();
|
||||
assert_eq!(error.parameter(), Some(parameter));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn named_tool_outputs_preserve_the_original_request_and_target_requirements() {
|
||||
let request = json!({"model":"m","messages":[
|
||||
{"role":"tool","name":"notifications","namespace":"agent","content":"notice"}
|
||||
]});
|
||||
let parsed = parse_request(&serde_json::to_vec(&request).unwrap()).unwrap();
|
||||
assert_eq!(&parsed, request.as_object().unwrap());
|
||||
assert!(responses::convert_request(&parsed).is_ok());
|
||||
for result in [
|
||||
messages::convert_request(&parsed, &Default::default()),
|
||||
genai::convert_request(&parsed),
|
||||
] {
|
||||
assert_eq!(
|
||||
result.unwrap_err().parameter(),
|
||||
Some("messages[0].tool_call_id")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -472,11 +506,14 @@ fn all_targets_apply_the_same_common_request_validation() {
|
||||
|
||||
#[test]
|
||||
fn custom_format_constraints_are_preserved_or_rejected_by_the_target() {
|
||||
for format in [
|
||||
json!(null),
|
||||
json!({"type":"text"}),
|
||||
json!({"type":"grammar","grammar":{"syntax":"lark","definition":"PRIVATE_GRAMMAR"}}),
|
||||
json!(17),
|
||||
for (format, expected) in [
|
||||
(json!(null), json!(null)),
|
||||
(json!({"type":"text"}), json!({"type":"text"})),
|
||||
(
|
||||
json!({"type":"grammar","grammar":{"syntax":"lark","definition":"PRIVATE_GRAMMAR"}}),
|
||||
json!({"type":"grammar","syntax":"lark","definition":"PRIVATE_GRAMMAR"}),
|
||||
),
|
||||
(json!(17), json!(17)),
|
||||
] {
|
||||
let mut body = super::request();
|
||||
body.insert(
|
||||
@@ -484,7 +521,7 @@ fn custom_format_constraints_are_preserved_or_rejected_by_the_target() {
|
||||
json!([{"type":"custom","custom":{"name":"run","format":format}}]),
|
||||
);
|
||||
let responses = responses::convert_request(&body).unwrap();
|
||||
assert_eq!(responses["tools"][0]["format"], format);
|
||||
assert_eq!(responses["tools"][0]["format"], expected);
|
||||
for result in [
|
||||
messages::convert_request(&body, &Default::default()),
|
||||
genai::convert_request(&body),
|
||||
|
||||
@@ -53,6 +53,31 @@ fn preserves_ordered_roles_images_and_modern_tool_round_trip() {
|
||||
assert!(converted.get("previous_response_id").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn named_tool_outputs_preserve_unpaired_identity_and_order() {
|
||||
for call_id in [None, Some(Value::Null)] {
|
||||
let mut notice = json!({"role":"tool","name":"lookup","namespace":"agent","content":[{"type":"text","text":"independent notice"}]});
|
||||
if let Some(call_id) = call_id {
|
||||
notice["tool_call_id"] = call_id;
|
||||
}
|
||||
let converted = convert(json!({"model":"model-a","messages":[
|
||||
{"role":"assistant","tool_calls":[{"id":"call_lookup","type":"custom","custom":{"name":"lookup","input":"query"}}]},
|
||||
notice,
|
||||
{"role":"tool","tool_call_id":"call_lookup","content":"matched result"},
|
||||
{"role":"tool","name":"notifications","content":"another notice"}
|
||||
]}));
|
||||
assert_eq!(
|
||||
converted["input"],
|
||||
json!([
|
||||
{"type":"custom_tool_call","call_id":"call_lookup","name":"lookup","input":"query"},
|
||||
{"type":"function_call_output","name":"lookup","namespace":"agent","output":[{"type":"input_text","text":"independent notice"}]},
|
||||
{"type":"custom_tool_call_output","call_id":"call_lookup","output":"matched result"},
|
||||
{"type":"function_call_output","name":"notifications","output":"another notice"}
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn web_search_options_require_a_hosted_search_and_flatten_location() {
|
||||
for (options, expected) in [
|
||||
@@ -278,7 +303,7 @@ fn custom_tools_keep_native_input_and_mixed_call_families_through_history() {
|
||||
]}));
|
||||
assert_eq!(
|
||||
converted["tools"][0],
|
||||
json!({"type":"custom", "name":"patch", "format":schema})
|
||||
json!({"type":"custom", "name":"patch", "format":{"type":"grammar","syntax":"lark","definition":"start: /.+/"}})
|
||||
);
|
||||
assert_eq!(
|
||||
converted["tool_choice"],
|
||||
@@ -293,6 +318,40 @@ fn custom_tools_keep_native_input_and_mixed_call_families_through_history() {
|
||||
assert_eq!(converted["input"][5]["type"], "function_call_output");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn custom_grammar_formats_keep_their_constraints_and_source_paths() {
|
||||
for nested in [false, true] {
|
||||
for syntax in ["lark", "regex"] {
|
||||
let format =
|
||||
json!({"type":"grammar","syntax":syntax,"definition":"OK","future_field":true});
|
||||
let definition = json!({"name":"probe","format":format});
|
||||
let tool = if nested {
|
||||
json!({"type":"custom","custom":definition})
|
||||
} else {
|
||||
json!({"type":"custom","name":"probe","format":format})
|
||||
};
|
||||
let mut body =
|
||||
json!({"model":"m","messages":[{"role":"user","content":"hello"}],"tools":[tool]});
|
||||
assert_eq!(convert(body.clone())["tools"][0]["format"], format);
|
||||
let declaration = if nested {
|
||||
&mut body["tools"][0]["custom"]
|
||||
} else {
|
||||
&mut body["tools"][0]
|
||||
};
|
||||
declaration["format"] = json!({"type":"grammar","grammar":false});
|
||||
let error = convert_request(body.as_object().unwrap()).unwrap_err();
|
||||
assert_eq!(
|
||||
error.parameter(),
|
||||
Some(if nested {
|
||||
"tools[0].custom.format.grammar"
|
||||
} else {
|
||||
"tools[0].format.grammar"
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn files_and_audio_are_preserved_as_inputs_instead_of_losing_the_user_turn() {
|
||||
for file in [
|
||||
|
||||
@@ -69,7 +69,9 @@ impl ClientAdmissionRecoveryRepository for PgClientAdmissionRecoveryRepository {
|
||||
lease.lease_expires_at, request.outcome
|
||||
from model_requests request
|
||||
left join model_request_leases lease on lease.request_id = request.id
|
||||
where request.started_at >= $1 or request.outcome = 'running'
|
||||
where (request.started_at >= $1 or request.outcome = 'running')
|
||||
and (request.client_transport, request.request_kind)
|
||||
is distinct from ('internal_plugin', 'plugin_child_model')
|
||||
order by request.client_api_key_ref, request.started_at, request.id",
|
||||
)
|
||||
.bind(window_started_at)
|
||||
|
||||
@@ -155,8 +155,6 @@ impl ClientAdmissionRequest {
|
||||
return Err(invalid("lease TTL must be positive"));
|
||||
}
|
||||
redis_duration_millis(self.lease_ttl)?;
|
||||
redis_integer(self.limits.max_concurrency, "maximum concurrency")?;
|
||||
redis_integer(self.limits.requests_per_minute, "requests per minute")?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -287,6 +285,7 @@ impl ClientAdmissionRepository for RedisClientAdmissionRepository {
|
||||
.key(&keys[1])
|
||||
.arg(&request.model_request_id)
|
||||
.arg(lease_ttl_ms)
|
||||
// ZCARD 的取值都能精确表示,超过 Lua 精确范围的限额始终大于实际计数
|
||||
.arg(request.limits.max_concurrency)
|
||||
.arg(request.limits.requests_per_minute)
|
||||
.arg(MAX_REDIS_EXACT_INTEGER)
|
||||
|
||||
@@ -62,6 +62,23 @@ async fn recovery_loads_precise_window_and_running_request_facts() {
|
||||
.await
|
||||
.expect("remove missing lease fixture");
|
||||
|
||||
seed_request(
|
||||
&database.pool,
|
||||
"nested-child",
|
||||
now - Duration::seconds(8),
|
||||
now + Duration::seconds(30),
|
||||
"running",
|
||||
)
|
||||
.await;
|
||||
sqlx::query(
|
||||
"update model_requests set client_transport = 'internal_plugin',
|
||||
request_kind = case id when 'recent-running' then 'plugin_bound_model' else 'plugin_child_model' end
|
||||
where id in ('nested-child', 'recent-running')",
|
||||
)
|
||||
.execute(&database.pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let repository = PgClientAdmissionRecoveryRepository::new(database.pool.clone());
|
||||
let actual = repository
|
||||
.load_client_admission_recovery(window_started_at)
|
||||
|
||||
@@ -18,11 +18,19 @@ fn client_admission_rejects_zero_ttl() {
|
||||
assert!(request.validate().is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn client_admission_rejects_values_outside_redis_exact_integer_range() {
|
||||
let mut request = admission_request("request-1", "key-1", Duration::from_secs(30));
|
||||
#[tokio::test]
|
||||
async fn configured_limits_above_lua_integer_precision_allow_requests() {
|
||||
let Some((repository, mut connection, namespace)) = repository().await else {
|
||||
return;
|
||||
};
|
||||
let mut request = admission_request("req_large_limits", "key-1", Duration::from_secs(30));
|
||||
request.limits.max_concurrency = 1_u64 << 53;
|
||||
assert!(request.validate().is_err());
|
||||
request.limits.requests_per_minute = i64::MAX as u64;
|
||||
assert_eq!(
|
||||
repository.admit_client_request(&request).await.unwrap(),
|
||||
ClientAdmissionDecision::Granted
|
||||
);
|
||||
delete_namespace_keys(&mut connection, &namespace).await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -9,17 +9,23 @@ mod transport;
|
||||
|
||||
use gateway_admin::ports::provider::ProviderBundle;
|
||||
use gateway_core::{provider_ports::ProviderStorePorts, routing::ProviderKind};
|
||||
use std::sync::Arc;
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[error("Antigravity Provider 初始化失败")]
|
||||
pub struct ConfigError;
|
||||
|
||||
pub async fn initialize(ports: ProviderStorePorts) -> Result<ProviderBundle, ConfigError> {
|
||||
pub async fn initialize(
|
||||
ports: ProviderStorePorts,
|
||||
artifact_dir: PathBuf,
|
||||
) -> Result<ProviderBundle, ConfigError> {
|
||||
let kind = ProviderKind::new("antigravity").map_err(|_| ConfigError)?;
|
||||
let oauth = Arc::new(credential::GoogleOAuth::for_provider()?);
|
||||
let origin = oauth.resource_origin().clone();
|
||||
let release = Arc::new(profile::ReleaseService::new(ports.artifact_profiles())?);
|
||||
let release = Arc::new(profile::ReleaseService::new(
|
||||
ports.artifact_profiles(),
|
||||
artifact_dir,
|
||||
)?);
|
||||
release.restore().await;
|
||||
let credentials = Arc::new(credential::CredentialService::new(
|
||||
kind.clone(),
|
||||
|
||||
@@ -308,6 +308,7 @@ pub(crate) async fn download(
|
||||
client: &Client,
|
||||
url: &str,
|
||||
sha512: Option<&str>,
|
||||
artifact_dir: &std::path::Path,
|
||||
) -> Result<std::fs::File, WorkerTaskError> {
|
||||
let mut response = client
|
||||
.get(url)
|
||||
@@ -323,7 +324,11 @@ pub(crate) async fn download(
|
||||
{
|
||||
return Err(invalid());
|
||||
}
|
||||
let file = tempfile::tempfile().map_err(|e| invalid().with_source(e))?;
|
||||
// 官方包可能大于容器的 /tmp;匿名文件随句柄释放,失败和取消也不会留下半包。
|
||||
tokio::fs::create_dir_all(artifact_dir)
|
||||
.await
|
||||
.map_err(|e| invalid().with_source(e))?;
|
||||
let file = tempfile::tempfile_in(artifact_dir).map_err(|e| invalid().with_source(e))?;
|
||||
let mut file = tokio::fs::File::from_std(file);
|
||||
let mut count = 0u64;
|
||||
let mut digest = Sha512::new();
|
||||
|
||||
@@ -23,6 +23,7 @@ pub(crate) async fn verify(
|
||||
version: &str,
|
||||
url: &str,
|
||||
sha512: Option<&str>,
|
||||
artifact_dir: &std::path::Path,
|
||||
) -> Result<u64, WorkerTaskError> {
|
||||
match (target.client, target.platform) {
|
||||
(ClientKind::Desktop, Platform::Macos) => {
|
||||
@@ -50,7 +51,7 @@ pub(crate) async fn verify(
|
||||
.await
|
||||
}
|
||||
_ => {
|
||||
let file = download(client, url, sha512).await?;
|
||||
let file = download(client, url, sha512, artifact_dir).await?;
|
||||
// 取消 worker 时同步中止阻塞解包,临时文件由解析任务退出时关闭
|
||||
let (file, _guard) = CancellableFile::new(file);
|
||||
let version = version.to_owned();
|
||||
|
||||
@@ -13,6 +13,7 @@ use gateway_core::{provider_ports::ProviderArtifactProfileCachePort, routing::Pr
|
||||
use serde::Deserialize;
|
||||
use std::{
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
path::PathBuf,
|
||||
sync::{Arc, Mutex, RwLock},
|
||||
time::Duration,
|
||||
};
|
||||
@@ -74,6 +75,7 @@ pub(crate) struct ReleaseService {
|
||||
impl ReleaseService {
|
||||
pub(crate) fn new(
|
||||
cache: Arc<dyn ProviderArtifactProfileCachePort>,
|
||||
artifact_dir: PathBuf,
|
||||
) -> Result<Self, ConfigError> {
|
||||
let client = gateway_egress::http_client(None)
|
||||
.map_err(|_| ConfigError)?
|
||||
@@ -89,6 +91,7 @@ impl ReleaseService {
|
||||
verification: VerificationCache::new(
|
||||
ProviderKind::new("antigravity").map_err(|_| ConfigError)?,
|
||||
cache,
|
||||
artifact_dir,
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ use gateway_core::{
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
path::PathBuf,
|
||||
sync::Arc,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
@@ -39,13 +40,19 @@ struct Payload {
|
||||
pub(crate) struct VerificationCache {
|
||||
provider: ProviderKind,
|
||||
cache: Arc<dyn ProviderArtifactProfileCachePort>,
|
||||
artifact_dir: PathBuf,
|
||||
}
|
||||
impl VerificationCache {
|
||||
pub(crate) fn new(
|
||||
provider: ProviderKind,
|
||||
cache: Arc<dyn ProviderArtifactProfileCachePort>,
|
||||
artifact_dir: PathBuf,
|
||||
) -> Self {
|
||||
Self { provider, cache }
|
||||
Self {
|
||||
provider,
|
||||
cache,
|
||||
artifact_dir,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn load(
|
||||
@@ -117,6 +124,7 @@ impl VerificationCache {
|
||||
&release.version,
|
||||
&release.url,
|
||||
release.sha512.as_deref(),
|
||||
&self.artifact_dir,
|
||||
)
|
||||
.await?;
|
||||
(Utc::now(), changelist)
|
||||
|
||||
@@ -46,7 +46,11 @@ pub(super) async fn fixture() -> (MockServer, CredentialService, Arc<MemoryPorts
|
||||
runtime_policy: store.clone(),
|
||||
credential_state: store.clone(),
|
||||
release: Arc::new(
|
||||
crate::profile::ReleaseService::new(crate::support::profile::cache()).unwrap(),
|
||||
crate::profile::ReleaseService::new(
|
||||
crate::support::profile::cache(),
|
||||
std::env::temp_dir(),
|
||||
)
|
||||
.unwrap(),
|
||||
),
|
||||
oauth: Arc::new(GoogleOAuth::with_endpoints(
|
||||
config,
|
||||
|
||||
@@ -103,15 +103,31 @@ async fn complete_download_requires_the_manifest_digest() {
|
||||
let server = serve(body.to_vec(), "").await;
|
||||
let client = reqwest::Client::new();
|
||||
let digest = hex::encode(Sha512::digest(body));
|
||||
let file = download(&client, &server.uri(), Some(&digest))
|
||||
let root = tempfile::tempdir().unwrap();
|
||||
let artifact_dir = root.path().join("antigravity");
|
||||
let file = download(&client, &server.uri(), Some(&digest), &artifact_dir)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(file.metadata().unwrap().len(), body.len() as u64);
|
||||
drop(file);
|
||||
assert_eq!(std::fs::read_dir(&artifact_dir).unwrap().count(), 0);
|
||||
let blocked = root.path().join("file");
|
||||
std::fs::write(&blocked, b"").unwrap();
|
||||
assert!(
|
||||
download(&client, &server.uri(), Some(&"0".repeat(128)))
|
||||
download(&client, &server.uri(), Some(&digest), &blocked)
|
||||
.await
|
||||
.is_err()
|
||||
);
|
||||
assert!(
|
||||
download(
|
||||
&client,
|
||||
&server.uri(),
|
||||
Some(&"0".repeat(128)),
|
||||
&artifact_dir
|
||||
)
|
||||
.await
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -27,7 +27,7 @@ fn fixture_release(server: &wiremock::MockServer, version: &str) -> Release {
|
||||
async fn cache_restore_and_renewal_preserve_verification_without_downloading_again() {
|
||||
let server = super::archive::serve(super::artifact::desktop_zip("2.35.1"), "").await;
|
||||
let cache = cache();
|
||||
let service = VerificationCache::new(provider(), cache.clone());
|
||||
let service = VerificationCache::new(provider(), cache.clone(), std::env::temp_dir());
|
||||
let client = reqwest::Client::new();
|
||||
let target = Selection::default().target();
|
||||
let release = fixture_release(&server, "2.35.1");
|
||||
@@ -42,7 +42,7 @@ async fn cache_restore_and_renewal_preserve_verification_without_downloading_aga
|
||||
.unwrap();
|
||||
assert_eq!(same.verified_at, first.verified_at);
|
||||
assert_eq!(cache.writes.load(Ordering::SeqCst), 1);
|
||||
let restarted = VerificationCache::new(provider(), cache.clone());
|
||||
let restarted = VerificationCache::new(provider(), cache.clone(), std::env::temp_dir());
|
||||
let restored = restarted.load(target).await.unwrap().unwrap();
|
||||
assert_eq!(restored.verified_at, first.verified_at);
|
||||
assert_eq!(first.changelist, 1_234_567_890);
|
||||
@@ -50,7 +50,7 @@ async fn cache_restore_and_renewal_preserve_verification_without_downloading_aga
|
||||
assert_eq!(cache.writes.load(Ordering::SeqCst), 1);
|
||||
assert_eq!(server.received_requests().await.unwrap().len(), requests);
|
||||
|
||||
let releases = ReleaseService::new(cache.clone()).unwrap();
|
||||
let releases = ReleaseService::new(cache.clone(), std::env::temp_dir()).unwrap();
|
||||
releases.restore().await;
|
||||
let restored = dashboard(&Selection::default(), &releases);
|
||||
assert_eq!(restored.version, release.version);
|
||||
@@ -79,7 +79,7 @@ async fn latest_profile_switches_version_and_changelist_only_after_verified_publ
|
||||
)
|
||||
.await;
|
||||
let cache = cache();
|
||||
let service = VerificationCache::new(provider(), cache.clone());
|
||||
let service = VerificationCache::new(provider(), cache.clone(), std::env::temp_dir());
|
||||
let target = Selection::default().target();
|
||||
let client = reqwest::Client::new();
|
||||
let old = service
|
||||
@@ -92,7 +92,7 @@ async fn latest_profile_switches_version_and_changelist_only_after_verified_publ
|
||||
.await
|
||||
.unwrap();
|
||||
let new_release = fixture_release(&new_server, "2.36.0");
|
||||
let releases = ReleaseService::new(cache.clone()).unwrap();
|
||||
let releases = ReleaseService::new(cache.clone(), std::env::temp_dir()).unwrap();
|
||||
releases.restore().await;
|
||||
let before = dashboard(&Selection::default(), &releases);
|
||||
let frozen = default_profile(&releases).frozen();
|
||||
@@ -131,7 +131,7 @@ async fn latest_profile_switches_version_and_changelist_only_after_verified_publ
|
||||
async fn changed_artifact_or_target_and_failed_cache_do_not_publish_verification() {
|
||||
let server = super::archive::serve(super::artifact::desktop_zip("2.35.1"), "").await;
|
||||
let cache = cache();
|
||||
let service = VerificationCache::new(provider(), cache.clone());
|
||||
let service = VerificationCache::new(provider(), cache.clone(), std::env::temp_dir());
|
||||
let client = reqwest::Client::new();
|
||||
let target = Selection::default().target();
|
||||
let release = fixture_release(&server, "2.35.1");
|
||||
@@ -189,7 +189,7 @@ async fn changed_artifact_or_target_and_failed_cache_do_not_publish_verification
|
||||
async fn version_disagreement_leaves_the_previous_cache_intact() {
|
||||
let server = super::archive::serve(super::artifact::desktop_zip("2.35.1"), "").await;
|
||||
let cache = cache();
|
||||
let service = VerificationCache::new(provider(), cache.clone());
|
||||
let service = VerificationCache::new(provider(), cache.clone(), std::env::temp_dir());
|
||||
let client = reqwest::Client::new();
|
||||
let target = Selection::default().target();
|
||||
let release = fixture_release(&server, "2.35.1");
|
||||
|
||||
@@ -67,7 +67,7 @@ async fn middleware_business_headers_survive_without_overriding_frozen_authentic
|
||||
let fixture = Fixture::new(&upstream.uri());
|
||||
let profile = profile::resolve(
|
||||
&Selection::default().configuration(),
|
||||
&ReleaseService::new(crate::support::profile::cache()).unwrap(),
|
||||
&ReleaseService::new(crate::support::profile::cache(), std::env::temp_dir()).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
Mock::given(path("/v1internal:generateContent"))
|
||||
|
||||
@@ -247,7 +247,9 @@ impl Fixture {
|
||||
store.clone(),
|
||||
store.clone(),
|
||||
);
|
||||
let release = Arc::new(ReleaseService::new(crate::support::profile::cache()).unwrap());
|
||||
let release = Arc::new(
|
||||
ReleaseService::new(crate::support::profile::cache(), std::env::temp_dir()).unwrap(),
|
||||
);
|
||||
let credentials = Arc::new(CredentialService::new(
|
||||
kind.clone(),
|
||||
&ports,
|
||||
|
||||
@@ -21,8 +21,9 @@ use wiremock::{
|
||||
async fn oauth_refresh_and_native_generate_preserve_grant_profile_and_wire_payload() {
|
||||
let server = MockServer::start().await;
|
||||
let (origin, access_token) = refreshed_credential(&server).await;
|
||||
let profile =
|
||||
profile::default_profile(&ReleaseService::new(crate::support::profile::cache()).unwrap());
|
||||
let profile = profile::default_profile(
|
||||
&ReleaseService::new(crate::support::profile::cache(), std::env::temp_dir()).unwrap(),
|
||||
);
|
||||
let user_agent = "antigravity/hub/2.37.0 (aidev_client; os_type=darwin; arch=arm64)";
|
||||
let client = CloudCodeClient::new(&origin, None, &profile).unwrap();
|
||||
let post = |p| {
|
||||
@@ -171,8 +172,9 @@ async fn oauth_refresh_and_native_generate_preserve_grant_profile_and_wire_paylo
|
||||
#[tokio::test]
|
||||
async fn streamed_text_is_projected_once_across_native_frames() {
|
||||
let server = MockServer::start().await;
|
||||
let profile =
|
||||
profile::default_profile(&ReleaseService::new(crate::support::profile::cache()).unwrap());
|
||||
let profile = profile::default_profile(
|
||||
&ReleaseService::new(crate::support::profile::cache(), std::env::temp_dir()).unwrap(),
|
||||
);
|
||||
let client = CloudCodeClient::new(&server.uri().parse().unwrap(), None, &profile).unwrap();
|
||||
let frames = [
|
||||
json!({"candidates":[{"content":{"parts":[{"text":""}]}}]}),
|
||||
@@ -249,8 +251,9 @@ async fn streamed_text_is_projected_once_across_native_frames() {
|
||||
#[tokio::test]
|
||||
async fn incomplete_native_stream_and_redirect_are_rejected() {
|
||||
let server = MockServer::start().await;
|
||||
let profile =
|
||||
profile::default_profile(&ReleaseService::new(crate::support::profile::cache()).unwrap());
|
||||
let profile = profile::default_profile(
|
||||
&ReleaseService::new(crate::support::profile::cache(), std::env::temp_dir()).unwrap(),
|
||||
);
|
||||
let client = CloudCodeClient::new(&server.uri().parse().unwrap(), None, &profile).unwrap();
|
||||
Mock::given(path("/v1internal:streamGenerateContent")).respond_with(ResponseTemplate::new(200).set_body_raw("data: {\"response\":{\"candidates\":[{\"content\":{\"parts\":[{\"text\":\"partial\"}]}}]}}\n\n","text/event-stream")).mount(&server).await;
|
||||
let res = client
|
||||
@@ -350,8 +353,9 @@ async fn compressed_response(status: u16, body: &[u8], media: &str) -> ResponseT
|
||||
async fn compressed_control_responses_keep_errors_and_decoded_size_limits() {
|
||||
use gateway_core::error::ProviderErrorKind;
|
||||
let server = MockServer::start().await;
|
||||
let profile =
|
||||
profile::default_profile(&ReleaseService::new(crate::support::profile::cache()).unwrap());
|
||||
let profile = profile::default_profile(
|
||||
&ReleaseService::new(crate::support::profile::cache(), std::env::temp_dir()).unwrap(),
|
||||
);
|
||||
let client = CloudCodeClient::new(&server.uri().parse().unwrap(), None, &profile).unwrap();
|
||||
Mock::given(path("/v1internal:loadCodeAssist"))
|
||||
.respond_with(
|
||||
|
||||
@@ -1,9 +1,147 @@
|
||||
//! Chat 转换的目标档位与 fast 协议头适配
|
||||
//! Chat 转换的目标档位、工具标识与 fast 协议头适配
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use bytes::Bytes;
|
||||
use gateway_core::engine::middleware::MiddlewareHeader;
|
||||
use reqwest::header::HeaderMap;
|
||||
use serde_json::{Map, Value};
|
||||
use sha2::{Digest as _, Sha256};
|
||||
|
||||
/// 名称映射只属于本次 Chat 响应,历史调用 ID 在出站副本中保持成对关联
|
||||
pub(crate) fn normalize_translated_codex_tools(
|
||||
body: &mut Map<String, Value>,
|
||||
) -> HashMap<String, String> {
|
||||
let mut fields = Vec::new();
|
||||
for (field, value) in body.iter_mut() {
|
||||
match field.as_str() {
|
||||
"tools" | "input" => {
|
||||
if let Some(items) = value.as_array_mut() {
|
||||
for item in items {
|
||||
collect_tool_names(item, &mut fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
"tool_choice" => collect_tool_names(value, &mut fields),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
// 先预留所有原名,避免别名抢占后面声明的合法名称
|
||||
let mut used = fields
|
||||
.iter()
|
||||
.filter_map(|value| value.as_str())
|
||||
.map(str::to_owned)
|
||||
.collect();
|
||||
let mut names = HashMap::new();
|
||||
for field in fields {
|
||||
let Some(name) = field.as_str() else { continue };
|
||||
if name.is_empty()
|
||||
|| name
|
||||
.bytes()
|
||||
.all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'_' | b'-'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let alias = names.entry(name.to_owned()).or_insert_with(|| {
|
||||
let base: String = name
|
||||
.chars()
|
||||
.map(|ch| {
|
||||
if ch.is_ascii_alphanumeric() || matches!(ch, '_' | '-') {
|
||||
ch
|
||||
} else {
|
||||
'_'
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
unique_tool_alias(&base, &mut used)
|
||||
});
|
||||
*field = Value::String(alias.clone());
|
||||
}
|
||||
if let Some(input) = body.get_mut("input").and_then(Value::as_array_mut) {
|
||||
let mut used = input
|
||||
.iter()
|
||||
.filter_map(|item| item.get("call_id").and_then(Value::as_str))
|
||||
.map(str::to_owned)
|
||||
.collect();
|
||||
let mut ids = HashMap::new();
|
||||
for item in input.iter().filter(|item| {
|
||||
matches!(
|
||||
item.get("type").and_then(Value::as_str),
|
||||
Some("function_call" | "custom_tool_call")
|
||||
)
|
||||
}) {
|
||||
let Some(id) = item
|
||||
.get("call_id")
|
||||
.and_then(Value::as_str)
|
||||
.filter(|id| id.chars().count() > 64)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
ids.entry(id.to_owned()).or_insert_with(|| {
|
||||
let digest = hex::encode(Sha256::digest(id.as_bytes()));
|
||||
unique_tool_alias(&format!("call_{digest}"), &mut used)
|
||||
});
|
||||
}
|
||||
for item in input {
|
||||
if matches!(
|
||||
item.get("type").and_then(Value::as_str),
|
||||
Some(
|
||||
"function_call"
|
||||
| "custom_tool_call"
|
||||
| "function_call_output"
|
||||
| "custom_tool_call_output"
|
||||
)
|
||||
) && let Some(alias) = item
|
||||
.get("call_id")
|
||||
.and_then(Value::as_str)
|
||||
.and_then(|id| ids.get(id))
|
||||
{
|
||||
item["call_id"] = alias.clone().into();
|
||||
}
|
||||
}
|
||||
}
|
||||
names
|
||||
.into_iter()
|
||||
.map(|(name, alias)| (alias, name))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn collect_tool_names<'a>(tool: &'a mut Value, names: &mut Vec<&'a mut Value>) {
|
||||
match tool.get("type").and_then(Value::as_str) {
|
||||
Some(
|
||||
"function"
|
||||
| "custom"
|
||||
| "function_call"
|
||||
| "custom_tool_call"
|
||||
| "function_call_output"
|
||||
| "custom_tool_call_output",
|
||||
) => {
|
||||
if let Some(name) = tool.get_mut("name") {
|
||||
names.push(name);
|
||||
}
|
||||
}
|
||||
Some("namespace" | "allowed_tools" | "additional_tools" | "tool_search_output") => {
|
||||
if let Some(tools) = tool.get_mut("tools").and_then(Value::as_array_mut) {
|
||||
for tool in tools {
|
||||
collect_tool_names(tool, names);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn unique_tool_alias(base: &str, used: &mut HashSet<String>) -> String {
|
||||
// 调用方只传入 ASCII 名称或十六进制摘要,可按字节截取 Codex 标识上限
|
||||
let mut candidate = base[..base.len().min(64)].to_owned();
|
||||
let mut index = 0;
|
||||
while !used.insert(candidate.clone()) {
|
||||
index += 1;
|
||||
let suffix = format!("_{index}");
|
||||
candidate = format!("{}{suffix}", &base[..base.len().min(64 - suffix.len())]);
|
||||
}
|
||||
candidate
|
||||
}
|
||||
|
||||
pub(crate) fn normalize_translated_codex_service_tier(body: &mut Map<String, Value>) {
|
||||
// 转换生成的默认档位沿用 Codex 客户端的省略表达,原生 Responses 保留调用方声明
|
||||
|
||||
@@ -10,7 +10,10 @@ mod search_tools;
|
||||
use gateway_core::engine::middleware::MiddlewareHeader;
|
||||
use serde_json::{Map, Value};
|
||||
|
||||
pub(crate) use chat::{add_translated_fast_beta, normalize_translated_codex_service_tier};
|
||||
pub(crate) use chat::{
|
||||
add_translated_fast_beta, normalize_translated_codex_service_tier,
|
||||
normalize_translated_codex_tools,
|
||||
};
|
||||
pub(crate) use headers::is_non_codex_request_header;
|
||||
pub(crate) use request::normalize_codex_request_body;
|
||||
pub(crate) use search_tools::declares_hosted_search;
|
||||
|
||||
@@ -8,6 +8,7 @@ use serde_json::{Map, Value, json};
|
||||
/// 只处理已验证被拒绝的字段,不根据客户端品牌推断整份历史是否合法
|
||||
pub(super) fn normalize_non_codex_request_body(body: &mut Map<String, Value>) {
|
||||
normalize_codex_oauth_options(body);
|
||||
super::search_tools::normalize_search_tool_aliases(body);
|
||||
let Some(input) = body.get_mut("input").and_then(Value::as_array_mut) else {
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,39 @@
|
||||
//! 识别普通与 Responses Lite 请求中的托管搜索声明,不改写工具配置
|
||||
//! 识别托管搜索声明并适配 Codex 的搜索工具名称
|
||||
|
||||
use serde_json::{Map, Value};
|
||||
|
||||
pub(super) fn normalize_search_tool_aliases(body: &mut Map<String, Value>) {
|
||||
for (field, value) in body {
|
||||
match field.as_str() {
|
||||
"tools" | "input" => {
|
||||
if let Some(items) = value.as_array_mut() {
|
||||
for item in items {
|
||||
normalize_search_tool(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
"tool_choice" => normalize_search_tool(value),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn normalize_search_tool(tool: &mut Value) {
|
||||
match tool.get("type").and_then(Value::as_str) {
|
||||
Some("web_search_preview" | "web_search_preview_2025_03_11") => {
|
||||
tool["type"] = "web_search".into();
|
||||
}
|
||||
Some("allowed_tools" | "additional_tools" | "tool_search_output" | "namespace") => {
|
||||
if let Some(tools) = tool.get_mut("tools").and_then(Value::as_array_mut) {
|
||||
for tool in tools {
|
||||
normalize_search_tool(tool);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn declares_hosted_search(body: &Map<String, Value>) -> bool {
|
||||
body.get("tools")
|
||||
.and_then(Value::as_array)
|
||||
|
||||
@@ -38,7 +38,7 @@ impl CodexProvider {
|
||||
};
|
||||
let mut source_context = generate.protocol_payload().context().clone();
|
||||
let target = selected.lease.authentication().api_protocol();
|
||||
let translator = response::ChatResponseTranslator::new(target, identity, original);
|
||||
let mut translator = response::ChatResponseTranslator::new(target, identity, original);
|
||||
match target {
|
||||
ApiKeyProtocol::Messages => {
|
||||
let capabilities = self
|
||||
@@ -82,6 +82,8 @@ impl CodexProvider {
|
||||
CodexRuntimeAuthentication::OAuth(_)
|
||||
) {
|
||||
crate::compat::normalize_translated_codex_service_tier(&mut body);
|
||||
translator.tool_names =
|
||||
crate::compat::normalize_translated_codex_tools(&mut body);
|
||||
}
|
||||
let body = serde_json::to_vec(&body).map_err(|_| request_error())?;
|
||||
let operation = operation
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
//! 单次响应直接映射为 Chat wire,原生观测与资源释放归现有执行链
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::*;
|
||||
use gateway_core::engine::provider::NativeResponseTranslator;
|
||||
use gateway_protocol::{
|
||||
@@ -20,6 +22,7 @@ pub(super) struct ChatResponseTranslator {
|
||||
complete_json: bool,
|
||||
streaming: bool,
|
||||
include_usage: bool,
|
||||
pub(super) tool_names: HashMap<String, String>,
|
||||
}
|
||||
|
||||
impl ChatResponseTranslator {
|
||||
@@ -54,6 +57,7 @@ impl ChatResponseTranslator {
|
||||
complete_json: false,
|
||||
streaming: request.get("stream").and_then(Value::as_bool) == Some(true),
|
||||
include_usage,
|
||||
tool_names: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,7 +83,7 @@ impl NativeResponseTranslator for ChatResponseTranslator {
|
||||
}
|
||||
if let Some(raw) = event.raw_json_body() {
|
||||
let body = serde_json::from_slice(raw).map_err(|_| response_error())?;
|
||||
let response = match self.encoder {
|
||||
let mut response = match self.encoder {
|
||||
Encoder::Responses(_) => responses::project_response(&body, &self.identity),
|
||||
Encoder::Messages(_) => {
|
||||
messages::project_response_with_request(&body, &self.identity, &self.request)
|
||||
@@ -94,8 +98,10 @@ impl NativeResponseTranslator for ChatResponseTranslator {
|
||||
self.include_usage,
|
||||
)
|
||||
.map_err(map_error)?,
|
||||
&self.tool_names,
|
||||
);
|
||||
}
|
||||
restore_tool_names(&mut response, &self.tool_names);
|
||||
return ProtocolWireEvent::raw_json(
|
||||
CHAT_PROTOCOL,
|
||||
serde_json::to_vec(&response)
|
||||
@@ -113,7 +119,7 @@ impl NativeResponseTranslator for ChatResponseTranslator {
|
||||
Encoder::Messages(encoder) => encoder.push_event(event.event_type(), event.data()),
|
||||
}
|
||||
.map_err(map_error)?;
|
||||
wire_events(chunks)
|
||||
wire_events(chunks, &self.tool_names)
|
||||
}
|
||||
|
||||
fn finish(&mut self) -> Result<Vec<ProtocolWireEvent>, ProviderError> {
|
||||
@@ -125,19 +131,52 @@ impl NativeResponseTranslator for ChatResponseTranslator {
|
||||
Encoder::Messages(encoder) => encoder.finish(),
|
||||
}
|
||||
.map_err(map_error)?;
|
||||
wire_events(chunks)
|
||||
wire_events(chunks, &self.tool_names)
|
||||
}
|
||||
}
|
||||
|
||||
fn wire_events(chunks: Vec<Value>) -> Result<Vec<ProtocolWireEvent>, ProviderError> {
|
||||
fn wire_events(
|
||||
chunks: Vec<Value>,
|
||||
names: &HashMap<String, String>,
|
||||
) -> Result<Vec<ProtocolWireEvent>, ProviderError> {
|
||||
chunks
|
||||
.into_iter()
|
||||
.map(|chunk| {
|
||||
.map(|mut chunk| {
|
||||
restore_tool_names(&mut chunk, names);
|
||||
ProtocolWireEvent::json(CHAT_PROTOCOL, None, chunk).map_err(|_| response_error())
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn restore_tool_names(response: &mut Value, names: &HashMap<String, String>) {
|
||||
if names.is_empty() {
|
||||
return;
|
||||
}
|
||||
let Some(choices) = response.get_mut("choices").and_then(Value::as_array_mut) else {
|
||||
return;
|
||||
};
|
||||
for choice in choices {
|
||||
for field in ["message", "delta"] {
|
||||
let Some(calls) = choice
|
||||
.get_mut(field)
|
||||
.and_then(|message| message.get_mut("tool_calls"))
|
||||
.and_then(Value::as_array_mut)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
for call in calls {
|
||||
for kind in ["function", "custom"] {
|
||||
if let Some(name) = call.get_mut(kind).and_then(|tool| tool.get_mut("name"))
|
||||
&& let Some(original) = name.as_str().and_then(|name| names.get(name))
|
||||
{
|
||||
*name = original.clone().into();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn map_error(error: ChatError) -> ProviderError {
|
||||
response_error().with_source(error)
|
||||
}
|
||||
|
||||
@@ -31,11 +31,22 @@ impl WebSocketContinuationState {
|
||||
if request.store() || !request.generate() || body.contains_key("previous_response_id") {
|
||||
return Self::default();
|
||||
}
|
||||
// 每轮元数据随当前帧照常发送,模型、工具及未知正文属性均参与前缀校验
|
||||
let properties: BTreeMap<_, _> = body
|
||||
.iter()
|
||||
.filter(|(key, _)| !matches!(key.as_str(), "input" | "client_metadata"))
|
||||
.collect();
|
||||
// 对齐 Codex 的 responses_request_properties_mismatch,仅比较它用来判定续接的属性
|
||||
let properties = [
|
||||
"model",
|
||||
"tools",
|
||||
"tool_choice",
|
||||
"parallel_tool_calls",
|
||||
"reasoning",
|
||||
"store",
|
||||
"stream",
|
||||
"include",
|
||||
"service_tier",
|
||||
"prompt_cache_key",
|
||||
"prompt_cache_options",
|
||||
"text",
|
||||
]
|
||||
.map(|field| body.get(field).unwrap_or(&Value::Null));
|
||||
let mut input = Prefix {
|
||||
count: 0,
|
||||
digest: fingerprint((owner, properties)),
|
||||
@@ -48,7 +59,7 @@ impl WebSocketContinuationState {
|
||||
.as_ref()
|
||||
.map_or(0, |last| last.total.count.min(items.len()));
|
||||
input.extend(&items[..cut]);
|
||||
let reuse = self.history.is_some_and(|last| last.total == input) && cut < items.len();
|
||||
let reuse = self.history.is_some_and(|last| last.total == input);
|
||||
input.extend(&items[cut..]);
|
||||
if reuse && let Some(id) = self.latest_response_id.filter(|id| !id.is_empty()) {
|
||||
items.drain(..cut);
|
||||
@@ -91,9 +102,7 @@ impl WebSocketContinuationState {
|
||||
history.total = history.input;
|
||||
history.total.extend(output);
|
||||
}
|
||||
} else if history.total.count == history.input.count
|
||||
|| history.total.count - history.input.count < history.added
|
||||
{
|
||||
} else if history.total.count - history.input.count < history.added {
|
||||
self.history = None;
|
||||
}
|
||||
}
|
||||
@@ -113,6 +122,45 @@ struct HttpHistory {
|
||||
added: usize,
|
||||
}
|
||||
|
||||
// 对齐 Codex 的历史项比较,保留工具结果及其调用绑定,只借用正文计算摘要
|
||||
fn history_digest(previous: [u8; 32], item: &Value) -> [u8; 32] {
|
||||
let Some(fields) = item.as_object() else {
|
||||
return fingerprint((previous, 0_u8, item));
|
||||
};
|
||||
let kind = item["type"].as_str();
|
||||
let sampled = matches!(
|
||||
kind,
|
||||
Some("reasoning" | "function_call" | "custom_tool_call")
|
||||
) || (kind == Some("message") && item["role"] == "assistant");
|
||||
let content: BTreeMap<_, _> = fields
|
||||
.iter()
|
||||
.filter(|(key, value)| match key.as_str() {
|
||||
"internal_chat_message_metadata_passthrough" => false,
|
||||
"metadata" if sampled => false,
|
||||
// Codex 回传空推理内容时可省略 content
|
||||
"content" if kind == Some("reasoning") => {
|
||||
!(value.is_null() || value.as_array().is_some_and(Vec::is_empty))
|
||||
}
|
||||
_ => true,
|
||||
})
|
||||
.collect();
|
||||
let results: Vec<_> = item["internal_chat_message_metadata_passthrough"]["executed_tool_calls"]
|
||||
.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.enumerate()
|
||||
.filter_map(|(index, call)| {
|
||||
Some((
|
||||
index,
|
||||
call.get("name"),
|
||||
call.get("arguments"),
|
||||
call.get("tool_result_metadata")?,
|
||||
))
|
||||
})
|
||||
.collect();
|
||||
fingerprint((previous, 1_u8, content, results))
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
struct Prefix {
|
||||
count: usize,
|
||||
@@ -127,7 +175,7 @@ impl Prefix {
|
||||
}
|
||||
|
||||
fn push(&mut self, item: &Value) {
|
||||
self.digest = fingerprint((self.digest, item));
|
||||
self.digest = history_digest(self.digest, item);
|
||||
self.count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
//! 验证 Chat 工具别名经实际出站、流式与 JSON 响应保持名称和调用关联
|
||||
|
||||
use super::*;
|
||||
use gateway_core::event::{ProtocolWireEvent, ProviderEvent};
|
||||
use gateway_protocol::chat_completions::ChatAccumulator;
|
||||
use sha2::{Digest as _, Sha256};
|
||||
|
||||
#[tokio::test]
|
||||
async fn chat_tool_aliases_preserve_pairing_names_and_account_boundaries() {
|
||||
let long_id = format!("call_{}", "x".repeat(80));
|
||||
let mut collision_id = format!("call_{}", hex::encode(Sha256::digest(long_id.as_bytes())));
|
||||
collision_id.truncate(64);
|
||||
let long_custom_id = "调用".repeat(40);
|
||||
let long_name = format!("tool_{}", "x".repeat(80));
|
||||
let arguments = json!({"tool_name":"mcp.server/tool","call_id":long_id}).to_string();
|
||||
let schema = json!({"type":"object","properties":{"mcp.server/tool":{"type":"string"}}});
|
||||
for api_key in [false, true] {
|
||||
for streaming in [false, true] {
|
||||
let server = MockServer::start().await;
|
||||
let store = Arc::new(MemoryAccountStore::default());
|
||||
if api_key {
|
||||
store
|
||||
.seed_api_key(
|
||||
"acct_provider_contract",
|
||||
server.uri(),
|
||||
provider_openai::credential::ResponsesTransport::Http,
|
||||
)
|
||||
.await;
|
||||
} else {
|
||||
create_account(&store, "acct_provider_contract").await;
|
||||
}
|
||||
Mock::given(method("POST"))
|
||||
.and(path(if api_key { "/responses" } else { "/codex/responses" }))
|
||||
.respond_with(|request: &wiremock::Request| {
|
||||
let body = captured_request_body(request);
|
||||
let output = json!([
|
||||
{"type":"function_call","id":"fc_new","call_id":"call_new","name":body["tools"][0]["name"],"arguments":"{}","status":"completed"},
|
||||
{"type":"custom_tool_call","id":"ctc_new","call_id":"custom_new","name":body["tools"][2]["name"],"input":"raw input","status":"completed"}
|
||||
]);
|
||||
let mut events = vec![json!({"type":"response.created","response":{"id":"r_tools","model":"gpt-5.4","status":"in_progress"}})];
|
||||
for (index, item) in output.as_array().unwrap().iter().enumerate() {
|
||||
events.push(json!({"type":"response.output_item.added","output_index":index,"item":item}));
|
||||
events.push(json!({"type":"response.output_item.done","output_index":index,"item":item}));
|
||||
}
|
||||
events.push(json!({"type":"response.completed","response":{
|
||||
"id":"r_tools","model":"gpt-5.4","status":"completed","output":output,
|
||||
"usage":{"input_tokens":1,"output_tokens":1,"total_tokens":2}
|
||||
}}));
|
||||
let sse = events.iter().map(|event| format!("data: {event}\n\n")).collect::<String>();
|
||||
ResponseTemplate::new(200).set_body_raw(sse, "text/event-stream")
|
||||
})
|
||||
.expect(1)
|
||||
.mount(&server).await;
|
||||
let body = json!({
|
||||
"model":"gpt-5.4","stream":streaming,
|
||||
"tools":[
|
||||
{"type":"function","function":{"name":"mcp.server/tool","parameters":schema}},
|
||||
{"type":"function","function":{"name":"mcp_server_tool"}},
|
||||
{"type":"custom","custom":{"name":"mcp/server/tool"}},
|
||||
{"type":"function","function":{"name":long_name}}
|
||||
],
|
||||
"tool_choice":{"type":"allowed_tools","allowed_tools":{"mode":"auto","tools":[
|
||||
{"type":"function","function":{"name":"mcp.server/tool"}},
|
||||
{"type":"custom","custom":{"name":"mcp/server/tool"}}
|
||||
]}},
|
||||
"messages":[
|
||||
{"role":"assistant","tool_calls":[
|
||||
{"type":"function","id":long_id,"function":{"name":"mcp.server/tool","arguments":arguments}},
|
||||
{"type":"function","id":collision_id,"function":{"name":"mcp_server_tool","arguments":"{}"}},
|
||||
{"type":"custom","id":long_custom_id,"custom":{"name":"mcp/server/tool","input":"raw history"}}
|
||||
]},
|
||||
{"role":"tool","tool_call_id":long_id,"content":"first"},
|
||||
{"role":"tool","tool_call_id":collision_id,"content":"second"},
|
||||
{"role":"tool","tool_call_id":long_custom_id,"content":"third"},
|
||||
{"role":"tool","name":"mcp.server/tool","namespace":"agent","content":"independent"},
|
||||
{"role":"user","content":"continue"}
|
||||
]
|
||||
});
|
||||
let operation = Operation::Generate(GenerateRequest::from_protocol_payload(
|
||||
ProtocolPayload::json_object("chat_completions", body.as_object().unwrap().clone())
|
||||
.unwrap()
|
||||
.with_context(Map::from_iter([("use_websocket".into(), json!(false))])),
|
||||
));
|
||||
let mut stream = provider_with_base_url(&store, server.uri())
|
||||
.execute(
|
||||
planned_request("openai", operation),
|
||||
context("req_chat_tools", CancellationToken::new()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let mut accumulator = ChatAccumulator::default();
|
||||
while let Some(event) = stream.next().await {
|
||||
let event = event.unwrap();
|
||||
let terminal = event
|
||||
.canonical_facts()
|
||||
.iter()
|
||||
.any(|fact| matches!(fact, GatewayEvent::Completed(_)));
|
||||
for event in stream.translate_native_response(event, terminal).unwrap() {
|
||||
if let Some(wire) = event.wire_event() {
|
||||
accumulator.push(wire.data()).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
let result = accumulator.finish().unwrap();
|
||||
assert_eq!(
|
||||
result["choices"][0]["message"]["tool_calls"][0]["function"]["name"],
|
||||
"mcp.server/tool"
|
||||
);
|
||||
assert_eq!(
|
||||
result["choices"][0]["message"]["tool_calls"][1]["custom"]["name"],
|
||||
"mcp/server/tool"
|
||||
);
|
||||
assert_eq!(
|
||||
result["choices"][0]["message"]["tool_calls"][1]["custom"]["input"],
|
||||
"raw input"
|
||||
);
|
||||
let requests = server.received_requests().await.unwrap();
|
||||
let sent = captured_request_body(&requests[0]);
|
||||
assert_eq!(sent["tools"][0]["parameters"], schema);
|
||||
assert_eq!(sent["input"][0]["arguments"], arguments);
|
||||
assert_eq!(sent["input"][6]["namespace"], "agent");
|
||||
assert!(sent["input"][6].get("call_id").is_none());
|
||||
let ids = [&long_id, &collision_id, &long_custom_id];
|
||||
let mut distinct_ids = BTreeSet::new();
|
||||
let mut distinct_names = BTreeSet::new();
|
||||
for (index, original_id) in ids.into_iter().enumerate() {
|
||||
let id = sent["input"][index]["call_id"].as_str().unwrap();
|
||||
assert_eq!(id, sent["input"][index + 3]["call_id"]);
|
||||
assert!(distinct_ids.insert(id));
|
||||
let name = sent["tools"][index]["name"].as_str().unwrap();
|
||||
assert_eq!(name, sent["input"][index]["name"]);
|
||||
assert!(distinct_names.insert(name));
|
||||
if api_key || index == 1 {
|
||||
assert_eq!(id, original_id);
|
||||
} else {
|
||||
assert!(id.len() <= 64);
|
||||
assert_ne!(id, original_id);
|
||||
}
|
||||
if !api_key {
|
||||
assert!(name.bytes().all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'_' | b'-')));
|
||||
}
|
||||
}
|
||||
assert_eq!(sent["input"][6]["name"], sent["tools"][0]["name"]);
|
||||
assert_eq!(
|
||||
sent["tool_choice"]["tools"][0]["name"],
|
||||
sent["tools"][0]["name"]
|
||||
);
|
||||
assert_eq!(
|
||||
sent["tool_choice"]["tools"][1]["name"],
|
||||
sent["tools"][2]["name"]
|
||||
);
|
||||
assert_eq!(sent["tools"][1]["name"], "mcp_server_tool");
|
||||
assert_eq!(sent["tools"][3]["name"], long_name);
|
||||
server.verify().await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn complete_json_restores_oauth_tool_names_for_each_chat_delivery() {
|
||||
for streaming in [false, true] {
|
||||
let server = MockServer::start().await;
|
||||
let store = Arc::new(MemoryAccountStore::default());
|
||||
create_account(&store, "acct_provider_contract").await;
|
||||
let request = json!({"model":"gpt-5.4","stream":streaming,"messages":[{"role":"user","content":"hello"}],
|
||||
"tools":[{"type":"function","function":{"name":"工具.lookup"}}]});
|
||||
let operation = Operation::Generate(GenerateRequest::from_protocol_payload(
|
||||
ProtocolPayload::json_object("chat_completions", request.as_object().unwrap().clone())
|
||||
.unwrap(),
|
||||
));
|
||||
let mut stream = provider_with_base_url(&store, server.uri())
|
||||
.execute(
|
||||
planned_request("openai", operation),
|
||||
context("req_tool_json", CancellationToken::new()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let response = json!({"id":"r","object":"response","model":"gpt-5.4","status":"completed",
|
||||
"output":[{"type":"function_call","id":"fc_1","call_id":"call_1","name":"___lookup","arguments":"{}"}],
|
||||
"usage":{"input_tokens":1,"output_tokens":1,"total_tokens":2}});
|
||||
let wire =
|
||||
ProtocolWireEvent::raw_json("openai", serde_json::to_vec(&response).unwrap().into())
|
||||
.unwrap();
|
||||
let events = stream
|
||||
.translate_native_response(ProviderEvent::wire(wire), true)
|
||||
.unwrap();
|
||||
let mut accumulator = ChatAccumulator::default();
|
||||
for wire in events.iter().filter_map(|event| event.wire_event()) {
|
||||
if let Some(raw) = wire.raw_json_body() {
|
||||
let result: Value = serde_json::from_slice(raw).unwrap();
|
||||
assert_eq!(
|
||||
result["choices"][0]["message"]["tool_calls"][0]["function"]["name"],
|
||||
"工具.lookup"
|
||||
);
|
||||
} else {
|
||||
accumulator.push(wire.data()).unwrap();
|
||||
}
|
||||
}
|
||||
if streaming {
|
||||
let result = accumulator.finish().unwrap();
|
||||
assert_eq!(
|
||||
result["choices"][0]["message"]["tool_calls"][0]["function"]["name"],
|
||||
"工具.lookup"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ mod account_isolation;
|
||||
mod cache_preference;
|
||||
mod capacity;
|
||||
mod catalog_startup;
|
||||
mod chat_tools;
|
||||
mod cookies;
|
||||
mod correlation;
|
||||
mod error_details;
|
||||
|
||||
@@ -222,7 +222,8 @@ async fn privacy_workspace_alias_matches_websocket_opening_and_reused_frames() {
|
||||
let body: Value = serde_json::from_str(&frame).unwrap();
|
||||
aliases.push(assert_workspace_alias(&metadata, &body));
|
||||
let completed = json!({"type":"response.completed","response":{
|
||||
"id":format!("resp_workspace_{n}"),"model":"gpt-5.4","status":"completed","output":[]
|
||||
"id":format!("resp_workspace_{n}"),"model":"gpt-5.4","status":"completed",
|
||||
"output":[{"type":"message","role":"assistant","content":[{"type":"output_text","text":"ok"}]}]
|
||||
}});
|
||||
socket
|
||||
.send(Message::Text(completed.to_string().into()))
|
||||
@@ -667,7 +668,14 @@ async fn privacy_header_change_isolates_websocket_then_reuses_stable_headers() {
|
||||
let body: Value = serde_json::from_str(&frame).unwrap();
|
||||
assert_eq!(body["input"][0]["content"][0]["text"], "hellohello");
|
||||
cache_keys.push(body["prompt_cache_key"].as_str().unwrap().to_owned());
|
||||
socket.send(Message::Text(json!({"type":"response.completed","response":{"id":format!("resp_privacy_pool_{}",cache_keys.len()),"model":"gpt-5.4","status":"completed","output":[]}}).to_string().into())).await.unwrap();
|
||||
let completed = json!({"type":"response.completed","response":{
|
||||
"id":format!("resp_privacy_pool_{}", cache_keys.len()),"model":"gpt-5.4","status":"completed",
|
||||
"output":[{"type":"message","role":"assistant","content":[{"type":"output_text","text":"ok"}]}]
|
||||
}});
|
||||
socket
|
||||
.send(Message::Text(completed.to_string().into()))
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
// 保留第一条连接,确保下一次握手是池隔离的结果而非断线重连
|
||||
sockets.push(socket);
|
||||
|
||||
@@ -112,8 +112,13 @@ async fn search_history_preserves_existing_tools_and_explicit_choices() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn search_history_keeps_existing_search_declarations_in_all_supported_locations() {
|
||||
for kind in ["web_search", "web_search_preview"] {
|
||||
async fn search_history_preserves_options_and_adapts_known_search_aliases() {
|
||||
for (kind, codex_kind) in [
|
||||
("web_search", "web_search"),
|
||||
("web_search_preview", "web_search"),
|
||||
("web_search_preview_2025_03_11", "web_search"),
|
||||
("web_search_preview_future", "web_search_preview_future"),
|
||||
] {
|
||||
for location in ["top", "additional_tools", "tool_search_output"] {
|
||||
let mut original = search_request();
|
||||
let tool = json!({"type":kind,"external_web_access":true,"search_context_size":"high"});
|
||||
@@ -127,8 +132,25 @@ async fn search_history_keeps_existing_search_declarations_in_all_supported_loca
|
||||
}),
|
||||
);
|
||||
}
|
||||
let actual = capture_downstream_request(original.clone(), false, false, true).await;
|
||||
assert_request_fields(&actual, &original);
|
||||
original["tool_choice"] =
|
||||
json!({"type":"allowed_tools","mode":"auto","tools":[{"type":kind}]});
|
||||
for api_key in [false, true] {
|
||||
for websocket in [false, true] {
|
||||
let mut expected = original.clone();
|
||||
if !api_key {
|
||||
if location == "top" {
|
||||
expected["tools"][0]["type"] = codex_kind.into();
|
||||
} else {
|
||||
expected["input"][0]["tools"][0]["type"] = codex_kind.into();
|
||||
}
|
||||
expected["tool_choice"]["tools"][0]["type"] = codex_kind.into();
|
||||
}
|
||||
let actual =
|
||||
capture_downstream_request(original.clone(), api_key, websocket, true)
|
||||
.await;
|
||||
assert_request_fields(&actual, &expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,15 +6,22 @@ use super::*;
|
||||
async fn http_history_follows_completed_output_on_its_own_connection() {
|
||||
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||
let addr = listener.local_addr().unwrap();
|
||||
let tool = json!({"type":"function_call","name":"lookup","call_id":"c","arguments":"{}"});
|
||||
let message = json!({"type":"message","role":"assistant","content":"ok"});
|
||||
let tool = json!({"type":"function_call","id":"fc","status":"completed","name":"lookup","call_id":"c","arguments":"{}"});
|
||||
let message = json!({"type":"message","id":"msg","role":"assistant","content":[{"type":"output_text","text":"ok","annotations":[],"logprobs":[]}]});
|
||||
let reasoning =
|
||||
json!({"type":"reasoning","id":"rs","encrypted_content":"ciphertext","summary":[]});
|
||||
let (frames, mut seen) = tokio::sync::mpsc::unbounded_channel();
|
||||
let server = tokio::spawn({
|
||||
let tool = tool.clone();
|
||||
let message = message.clone();
|
||||
let mut tool = tool.clone();
|
||||
tool["metadata"] = json!({"turn_id":"turn"});
|
||||
tool["internal_chat_message_metadata_passthrough"] = json!({"turn_id":"turn"});
|
||||
let mut message = message.clone();
|
||||
message["metadata"] = json!({"turn_id":"turn"});
|
||||
let mut reasoning = reasoning.clone();
|
||||
reasoning["content"] = json!([]);
|
||||
async move {
|
||||
// 更换会话池键后在另一条连接上从全量重新开始
|
||||
for turns in [0..6, 6..9] {
|
||||
for turns in [0..6, 6..16] {
|
||||
let (socket, _) = listener.accept().await.unwrap();
|
||||
let mut ws = accept_codex_test_websocket(socket).await;
|
||||
for turn in turns {
|
||||
@@ -23,13 +30,18 @@ async fn http_history_follows_completed_output_on_its_own_connection() {
|
||||
.send(serde_json::from_str::<Value>(&frame).unwrap())
|
||||
.unwrap();
|
||||
let output = if turn == 0 {
|
||||
for event in ["response.output_item.added", "response.output_item.done"] {
|
||||
let event = json!({"type":event,"item":tool,"output_index":0});
|
||||
ws.send(Message::Text(event.to_string().into()))
|
||||
.await
|
||||
.unwrap();
|
||||
for (index, item) in [&reasoning, &tool].into_iter().enumerate() {
|
||||
for event in ["response.output_item.added", "response.output_item.done"]
|
||||
{
|
||||
let event = json!({"type":event,"item":item,"output_index":index});
|
||||
ws.send(Message::Text(event.to_string().into()))
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
json!([])
|
||||
} else if turn == 14 {
|
||||
json!([])
|
||||
} else {
|
||||
json!([message])
|
||||
};
|
||||
@@ -60,24 +72,53 @@ async fn http_history_follows_completed_output_on_its_own_connection() {
|
||||
.with_websocket_pool(Arc::new(CodexWebSocketPool::default()));
|
||||
|
||||
let mut history = vec![json!({"role":"user","content":"start"})];
|
||||
for turn in 0..9 {
|
||||
for turn in 0..16 {
|
||||
let next = json!({"role":"user","content":format!("turn {turn}")});
|
||||
match turn {
|
||||
0 => {}
|
||||
1 => {
|
||||
history.push(reasoning.clone());
|
||||
history.push(tool.clone());
|
||||
history.push(json!({"type":"function_call_output","call_id":"c","output":"found"}));
|
||||
history.push(json!({"type":"function_call_output","call_id":"c","output":"found",
|
||||
"internal_chat_message_metadata_passthrough":{"turn_id":"one","executed_tool_calls":[
|
||||
{"name":"lookup","arguments":{},"tool_result_metadata":{"revision":1}}
|
||||
]}
|
||||
}));
|
||||
}
|
||||
_ => {
|
||||
history.push(message.clone());
|
||||
history.push(next);
|
||||
let mut replay = message.clone();
|
||||
match turn {
|
||||
// 采样输出可带回服务端元数据,正文变化则属于历史分支
|
||||
9 => replay["metadata"] = json!({"turn_id":"turn"}),
|
||||
10 => replay["metadata"] = json!({"turn_id":"edited"}),
|
||||
11 => replay["content"][0]["text"] = json!("edited"),
|
||||
_ => {}
|
||||
}
|
||||
if turn != 15 {
|
||||
history.push(replay);
|
||||
}
|
||||
if turn != 12 {
|
||||
history.push(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
if turn == 2 {
|
||||
history[3]["internal_chat_message_metadata_passthrough"]["turn_id"] = json!("two");
|
||||
}
|
||||
if turn == 13 {
|
||||
history[3]["internal_chat_message_metadata_passthrough"]["executed_tool_calls"][0]["tool_result_metadata"]
|
||||
["revision"] = json!(2);
|
||||
}
|
||||
if turn == 3 {
|
||||
history[0]["content"] = json!("edited");
|
||||
}
|
||||
let instructions = if turn < 4 { "original" } else { "changed" };
|
||||
let mut request = codex_request("model", instructions, history.clone());
|
||||
let mut body = codex_request_body("model", instructions, history.clone());
|
||||
body.insert("client_extension".into(), json!(turn));
|
||||
if turn >= 14 {
|
||||
body.insert("tools".into(), json!([{"type":"function","name":"other"}]));
|
||||
}
|
||||
let mut request = CodexResponsesRequest::from_body(body);
|
||||
request.client_api_key_id = Some(if turn < 5 { "key-a" } else { "key-b" }.into());
|
||||
request.local_conversation_id = Some(if turn < 6 { "session" } else { "other" }.into());
|
||||
backend
|
||||
@@ -85,9 +126,14 @@ async fn http_history_follows_completed_output_on_its_own_connection() {
|
||||
.await
|
||||
.unwrap();
|
||||
let sent = seen.recv().await.unwrap();
|
||||
if matches!(turn, 1 | 2 | 8) {
|
||||
if matches!(turn, 1 | 2 | 4 | 8 | 9 | 10 | 12 | 15) {
|
||||
assert_eq!(sent["previous_response_id"], format!("resp_{}", turn - 1));
|
||||
assert_eq!(sent["input"], json!([history.last().unwrap()]));
|
||||
let delta = if turn == 12 {
|
||||
json!([])
|
||||
} else {
|
||||
json!([history.last().unwrap()])
|
||||
};
|
||||
assert_eq!(sent["input"], delta, "turn {turn}");
|
||||
} else {
|
||||
assert!(sent.get("previous_response_id").is_none(), "turn {turn}");
|
||||
assert_eq!(sent["input"], json!(history));
|
||||
|
||||
+11
-5
@@ -336,9 +336,9 @@ print(completion.choices[0].message.content)
|
||||
| `file` 内容块 | `file.file_id`、`file.file_data`、`file.file_url` 至少提供一种,保留可选 `filename`;URL 和非 PDF 文件为网关的 Responses 扩展,实际支持由上游判断 |
|
||||
| `input_audio` 内容块 | Chat 的 `data` 和 `format` 转为 Responses `audio_url` data URL;原生音频引用与 `input_text`、`input_image`、`input_file` 内容块也可携带 |
|
||||
| `messages[].refusal`、assistant 的 `refusal` 内容块 | 保留 assistant 拒绝历史,各角色消息的 `refusal: ""` 按缺省处理 |
|
||||
| `messages[].tool_calls`、`messages[].tool_call_id` | function 和 custom 调用分别映射到对应 Responses 调用及结果,保留 ID、参数或输入字符串。空调用列表按缺省处理。tool 必须携带调用 ID 和结果,其他角色忽略空 ID。custom 结果须携带前序调用历史 |
|
||||
| `messages[].name` | Responses 将 tool 消息的非空字符串名称随结果携带。Messages 和 GenAI 通过调用 ID 匹配历史。其他角色的名称作为辅助信息忽略 |
|
||||
| `tools` | 展开 function/custom 定义,保留 schema、format 及原生工具对象。function 的 `parameters: null` 按省略处理,`strict` 省略或为 `null` 时使用 `false` |
|
||||
| `messages[].tool_calls`、`messages[].tool_call_id` | function 和 custom 调用分别映射到对应 Responses 调用及结果,保留 ID、参数或输入字符串。空调用列表按缺省处理。tool 必须携带结果;Responses 目标允许调用 ID 缺省或为 `null` 的独立工具输出,此时必须提供非空 `name`,不推断配对或丢弃内容。显式空 ID 仍返回 `400`,其他角色忽略空 ID。custom 结果须携带前序调用历史 |
|
||||
| `messages[].name`、`messages[].namespace` | Responses 将 tool 消息的非空字符串名称和命名空间随结果携带。Messages 和 GenAI 仍要求调用 ID 并匹配历史,不支持无 ID 的独立输出。其他角色的名称和命名空间作为辅助信息忽略 |
|
||||
| `tools` | 展开 function/custom 定义,保留 schema 及原生工具对象。custom 的 `format.grammar` 展开为 Responses 的 `format.syntax` 和 `format.definition`。function 的 `parameters: null` 按省略处理,`strict` 省略或为 `null` 时使用 `false` |
|
||||
| `tool_choice`、`parallel_tool_calls` | 展开指定 function/custom 和 `allowed_tools` 选择;原生选择与并行布尔值交给上游 |
|
||||
| `web_search_options` | `{}` 即要求上游执行 `web_search`;支持 `search_context_size` 与 `user_location.approximate` |
|
||||
| `response_format` | 非 `null` 时优先于 `text.format`,保留 JSON Schema;未知格式交给 Responses 上游 |
|
||||
@@ -355,6 +355,11 @@ print(completion.choices[0].message.content)
|
||||
`seed`、`frequency_penalty`、`presence_penalty`、`logit_bias` 和 `prediction` 没有对应的 Responses 控制语义,接受后忽略,不保证生效。
|
||||
消息的 `reasoning_content` 和 `reasoning` 作为辅助历史忽略,不转为用户正文
|
||||
|
||||
Chat 发往 Codex/OAuth 时,包含 `[A-Za-z0-9_-]` 以外字符的工具名称转换为无冲突别名,
|
||||
工具声明、选择和历史使用同一映射,JSON 与 SSE 响应还原客户端名称。
|
||||
历史调用 ID 超过 64 字符时,调用和对应结果使用同一短 ID;名称与 ID 映射仅限当前请求,
|
||||
工具参数和结果正文保持原值
|
||||
|
||||
`n`、`store`、`background`、`modalities` 和 `functions` 可省略或为 `null`。非空值仅接受 `n: 1`、`store: false`、`background: false`、`modalities: ["text"]` 和 `functions: []`。
|
||||
网关拒绝 `function_call`、`function` 消息角色、音频输出和无法映射的内容类型。
|
||||
入口不接收 `input`、`previous_response_id` 或 `conversation`;需要服务端续接时使用 `/v1/responses`
|
||||
@@ -612,6 +617,7 @@ WS 握手的轮次元数据头只随首次请求转发,后续帧在正文中
|
||||
| `top_p`、`frequency_penalty`、`presence_penalty`、`chat_template_kwargs`、`user`、`metadata`、`safety_identifier` | 省略;采样参数取默认值时也省略 |
|
||||
| `stream_options.include_usage` | 省略该成员,保留其他流式选项 |
|
||||
| `truncation`、`stop_sequences`、`prompt_cache_options` | 分别仅在值为 `"disabled"`、`[]`、`{}` 时省略;显式策略交给上游校验 |
|
||||
| 搜索工具声明与 `tool_choice` | `web_search_preview`、`web_search_preview_2025_03_11` 映射为 `web_search`,保留搜索选项;同样适用于 `additional_tools`、`tool_search_output` 和 `allowed_tools` 中的声明 |
|
||||
|
||||
选定 Codex/OAuth 上游后,HTTP 和 WebSocket 按相同规则处理 `input` 中的回放条目,适用于所有 User-Agent。API Key 上游保留这些历史字段
|
||||
|
||||
@@ -669,7 +675,7 @@ Responses WebSocket 接受文本消息,`response.create` 在同一连接串行
|
||||
| WS → SSE | 通常保留下游 WS。需要完整重放的 OpenAI 大包回退按下述规则重连 |
|
||||
| WS → WS | 保留当前绑定的上游 WS,支持下一轮续接 |
|
||||
|
||||
Codex OAuth 的 SSE 客户端可以每轮提交完整历史。网关先执行隐私规则,再用处理后的内容匹配历史。复用同一上游 WS 时,若同一 Client Key 的请求配置和历史前缀匹配上一轮已完成的输入、输出,网关使用 `previous_response_id` 和新增输入续接。换连接或历史不匹配时发送本次完整输入。此优化用于 `store=false` 的生成请求;显式续接和出站插件接管的帧沿用各自的传输合同
|
||||
Codex OAuth 的 SSE 客户端可以每轮提交完整历史。网关先执行隐私规则,再用处理后的内容匹配历史。复用同一上游 WS 时,若同一 Client Key 的模型、工具、推理等 Codex 续接配置相同,且历史前缀匹配上一轮已完成的输入、输出,网关使用 `previous_response_id` 和剩余输入续接。剩余输入可以为空,每轮元数据及额外的请求属性随本轮转发。换连接或历史不匹配时发送本次完整输入。此优化用于 `store=false` 的生成请求;显式续接和出站插件接管的帧沿用各自的传输合同
|
||||
|
||||
活跃客户端 WS 的绑定不受普通空闲回收期限约束;上游 Close(不限关闭码)、EOF、传输读写失败、总寿命到期或连接被回收仍可能使连接内续接失效,
|
||||
网关在收到绑定上游的失效通知且下游空闲时,以关闭码 1000 要求客户端重连并发送完整输入。
|
||||
@@ -2333,7 +2339,7 @@ OpenAI Key 的 `installationSeed` 接受带连字符的 UUID,保存时规范
|
||||
|
||||
金额字段为非负十进制字符串,最多 10 位整数与 10 位小数,`"0"` 表示不限额。
|
||||
创建时省略金额字段默认为零;更新时省略或 `null` 保留当前值,修改限额不会清空已用金额。
|
||||
`maxConcurrency` 和 `requestsPerMinute` 是非负整数,零表示不限
|
||||
`maxConcurrency` 限制同一 Key 同时执行的请求数,`requestsPerMinute` 限制同一 Key 在最近 60 秒内成功准入的请求数。两项接受非负 64 位有符号整数,零表示不限
|
||||
|
||||
列表返回 `dailyLimitUsd`、`weeklyLimitUsd`、`dailyUsedUsd`、`weeklyUsedUsd`(均为字符串)、
|
||||
`dailyResetsAt`、`weeklyResetsAt`(RFC3339 或 `null`)。
|
||||
|
||||
@@ -810,7 +810,7 @@ Continuation 受原请求的 Client Key、账号范围、Provider 和发送/交
|
||||
- OpenAI Provider 在发送前按上游握手声明的消息大小上限检查最终出站帧,新链可选择 HTTP;超限的 connection-local
|
||||
续接和已标记为需要重放的 HTTP/WS 增量返回 `ClientReplayRequired`,由客户端重发
|
||||
完整历史。预检拒绝先释放连接及租约,不消耗 WS 故障预算;Provider session state 只携带元数据,不保存 transcript
|
||||
- Codex OAuth 的 HTTP 全量历史由独占租用的上游 WS 比较。连接只持有上一轮的响应 ID、项数和绑定 Client Key 与请求属性的前缀摘要,随连接回收;增量只改写出站帧,本次完整请求仍可用于安全回退
|
||||
- Codex OAuth 的 HTTP 全量历史由独占租用的上游 WS 比较。连接只持有上一轮的响应 ID、项数和绑定 Client Key 与请求属性的前缀摘要,随连接回收。请求属性采用 Codex 的续接字段集。历史项按顺序比较,忽略 Codex 回传省略的采样和内部元数据,工具结果及其调用绑定仍参与比较。增量只改写出站帧,本次完整请求仍可用于安全回退
|
||||
- OpenAI 在有效输出交付前收到可安全重放的明确额度拒绝时,先隔离账号,再投影 `ClientReplayRequired`;
|
||||
丢弃未交付的原错误帧,由客户端提交完整历史开启新链,不把原增量输入交给其他账号。
|
||||
真实错误分类、状态码、发送状态和上游诊断保持不变,客户端合同见 [Responses API](api.md#3-模型数据面与模型目录)
|
||||
@@ -1469,6 +1469,7 @@ OpenAI 客户端画像由 Provider 每小时检查发布元数据,发布标识
|
||||
版本及缓存更新失败保留当前画像,下轮继续尝试;Host 只监督调度与取消。
|
||||
|
||||
Antigravity 启动时恢复有效制品缓存,每小时检查发布资料。后台按已使用的客户端、平台和架构核对发布包版本并提取 CL,CLI 同时校验清单的 SHA-512。
|
||||
需要完整下载的制品写入运行数据目录下 `antigravity/` 中的匿名临时文件,解析结束或取消后释放。
|
||||
版本、CL 和核验时间绑定同一制品。缓存每 24 小时续期,保留 30 天及原核验时间。Provider 在缓存写入成功后整组发布画像,失败保留当前画像。
|
||||
发布资料单独记录最新观测,供管理端展示。
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -33,7 +33,7 @@ function select() {
|
||||
<div class="grid gap-2">
|
||||
<ProviderSelect v-if="!provider" v-model="selectedProvider" :aria-label="t('keys.configuration.platform')" />
|
||||
<div
|
||||
class="flex items-center gap-1 rounded-z-sm pr-1 transition-colors hover:bg-z-bg-text-hover has-focus-visible:bg-z-bg-text-hover motion-reduce:transition-none"
|
||||
class="flex items-center gap-1 rounded-z-sm bg-z-fill-quaternary pr-3 shadow-z-tertiary transition-colors hover:bg-z-bg-text-hover has-focus-visible:bg-z-bg-text-hover motion-reduce:transition-none"
|
||||
>
|
||||
<ZMenuItem class="min-h-18 min-w-0 py-3 hover:bg-transparent!" @click="select">
|
||||
<template #icon>
|
||||
|
||||
@@ -78,7 +78,7 @@ watch(
|
||||
<main class="relative isolate h-dvh min-w-0 flex-1 overflow-hidden">
|
||||
<!-- 让主滚动区自身绘制不透明底色,浏览器可在合成线程滚动 -->
|
||||
<ZScrollbar ref="pageScrollbarRef" class="[&>.z-scrollbar-hidden]:bg-z-bg-layout">
|
||||
<div class="page-slot flex min-h-full min-w-0 flex-col p-4 min-[961px]:p-6">
|
||||
<div class="page-content flex min-h-full min-w-0 flex-col p-(--page-padding)">
|
||||
<RouterView v-slot="{ Component }">
|
||||
<component :is="Component" class="min-h-0 flex-1" />
|
||||
</RouterView>
|
||||
@@ -118,6 +118,18 @@ watch(
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.page-content {
|
||||
--page-padding: calc(var(--spacing) * 4);
|
||||
/* 页面只消费正文高度,标题栏与外侧留白在布局层统一扣除 */
|
||||
--page-height: calc(var(--app-height, 100dvh) - var(--page-padding) * 2);
|
||||
}
|
||||
|
||||
@media (width >= 961px) {
|
||||
.page-content {
|
||||
--page-padding: calc(var(--spacing) * 6);
|
||||
}
|
||||
}
|
||||
|
||||
.mobile-sidebar-enter-active,
|
||||
.mobile-sidebar-leave-active {
|
||||
transition: opacity 180ms ease;
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
@import '@codex-proxy/ui/tailwind.css';
|
||||
@import 'tailwindcss/utilities.css' layer(utilities);
|
||||
|
||||
@utility h-page {
|
||||
height: var(--page-height);
|
||||
}
|
||||
|
||||
/* 浏览器移交标签页时不会重新挂载应用,标题栏留白直接跟随当前窗口模式 */
|
||||
@media (display-mode: standalone), (display-mode: window-controls-overlay) {
|
||||
.supports-titlebar-overlay {
|
||||
@@ -18,8 +22,7 @@
|
||||
padding-top: var(--app-titlebar-inset);
|
||||
}
|
||||
|
||||
.supports-titlebar-overlay .h-dvh,
|
||||
.supports-titlebar-overlay .page-slot {
|
||||
.supports-titlebar-overlay .h-dvh {
|
||||
height: var(--app-height);
|
||||
}
|
||||
|
||||
@@ -27,15 +30,6 @@
|
||||
min-height: var(--app-height);
|
||||
}
|
||||
|
||||
/* 满屏面板不能高于正文;矮窗仍由外层滚动到列表底部 */
|
||||
.supports-titlebar-overlay .page-slot > * {
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.supports-titlebar-overlay .page-slot > .h-full {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/* 通知挂在 body,固定定位不会避开标题栏 */
|
||||
.supports-titlebar-overlay article[id^='z-notification-'] {
|
||||
translate: 0 var(--app-titlebar-inset);
|
||||
|
||||
@@ -211,7 +211,7 @@ const {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex min-h-0 w-full flex-col xl:h-[calc(100dvh-3rem)] xl:flex-none!">
|
||||
<div class="flex min-h-0 w-full flex-col xl:h-page xl:flex-none!">
|
||||
<ZPageHeader
|
||||
:title="t('navigation.accounts')"
|
||||
:description="t('accounts.page.description')"
|
||||
|
||||
@@ -60,14 +60,14 @@ const { allSelected, indeterminate, selectedRowKeys, toggleSelection, toggleAll
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full min-h-0 w-full flex-col overflow-hidden">
|
||||
<div class="flex h-page min-h-min! w-full flex-none! flex-col">
|
||||
<ZPageHeader
|
||||
:title="t('navigation.groups')"
|
||||
:description="t('groups.page.description')"
|
||||
/>
|
||||
|
||||
<ZCard
|
||||
class="mt-5 flex h-[calc(100dvh-136px)] min-h-125 flex-col"
|
||||
class="mt-5 flex min-h-125 flex-1 basis-0 flex-col"
|
||||
>
|
||||
<template #header>
|
||||
<AccountGroupFilters
|
||||
|
||||
@@ -151,14 +151,14 @@ watch([showFormModal, showBatchEdit], ([editor, batch]) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full min-h-0 w-full flex-col overflow-hidden">
|
||||
<div class="flex h-page min-h-min! w-full flex-none! flex-col">
|
||||
<ZPageHeader
|
||||
:title="t('navigation.apiKeys')"
|
||||
:description="t('keys.page.description')"
|
||||
/>
|
||||
|
||||
<ZCard
|
||||
class="mt-5 flex h-[calc(100dvh-136px)] min-h-125 flex-col"
|
||||
class="mt-5 flex min-h-125 flex-1 basis-0 flex-col"
|
||||
>
|
||||
<template #header>
|
||||
<ApiKeyFilters
|
||||
|
||||
@@ -37,7 +37,7 @@ const tabOptions = computed(() => ([
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-[calc(100dvh-2rem)] min-h-0 w-full flex-none! flex-col gap-3 overflow-hidden min-[961px]:h-[calc(100dvh-3rem)]">
|
||||
<div class="flex h-page min-h-0 w-full flex-none! flex-col gap-3 overflow-hidden">
|
||||
<ZPageHeader :title="t('navigation.plugins')" :description="t('plugins.management.description')" />
|
||||
|
||||
<div class="flex shrink-0 items-start gap-3">
|
||||
|
||||
@@ -78,12 +78,12 @@ watch(search, () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full min-h-0 w-full flex-col overflow-hidden">
|
||||
<div class="flex h-page min-h-min! w-full flex-none! flex-col">
|
||||
<ZPageHeader
|
||||
:title="t('navigation.proxies')"
|
||||
:description="t('proxies.page.description')"
|
||||
/>
|
||||
<ZCard class="mt-5 flex h-[calc(100dvh-136px)] min-h-125 flex-col">
|
||||
<ZCard class="mt-5 flex min-h-125 flex-1 basis-0 flex-col">
|
||||
<template #header>
|
||||
<div class="flex w-full flex-col gap-3 sm:flex-row sm:items-center">
|
||||
<ZInput v-model="search" :disabled="batchTesting" class="sm:w-80" :aria-label="t('proxies.page.searchLabel')" :placeholder="t('proxies.page.searchPlaceholder')">
|
||||
|
||||
@@ -188,7 +188,7 @@ watch(() => !loading.value && route.hash === '#reset-credits', async (ready) =>
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="@container/settings w-full" :class="section === 'pricing' ? 'flex h-[calc(100dvh-2rem)] flex-none! flex-col min-[961px]:h-[calc(100dvh-3rem)]' : undefined">
|
||||
<div class="@container/settings w-full" :class="section === 'pricing' ? 'flex h-page flex-none! flex-col' : undefined">
|
||||
<ZPageHeader :title="t('navigation.settings')" :description="t('settings.page.description')" />
|
||||
|
||||
<div class="mt-4 flex min-h-z-control shrink-0 flex-wrap items-center justify-between gap-3">
|
||||
|
||||
@@ -3,7 +3,7 @@ import AppearanceSettingsSection from './components/AppearanceSettingsSection.vu
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="min-h-0 w-full xl:h-[calc(100dvh-3rem)] xl:flex-none">
|
||||
<div class="min-h-0 w-full xl:h-page xl:flex-none">
|
||||
<AppearanceSettingsSection class="h-full" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -2,6 +2,6 @@ version: 3.61.1-rc.4
|
||||
published:
|
||||
'3':
|
||||
stable: 3.61.0
|
||||
rc: 3.61.1-rc.3
|
||||
beta: 3.61.1-rc.3
|
||||
alpha: 3.61.1-rc.3
|
||||
rc: 3.61.1-rc.4
|
||||
beta: 3.61.1-rc.4
|
||||
alpha: 3.61.1-rc.4
|
||||
|
||||
Reference in New Issue
Block a user