Commit Graph

60 Commits

Author SHA1 Message Date
RWDai
d5d93eda11 Fix affinity key parsing and counters 2026-05-07 15:08:07 +08:00
fawney19
fd44906bb7 fix provider pool quota status handling 2026-05-07 11:28:44 +08:00
fawney19
10e679bb2f Add provider key cycle stats reset handling 2026-05-07 03:23:20 +08:00
Kayphoon
79cb9b502a feat(pool): add codex cycle stats mode 2026-05-07 00:07:32 +08:00
fawney19
f959f02d40 Implement transport profile routing 2026-05-05 22:21:23 +08:00
fawney19
aacab1a90c Merge remote-tracking branch 'origin/aether-rust-pioneer' into aether-rust-pioneer
# Conflicts:
#	crates/aether-data-contracts/src/repository/usage/mod.rs
#	crates/aether-data/src/repository/global_models/postgres.rs
#	crates/aether-data/src/repository/usage/postgres/mod.rs
2026-05-05 18:53:14 +08:00
fawney19
fce7e959e5 Add multi-database data layer
Introduce aether-data-schema and driver-specific schema generation for Postgres, MySQL, and SQLite.

Split data backends, lifecycle, repositories, and gateway runtime integration across database drivers.

Verified with cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, and cargo test --workspace.
2026-05-05 18:27:36 +08:00
Entropy.Xu
ff1ed8b57d feat(stats): 添加 Provider 性能统计分析 2026-05-05 11:24:16 +08:00
fawney19
53a5e18b20 Merge pull request #370 from yao177/aether-rust-pioneer
fix(proxy): record manual proxy node traffic
2026-05-03 21:40:20 +08:00
fawney19
a24e4a793d Refactor pool candidate scheduling 2026-05-03 20:14:29 +08:00
Yao177
c3d97b8c16 fix(proxy): record manual proxy node traffic
- add manual proxy traffic mutations to the data layer
- record sync and stream outcomes for manual proxy requests
- prevent tunnel proxy nodes from receiving manual traffic updates
2026-05-03 18:38:04 +08:00
fawney19
4fc7cecf30 Fix OAuth token import and table filters 2026-05-01 02:14:49 +08:00
fawney19
e751289dfb Support per-format provider key auth 2026-04-29 15:46:50 +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
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
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
6426b5d80e chore: add oauth refresh diagnostics 2026-04-28 00:18:51 +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
Entropy.Xu
e36fb8c07a Honor global format conversion override (#341)
Apply the global enable_format_conversion setting when building provider transport snapshots so enabled global conversion overrides provider-level settings at runtime.

Keep the cached provider snapshot unchanged so disabling the global switch restores each provider's original conversion configuration.
2026-04-26 23:54:52 +08:00
AAEE86
f3a9fd4c82 feat(gateway): 补齐号池主动探测后台任务 (#342)
- 解析 pool_advanced 主动探测开关与间隔配置
- 对齐 Python 版本的探测间隔默认值和范围限制
- 新增号池配额主动探测 worker
- 支持 codex、kiro、antigravity provider
- 使用 Redis 时间戳和 provider 级锁避免重复探测
- 接入 gateway 后台任务并补充测试
2026-04-26 23:48:31 +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
cf6228f525 feat(stats,rules): api_key 用量统计(total_tokens 字段 + 回填)与 body rules 新增 append/insert/regex_replace/name_style 操作
- 新增迁移 20260422120000_add_api_key_usage_stats.sql,为 api_keys 表添加 total_tokens 列
- 新增回填 20260422120000_backfill_api_key_usage_stats.sql,按历史 usage 重建 api_key 维度汇总
- 在 UsageWriteRepository trait 中添加 rebuild_api_key_usage_stats,补齐 SQL/内存实现及上层调用链
- 内存实现中新增 apply_usage_stats_delta,支持增量更新 api_key 统计快照
- dev.sh:改进临时日志目录管理,并在网关异常退出时输出错误提示
- frontend EndpointFormDialog:将 append 操作从 insert 分支拆分,提供独立 path/value 输入 UI
- rules.rs:扩展 body rules 支持,新增 append/insert/regex_replace/name_style 操作及 WildcardSlice 路径段
2026-04-22 20:16:57 +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
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
fawney19
226a6e58d5 refactor(gateway): 重构格式转换候选资格检查并优化测试基础设施
- 将 format_conversion_disabled 的过滤提前到候选遴选阶段,替代原来的 skip_reason 标记机制
- 为测试添加 execution_runtime_sync_override 直接注入支持,避免启动额外 HTTP 服务器
- 将 submit_terminal_event 改为 async record_terminal_event 确保失败用量事件可靠入库
- 新增 test_support 模块封装可重试的 loopback 端口绑定逻辑
- 前端:poolTrace 将 skipped 从隐藏状态移除,新增 buildPoolParticipatedCandidates 统一新旧链路逻辑,并将 skipped 状态色改为 foreground
2026-04-20 16:59:18 +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
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
fawney19
569242d72f refactor gateway orchestration and failover effects 2026-04-18 11:35:11 +08:00
fawney19
3321bb3ccc Implement independent provider pool scheduling runtime 2026-04-17 23:05:49 +08:00
AAEE86
e5d3722adf fix(admin): force manual oauth refresh to bypass local cache (#308)
Co-authored-by: fawney19 <elky0401@gmail.com>
2026-04-17 14:12:15 +08:00
fawney19
654a41c3b0 Revert "fix(admin): force manual oauth refresh to bypass local cache"
This reverts commit 85a630cfa9.
2026-04-17 13:36:51 +08:00
fawney19
85a630cfa9 fix(admin): force manual oauth refresh to bypass local cache 2026-04-17 13:23:51 +08:00
Entropy.Xu
6964729cb7 feat(payments): 增加兑换码与支付适配框架 (#299)
* feat(payments): 增加兑换码与支付适配框架

* fix(ci): 对齐 Rust 1.95 lint 与格式要求

* fix(payments): harden redeem code wallet credits

---------

Co-authored-by: fawney19 <elky0401@gmail.com>
2026-04-17 10:07:52 +08:00
fawney19
1e0bc61526 feat(gateway/data): 新增 usage 关键词搜索、缓存命中摘要、结算成本摘要及 dashboard 聚合查询能力
- 新增 UsageAuditKeywordSearchQuery,支持多关键词、用户名、API Key 交叉过滤
- 新增 UsageCacheHitSummaryQuery/StoredUsageCacheHitSummary,统计请求缓存命中率
- 新增 UsageSettledCostSummaryQuery/StoredUsageSettledCostSummary,汇总结算成本
- 新增 UsageDashboardSummaryQuery、UsageBreakdownSummaryQuery 等 dashboard 聚合类型
- SQL 层实现对应查询方法,含 list_by_ids、list_usage_audits_by_keyword_search、count_usage_audits_by_keyword_search
- 将上述能力通过 GatewayDataState / AdminAppState 暴露给 handler 层
- user_me_usage 及 dashboard_filters 切换为新查询接口,移除旧的内存过滤逻辑
- 同步更新 memory 层及测试
2026-04-17 01:00:38 +08:00
fawney19
65cd9dc3e5 fix(admin): 修复 usage 观测全表扫描并下推聚合查询
- 收紧 admin usage/stats 默认时间范围和 active 轮询查询
- 将 summary/records/aggregation/time-series/leaderboard 下推到 SQL 侧
- 统一前端时间参数并补齐 admin usage/stats 回归测试
2026-04-16 17:46:19 +08:00
AAEE86
10605d9fb0 fix(admin): 同步 OAuth 刷新后的状态快照有效期 (#300)
手动刷新 OAuth Token 后同步回写 status_snapshot.oauth
修复号池管理页面仍显示旧有效期的问题
补充刷新后快照更新的回归测试
2026-04-16 14:37:59 +08:00
fawney19
67a2ca6e31 perf(gateway): 为 dashboard 接口添加短时响应缓存
新增 DashboardResponseCache,对 stats/daily_stats/provider_status
三个接口按用户维度缓存 15-30 秒,减少重复数据库查询。
2026-04-15 03:03:20 +08:00
fawney19
98ad1172b0 perf(usage): heatmap 改为数据库端按天聚合查询
将 admin 和 user heatmap 从逐条加载 usage audit 记录后在应用层聚合,
改为通过 SQL GROUP BY DATE 在数据库端直接按天汇总, 大幅减少数据传输量。

新增 UsageDailyHeatmapQuery / StoredUsageDailySummary 类型,
在 trait、SQL、内存实现中均补齐 summarize_usage_daily_heatmap 方法。

同时优化 docker-compose: postgres 增加空闲事务超时与 keepalive 参数,
gateway 增加健康检查配置。
2026-04-15 02:11:32 +08:00
fawney19
a4e7ac1df6 feat(proxy): 重构 Proxy 节点管理与隧道系统
- 重构 proxy_nodes 管理端,支持节点注册、心跳、隧道生命周期管理
- 增强 tunnel 嵌入式 hub 和隧道协议
- 重构 aether-proxy 配置、隧道客户端、心跳和调度机制
- 调整 admin OAuth/配额/导入等处理器的参数传递
- 扩展数据迁移模块
- 补充 proxy nodes、OAuth、配额、系统导入等测试
- 更新前端 proxy nodes 视图和 API
2026-04-14 22:51:02 +08:00
fawney19
21ac1825f3 fix(gateway): 修正 Codex 实时配额同步
Close #293

Co-authored-by: AAEE86 <ppk0227@hotmail.com>
2026-04-14 14:51:26 +08:00
fawney19
861ae81ff0 feat(admin): 完善代理节点与 OAuth 授权管理 2026-04-14 14:09:24 +08:00
fawney19
62e0a0338d refactor: 移除 shadow results 相关模块和接口 2026-04-14 09:46:16 +08:00
AAEE86
b2d85d70ca refactor(runtime): 优化管理端摘要查询与维护聚合链路
- 为 provider catalog key 和 video task 列表增加 summary/page 查询与排序能力,减少列表场景读取重字段
- 将多处 SQL 结果读取改为流式收集,降低 `fetch_all` 的内存占用
- 把日/小时统计、钱包日用量等维护任务改为数据库侧 `CTE + upsert` 聚合
- 修复视频任务轮询更新时从本地 snapshot 回填稀疏字段,避免 `prompt` 和请求体信息丢失
2026-04-13 15:44:58 +08:00
fawney19
5bb08e6aa4 feat(gateway): 重构 usage 数据层、迁移系统与系统导入
数据库迁移:
- 引入 baseline v2 bootstrap,空库首次启动自动初始化
- 服务启动不再自动执行迁移,需显式 `--migrate` 运行
- 新增 pending migration 检测,schema 落后时拒绝启动

Usage 数据层:
- usage body 存储外部化为独立 blob 表
- 新增 HTTP audit 表拆分存储请求/响应头与 body ref
- 后台清理任务支持 legacy body ref 元数据迁移
- usage runtime 写入迁移到专用 tokio runtime(独立线程池, 8MB 栈)

系统导入/导出:
- 支持用户、API Keys、钱包数据的完整导入
- 兼容 legacy 与 v1.3+ 两种导出格式

其他改进:
- executor outcome 增加 runtime miss 诊断上下文
- 主 tokio runtime 栈大小调整为 8MB
- 前端 provider 管理支持 base URL 配置
- dev.sh 支持 --migrate 参数
2026-04-13 14:01:22 +08:00