Commit Graph

86 Commits

Author SHA1 Message Date
fawney19
c4ea042eb4 feat: add model directive management 2026-05-03 14:48:25 +08:00
Kayphoon
fe27fb17fb feat: add provider-key concurrent limit (#352)
* feat: add provider-key concurrent limit

* Fix provider key concurrent limit checks

---------

Co-authored-by: fawney19 <elky0401@gmail.com>
2026-05-03 01:55:23 +08:00
jiuwovo-ai
bfd1ea72b3 fix: codex free accounts incorrectly marked as quota exhausted (#366)
* fix: codex free accounts incorrectly marked as quota exhausted when skip_exhausted_accounts enabled

- Cross-validate stored exhausted flag against window used_ratio in snapshot reader
- Guard has_credits:false check with window data presence in upstream_metadata fallback
- Add windows.is_empty() precondition to exhausted_by_credits in snapshot builder

Free codex accounts have has_credits:false (they use window-based quotas, not credits),
but the old logic treated this as credits depleted, skipping actual window usage checks.
This caused all free accounts to be incorrectly marked exhausted.

* test: cover codex free quota windows

---------

Co-authored-by: root <root@ser488556369540.local>
Co-authored-by: fawney19 <elky0401@gmail.com>
2026-05-02 14:11:29 +08:00
fawney19
4fc7cecf30 Fix OAuth token import and table filters 2026-05-01 02:14:49 +08:00
fawney19
33aa70c22b fix scheduler affinity candidate selection 2026-04-30 16:27:24 +08:00
Entropy.Xu
4d59d518d1 fix: correct API key expiry and dashboard savings (#361) 2026-04-30 00:35:32 +08:00
fawney19
e751289dfb Support per-format provider key auth 2026-04-29 15:46:50 +08:00
fawney19
07a319259b Normalize canonical API formats 2026-04-29 10:20:41 +08:00
fawney19
230e7d6259 Normalize management token prefixes 2026-04-28 19:46:38 +08:00
fawney19
3d20c05ef7 Fix OAuth refresh through tunnel proxy 2026-04-28 19:45:34 +08:00
fawney19
9194f78e56 OAuth refresh 隧道代理统一启用 follow-redirects 2026-04-28 17:47:28 +08:00
fawney19
70f747d406 Add shared OAuth flows 2026-04-28 15:46:21 +08:00
fawney19
3f1abb6906 Format OAuth refresh consistency changes 2026-04-28 09:54:35 +08:00
fawney19
29fc0be121 Tighten OAuth refresh consistency 2026-04-28 09:36:42 +08:00
fawney19
321f21ad49 Fix provider OAuth refresh token reuse 2026-04-28 02:00:35 +08:00
fawney19
639f26ed5d fix: force http1 for tunnel oauth refresh 2026-04-28 01:37:40 +08:00
fawney19
9a67497d8c fix: align oauth tunnel refresh transport 2026-04-28 01:10:34 +08:00
fawney19
83e1f99ccf fix: invalidate oauth transport cache after refresh 2026-04-27 23:35:05 +08:00
fawney19
ed17147281 fix: align provider oauth refresh redirects 2026-04-27 22:08:02 +08:00
fawney19
a7a3c9f023 Fix OAuth import proxy handling 2026-04-27 20:05:43 +08:00
fawney19
ea3dc3257e clean up legacy openai cli adapter names 2026-04-26 23:59:53 +08:00
fawney19
5b914aa78c migrate ai format conversion to responses adapters 2026-04-26 23:59:53 +08:00
Entropy.Xu
d784c540b6 fix(kiro): 隐藏 OAuth 刷新重试流程 (#339) 2026-04-25 21:29:45 +08:00
Entropy.Xu
fb46fcd80f feat(rust): 对齐 SMTP 测试与注册邮件 TLS 链路 (#325)
* feat(rust): 对齐 SMTP 连接测试链路

* fix(rust): 修复注册邮件 TLS provider 初始化
2026-04-24 14:59:00 +08:00
fawney19
f3c9835759 feat(pool): 引入 pro_first 调度预设、Pool 候选持久化跳过与诊断信息优化
- 新增 pro_first 调度预设(Pro 优先),更新 plus_first 仅针对 Plus 计划,移除 free_team_first
- Pool 内部候选(pool_key_index 不为空)跳过 DB 持久化(available/skipped/unused 均适用)
- LRU 排序新增 catalog_lru_score 回退:runtime 无记录时使用 last_used_at_unix_secs
- 执行路径 miss 诊断消息细化为中文,按 reason 分类输出可读说明
- build_local_request_candidate_status_record 补充 extra_data 和 created_at_unix_ms 字段
- OpenAI CLI 计划构建流程补充候选评估进度跟踪与 terminal reason 设置
- 前端 PoolSchedulingDialog 增加 pro_first 预设展示,修复 LRU 默认预设检测逻辑
2026-04-24 13:29:05 +08:00
fawney19
5148370253 fix(usage): 修复含失败信号的 pending 请求被误判为活跃的问题
- pending/streaming 状态含 status_code >= 400 或 error_message 时视为 failed
- 候选状态派生改为 failed 优先于 stale pending/streaming
- 活跃请求轮询时保留失败信号字段的更新
- 图片流支持 partial_image 事件转发及从 response.completed 读取最终图片
2026-04-24 03:07:11 +08:00
AAEE86
ccec46eddd fix(admin-api-keys): 独立余额 Key 统计与时间字段改为直读 api_keys 表 (#319)
- 列表/详情/更新响应中的 `total_requests`、`total_tokens`、`created_at`、`last_used_at` 统一直接读取 `api_keys` 导出记录字段
- 保持“已消费”继续走钱包字段(不改消费口径)
- 在 auth 导出记录中补充 `last_used_at_unix_secs`、`created_at_unix_secs`、`updated_at_unix_secs`
- 扩展 auth SQL 查询与 RETURNING 字段映射,确保时间字段完整回传
- 移除 admin api-keys 路由中对 usage summary token 聚合的依赖
- 更新 admin api-keys 控制层测试,校验 token/时间字段来源与格式
2026-04-23 22:32:00 +08:00
fawney19
fa328e18a1 feat: provider api_formats 可空继承、OpenAI 图片 edit/variation 与用量配额多项补强
- 鉴权: provider_api_keys.api_formats 改为可空,OAuth 托管 key 自动继承 provider endpoints 激活格式,相关 handler/测试同步更新
- 图片 planner: OpenAI 图片路由新增 edit/variation 操作并完善参数校验、响应合并与流式处理
- 用量: user me usage 返回区分 client_requested_stream/upstream_is_stream,前端 usage 列表筛选与展示增强
- 统计: stats_daily_model 新增 cache_creation_ephemeral_5m/1h tokens 字段与回填链路
- 配额/observability: quota repository 新增内存与 SQL 扩展,admin observability usage 字段扩充
- 其它: OAuth 导入/轮询收敛、provider 汇总与 pool admin 读写链路小修、新增 system_config 缓存与 provider template handler

Closes #318

Co-authored-by: Entropy.Xu <53283266+Entropy-Xu@users.noreply.github.com>
2026-04-23 14:42:51 +08:00
fawney19
4374f53315 fix(adaptive): 修复 429 计数归零写入及 reset 语义
- sql.rs: UPDATE 时对 concurrent_429_count / rpm_429_count 加 COALESCE(, 0),避免 None 覆写为 NULL
- effects.rs: rpm_429_count 始终写入 Some(projection.rpm_429_count),不再过滤零值;新增 unknown-429 场景下零值持久化的单元测试
- adaptive.rs: reset 接口将两个计数字段置为 Some(0) 而非 None,与数据库默认语义对齐;同步修正集成测试断言
- docker-compose.build.yml: 补充 AETHER_GATEWAY_AUTO_PREPARE_DATABASE 默认开启
- README.md: 同步说明 build compose 也已默认开启自动迁移
2026-04-22 22:16:51 +08:00
fawney19
a5e6bd3b62 feat(stats): 新增聚合读路径与回填机制并重构 dashboard/usage 读取链路
- 新增 stats_user_summary 及 user_daily_provider/api_format/cost_savings 等聚合表
- 扩展 stats_daily/hourly 有效 token 与响应时间等字段,maintenance runtime 同步写入
- 新增 backfill 模块与 --apply-backfills 命令补齐历史聚合数据
- 重写 dashboard_filters、usage_heatmap、user_rollups 查询改走聚合表
- 同步更新 baseline_v2.sql 与 migration 集,README/dev.sh 补充回填用法
2026-04-22 17:29:39 +08:00
fawney19
063ef02306 fix(oauth): 系统导入时清理失效标记并强制刷新 refresh_token,前端徽章优先使用 account_id
- 后端 admin 系统导入 OAuth 凭据时重置 expires_at 与失效标记,并在存在 refresh_token 时触发一次本地刷新
- 前端 OAuth 徽章改为优先展示 account_id,采用去前缀后 5 字符的紧凑格式
2026-04-21 18:06:39 +08:00
fawney19
c5c56ff92f feat(oauth): 允许替换已失效的活跃 OAuth 账号并同步 status_snapshot
- 活跃但 token 已过期或刷新失败的重复账号视为可替换
- 清除失效标记、刷新配额时同步更新 status_snapshot.oauth
- oauth_invalid 清除接口同时识别 invalid_at 与 invalid_reason 两种标记
- 批量导入任务状态区分 created_count / replaced_count,前端据此展示新增/替换统计
- 补充重复替换场景的集成测试,用量测试等待超时从 10s 提升到 30s 以适应并行压力
2026-04-20 22:59:02 +08:00
RWDai
cf7d129595 fix(proxy-nodes): allow management tokens with json null allowed_ips (#317)
* fix(proxy-nodes): allow management tokens with json null allowed_ips

* style(proxy-nodes): format regression test
2026-04-20 21:50:48 +08:00
fawney19
ffe5d16094 fix(oauth): 兼容 Kiro device token 的 snake_case 字段并保留 error 响应体
- device poll 同时接受 accessToken/access_token、refreshToken/refresh_token、expiresIn/expires_in
- post_kiro_device_oidc_json 在解析失败响应时保留完整 JSON 并附加 _error 标记, 避免丢失 authorization_pending 等详细信息
- 补充 authorization_pending 时 device session 保持 pending 状态的测试
2026-04-20 15:00:02 +08:00
fawney19
13bf222b8d refactor(oauth): 抽出 Kiro 刷新逻辑为共享模块并在 device-poll 复用
- 将 batch/kiro_import 中的 Kiro refresh/IDC helpers 抽到 dispatch/kiro.rs 共享
- device-poll 新增 IDC refresh 复核、JWT 缺失时通过 usage 接口回填 email、代理节点写入 key.proxy
- 补充对应集成测试覆盖 refresh 复核与 email 回填路径
2026-04-20 01:06:51 +08:00
fawney19
c1b9d94c84 feat(adaptive): 完善自适应 RPM 学习并将 Pool 调度状态与健康分解耦
- orchestration 新增 AdaptiveSuccess 效果,在成功回报路径上根据利用率窗口扩张 learned_rpm_limit
- 429 路径改用 429_observation/adjustment 记录以及基于历史的置信度评估,新增 last_rpm_peak 边界字段
- Pool 调度状态不再因 health_score 低或熔断而降级/拦截,前端同步移除相关按钮与文案兜底
- 新增前端 poolTrace 工具(附测试)承接原 HorizontalRequestTimeline 内的候选合并逻辑
2026-04-20 00:27:48 +08:00
fawney19
77aac74590 feat(oauth): 完善账号异常识别并在调度/展示层拦截失效 OAuth 密钥
- 新增 aether-admin provider status 模块,统一解析账号状态(禁用/工作区停用等)
- 调度器 runtime 增加 oauth_invalid 判定,跳过刷新失败或已撤销的 OAuth 密钥(REQUEST_FAILED 保留可选)
- gateway state 在 local oauth 刷新返回 4xx 时持久化失败原因并同步状态快照
- admin pool 列表/详情回填 account 状态与 scheduling 阻塞原因(account_blocked)
- 共享 catalog 的 status_snapshot payload 附加 account 字段
2026-04-19 20:50:31 +08:00
fawney19
c302dfe42d fix(usage): 完善 cache-affinity 时间线的用户名回退与模型空值兜底
- 当 auth 用户查询失败时回退到历史 username,避免时间线丢失用户信息
- SQL 投影对 usage.model 使用 COALESCE 兜底空值
- IntervalTimelineCard 在刷新间隔为 0 时跳过定时刷新
- Usage 页面关闭时间线卡片的自动轮询
2026-04-19 16:07:01 +08:00
fawney19
97cd877ce5 style(proxy-nodes): 统一缩进并移除未使用的 confirmWarning 引用 2026-04-19 13:46:21 +08:00
fawney19
7007d7a556 refactor(proxy-nodes): 简化批量升级为直接写入 upgrade_to 目标
- 后端移除分波 rollout/探测逻辑,改为一次性给所有合格 tunnel 节点写入升级目标,并自动取消活动中的 rollout
- 前端移除 rollout 进度、阶段筛选、重试/跳过/冲突清理等相关 UI 和交互
- 同步更新批量升级接口类型与测试用例
2026-04-19 13:38:59 +08:00
fawney19
e6fd95453d test(proxy-nodes): 将离线隧道用例的连通性探测指向 Cloudflare 以避免环境抖动 2026-04-19 04:03:37 +08:00
AAEE86
6666992d01 feat(admin): 将用户管理的用量统计改为全量累计口径 (#314)
- 新增按用户 ID 批量汇总 usage 的后端查询
- 在 /api/admin/users 中返回 request_count 和 total_tokens
- 移除用户管理页面额外的 usage 聚合请求
- 为管理端用户列表补充累计统计回归测试
2026-04-19 01:26:22 +08:00
AAEE86
bafb63a665 持久化 provider key 使用统计并移除 usage 汇总覆盖 (#313)
* 持久化 provider key 使用统计并移除 usage 汇总覆盖

- 在 usage upsert 时按请求前后差值同步 provider_api_keys 统计
- 增加基于保留 usage 记录的 provider key 统计重建能力
- 号池管理列表直接读取 provider_api_keys 统计字段

* fix: harden provider key usage stats sync

---------

Co-authored-by: fawney19 <elky0401@gmail.com>
2026-04-19 01:02:09 +08:00
RWDai
425227509a Fix/provider query cli model tests (#312)
* fix(admin): support openai cli provider-query model tests

* fix(admin): support claude and gemini cli provider-query model tests

* fix(admin): preserve provider-query prompts on cli fallback

* test(usage): relax async status wait for local usage checks

* fix(gateway): align provider-query CLI auth and headers

* fix(gateway): resolve provider-query clippy lint

---------

Co-authored-by: fawney19 <elky0401@gmail.com>
2026-04-18 23:05:39 +08:00
fawney19
f2a3836877 Improve tunnel proxy diagnostics and request body spooling 2026-04-18 21:13:37 +08:00
fawney19
3363592751 Refactor usage body capture and stream terminal reporting 2026-04-18 17:48:21 +08:00
fawney19
569242d72f refactor gateway orchestration and failover effects 2026-04-18 11:35:11 +08:00
RWDai
dd4641d618 Fix/provider query non kiro tests (#311)
* fix(admin): enable local provider-query tests for non-kiro providers

* test(admin): cover non-kiro provider-query model execution

* fix(admin): preserve provider-query test errors and failover retries

* fix(admin): handle provider-query test alias and HTTP retry edges

* fix(admin): extend provider-query failover coverage and fallback behavior

* fix(admin): prefer supported endpoints for provider-query tests

* fix(admin): prefer provider-query endpoints with compatible keys

* fix(admin): fall back to compatible provider-query endpoints

* fix(admin): align provider-query local tests with transport policy

---------

Co-authored-by: fawney19 <elky0401@gmail.com>
2026-04-17 19:45:20 +08:00
fawney19
0ce61bc91c fix(gateway): align provider restrictions with provider catalog 2026-04-17 18:59:13 +08:00
fawney19
7eae1f90f6 Unify quota snapshots and oauth refresh handling 2026-04-17 18:22:41 +08:00