From c7b957c4d451653b2daa57fec9a2d9a7e302836e Mon Sep 17 00:00:00 2001 From: Jidekin Date: Fri, 20 Nov 2026 16:30:42 +0800 Subject: [PATCH] =?UTF-8?q?refactor!:=20=E6=8A=80=E6=9C=AF=E6=A0=87?= =?UTF-8?q?=E8=AF=86=E4=B9=9F=E5=85=A8=E9=83=A8=E6=8D=A2=E6=8E=89=EF=BC=88?= =?UTF-8?q?logger=20/=20UA=20/=20=E8=84=9A=E6=9C=AC=20/=20=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=20/=20=E6=96=87=E6=A1=A3=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 老板要求:技术标识也要换,脚本啥的都换。 运行时 · 所有 logging.getLogger("api-gateway…") → "xiaoyin-gateway…"(main/metrics/circuit/settings/sessions/users/gomodels/video_owners/adapters) · app/main.py 的上游 User-Agent 默认值 → xiaoyin-gateway/{VERSION} · data/gateway.yaml 里 opencode 的 UA 覆盖 → xiaoyin-gateway/2.4.0 · run.py 启动横幅 → [xiaoyin-gateway] 脚本 · scripts/sync_models.py、sync_onemin.py 的探测 UA · scripts/ci_check.sh 的横幅 前端 · 配置备份文件的 kind: api-gateway-backup → xiaoyin-gateway-backup (导入逻辑本来就不校验 kind,旧备份照样能恢复) · dist 产物同步打补丁,不用重新 build 文档 · README / CHANGELOG 里的服务名、`supervisorctl restart api-gateway:api-gateway_00` 等 · 另一个技能 dsh-plugin-publish 的敏感词规则里也提到了旧名,一并更新 唯一没动的 · .gitignore 里那行指向 /root/.trash/2026-09-13-api-gateway-cleanup 的注释 —— 那是磁盘上真实存在的历史目录名,改了反而指错地方 --- CHANGELOG.md | 40 ++++++++++++++-------------- README.md | 18 ++++++------- app/adapters/openai_compat.py | 2 +- app/adapters/qwenpaw_engine.py | 2 +- app/agents_routes.py | 2 +- app/circuit.py | 2 +- app/gomodels.py | 4 +-- app/main.py | 4 +-- app/metrics.py | 2 +- app/sessions.py | 2 +- app/settings.py | 2 +- app/users.py | 2 +- app/video_owners.py | 2 +- data/gateway.yaml | 2 +- frontend/src/views/GatewayConfig.vue | 2 +- run.py | 2 +- scripts/ci_check.sh | 2 +- scripts/sync_models.py | 2 +- scripts/sync_onemin.py | 2 +- 19 files changed, 48 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcc9b3b..6c915e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -535,7 +535,7 @@ token 正常(输入 41 / 输出 12 / 推理 12);成员视角只看到自 老板:「旧托管的都删了,代码,文档相关的都去掉」。 -- **远端**:三个项目(`api-gateway` / `QwenPawChat` / `QwenPawChatWeChat`)都删掉 `origin` +- **远端**:三个项目(`xiaoyin-gateway` / `QwenPawChat` / `QwenPawChatWeChat`)都删掉 `origin` (旧托管的仓库地址)—— 现在只留 `gitea` 一个远端。 - **脚本**:旧的推送脚本移除(归档到 `/root/.trash/<归档>/`, 含 `MANIFEST.md`;内容仍可从 git 历史取回);`scripts/push_gitea.sh` 的注释里也去掉了旧托管表述。 @@ -547,7 +547,7 @@ token 正常(输入 41 / 输出 12 / 推理 12);成员视角只看到自 老板:「统一成 main,都默认 main 分支」。 -- **api-gateway**:本地分支 `master` → `main`(`git branch -m master main`);Gitea 侧推上 `main` +- **xiaoyin-gateway**:本地分支 `master` → `main`(`git branch -m master main`);Gitea 侧推上 `main` 后把仓库默认分支改成 `main`、删掉旧的 `master` 分支。 - **QwenPawChat / QwenPawChatWeChat**:本来就是 `main`,无需改(三个项目至此一致)。 - **本机 git** 设 `init.defaultBranch = main` —— 以后**新建**仓库默认就是 `main`。 @@ -578,7 +578,7 @@ token 正常(输入 41 / 输出 12 / 推理 12);成员视角只看到自 - **`README.md`**「版本号与发布纪律 → 发布流程」一节:推送目标改为 `推 Gitea`。 - **背景**:旧托管的凭据已实测失效(推送与 `ls-remote` 都回 `Repository Not Found.`);同期老板起了自建 Gitea (容器 `1Panel-gitea-CjQz`,`commitgo/gitea-ee:27.3.8`,公网 `https://git.wangjinding.com`), - 三个项目(`api-gateway` / `QwenPawChat` / `QwenPawChatWeChat`)都已建 **private** 仓库并推了**全量历史**。 + 三个项目(`xiaoyin-gateway` / `QwenPawChat` / `QwenPawChatWeChat`)都已建 **private** 仓库并推了**全量历史**。 - **remote 布局**:三个项目只留 `gitea` 一个远端(旧的 `origin` 已删除)。 - **待办**:若要免密自动推送,可在 Gitea 建 API token(需老板同意;本次没擅自建)。 @@ -691,7 +691,7 @@ token 正常(输入 41 / 输出 12 / 推理 12);成员视角只看到自 (切到 `agnes/agnes-3.0-flash` 报 401「无效的令牌」)。走网关的 `wangjinding` 正常 (网关侧 Agnes Key 是好的)。要用 Agnes 直连需先修 Key。 -**上线**:`supervisorctl restart api-gateway:api-gateway_00` + `npm run build`; +**上线**:`supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00` + `npm run build`; 线上 `version=2.6.0`、入口 `index-BQYagb1Q.js`、Agents chunk `Agents-CN_agann.js`; 真机验证:下拉 112 项 / 7 组 → 选 `wjd` → UI 显示 `wjd` → 磁盘 `agent.json` `{"provider_id":"wangjinding","model":"wjd"}` → 引擎回读一致 → 列表页同步。 @@ -1054,7 +1054,7 @@ Prometheus:api_gateway_tokens_cached_total 1920 / api_gateway_tokens_reasoning - `scripts/sync_models.py`:新增 `fetch_models_dev()`、`fetch_agnes_context()`(逐模型页解析「限制与价格」表),`diff()` 产出 `ctx_drift`,`apply_plan` 走 `_set_context`(块内改值、保留行尾注释、幂等),`verify()` 回读校验,报告显示漂移;`_DRIFT_KEYS` 与 `plan_is_empty` 认 `ctx_set`。 - 测试 **201 passed / 0 failed**(新增 3 个),`ci_check.sh` 全绿。 -**上线**:`supervisorctl restart api-gateway:api-gateway_00`(pid 3492804)→ 实测 `/v1/models` 45 个模型、**38 个带 `context_window`**(含 `wjd` 别名继承 = 1,000,000 / 384,000),图片/视频模型正确为 0;health 200。代码已推远端(`08a4aee`,远端 = 本地)。 +**上线**:`supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00`(pid 3492804)→ 实测 `/v1/models` 45 个模型、**38 个带 `context_window`**(含 `wjd` 别名继承 = 1,000,000 / 384,000),图片/视频模型正确为 0;health 200。代码已推远端(`08a4aee`,远端 = 本地)。 ## 2026-09-24 · 修「QwenPaw 缓存命中率恒 0」:流式 usage 丢掉 `prompt_tokens_details` @@ -1108,7 +1108,7 @@ Prometheus:api_gateway_tokens_cached_total 1920 / api_gateway_tokens_reasoning `ecb99e6 → afd2f69 → 16d973c`,**远端 `master` tip = 本地 HEAD**,`.git/config` 无 token。 ### ③ 立「上生产必须同步推远端」规则(老板硬性要求) -- `README.md` 新增段落:凡**重启上线生产**(`supervisorctl restart api-gateway:api-gateway_00`)或 **`npm run build` 覆盖 `frontend/dist`** 的代码改动,验证通过后**必须**推远端;顺序=改代码 → 测试/CI → 上线 → 确证线上生效 → commit → push;纯注释/配置靠热重载生效的也照推。唯一原则:**线上跑着的代码 = 仓库里的代码**。 +- `README.md` 新增段落:凡**重启上线生产**(`supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00`)或 **`npm run build` 覆盖 `frontend/dist`** 的代码改动,验证通过后**必须**推远端;顺序=改代码 → 测试/CI → 上线 → 确证线上生效 → commit → push;纯注释/配置靠热重载生效的也照推。唯一原则:**线上跑着的代码 = 仓库里的代码**。 - 新增推送脚本:一次性带凭据内嵌 URL 推送,推完自动核对「远端 = 本地」并复查 `.git/config` 无凭据;无凭据退出 2、工作区不干净退出 3;**脚本内不内置凭据**(凭据只在 `MEMORY.md`)。 ## 2026-09-24 · Agnes 免费 / 限时免费标注 + 免费标签间距对齐 @@ -1133,7 +1133,7 @@ Prometheus:api_gateway_tokens_cached_total 1920 / api_gateway_tokens_reasoning ### 上线 - 配置:`--apply` 落盘(备份 `data/gateway.yaml.bak`,权限 600,回读校验通过),`hot_reload` 自动生效。 -- 后端:`supervisorctl restart api-gateway:api-gateway_00`(pid 3465113,health 200)。 +- 后端:`supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00`(pid 3465113,health 200)。 - 前端:`npm run build` 覆盖 `frontend/dist`,线上 `/web` 已换 `index-CkVhRx-u.js` / `Models-RN5bN2Hd.js`(旧 chunk 404),入口包里能查到「限时免费」。 - 实测 `/v1/models` 载荷:Agnes 6 个免费 + `agnes-video-2.5-flash` 限时免费 + 3 个付费档无标注;`space-bunny-free` 免费标注不受影响。 @@ -1234,7 +1234,7 @@ dict 即使一个模型都没变也是**真值** → 每天无漂移也重写一 - **README**:供应商表模型数 17 → 35、模型清单小节按「线 + 免费」重写、三线直传小节数字同步。 ### 踩坑记录(下次别再犯) -- 探测上游必须带**专属 UA**(`api-gateway/2.4.0 (jakon opencode-go)`):用 python urllib 的默认 UA +- 探测上游必须带**专属 UA**(`xiaoyin-gateway/2.4.0 (jakon opencode-go)`):用 python urllib 的默认 UA 会被 Cloudflare 拦成 `403 error code: 1010`,看起来像"模型不可用",其实是 UA 被 ban。 ### 验证 @@ -1383,7 +1383,7 @@ dict 即使一个模型都没变也是**真值** → 每天无漂移也重写一 是对的。 ### 上线与验证 -- 后端 `supervisorctl restart api-gateway:api-gateway_00`;前端 `npm run build` 覆盖 +- 后端 `supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00`;前端 `npm run build` 覆盖 `frontend/dist`(网关 `StaticFiles` 直接挂载)→ 线上入口 **`index-Bf3pWvHR.js`**。 - 生产验证:`/healthz` 200、登录页 + 中英切换(真浏览器)、`/health/agnes` 无凭据 401、 `GET /` 导航无 `docs`、env 值校验 400 且文件未变、水印图下载 200、未登记 video_id 轮询 @@ -1408,7 +1408,7 @@ dict 即使一个模型都没变也是**真值** → 每天无漂移也重写一 - 单测 173 passed / 0 failed(`test_conversation_id_isolated_per_account`、 `test_api_conversation_id_flows_to_session_header`、`test_non_ascii_...` 已更新为「不传→非 None 稳定会话」新语义) -- 生产已重启(`api-gateway:api-gateway_00`,pid 1488509),`/healthz` ok、无回归 +- 生产已重启(`xiaoyin-gateway:xiaoyin-gateway_00`,pid 1488509),`/healthz` ok、无回归 - **真实的 `cached_tokens>0` 演示暂被挡**:opencode 免费 5 小时额度仍锁定(上游 429),待额度 重置(约 3h)后可再实测两通相同前缀调用确认命中。 @@ -1447,13 +1447,13 @@ dict 即使一个模型都没变也是**真值** → 每天无漂移也重写一 ### 验证 - 后端单测:**165 passed / 0 failed**(删 6 个路由引擎用例、改写 10 个、新增 2 个)。 - 前端:`vue-tsc --noEmit` 0 错、`npm run build` 成功、`check-i18n` 中英 699/699 对称。 -- 生产**未动**:后端需 `supervisorctl restart api-gateway:api-gateway_00`(踢会话), +- 生产**未动**:后端需 `supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00`(踢会话), 前端 dist 覆盖需老板点头。 ### 上线(老板批准重启,2026-09-18 15:16) - 前端 `npm run build` 产物覆盖 `frontend/dist`(新入口 `index-CWUVm0px.js`,公网 `https://api.wangjinding.com/web/...` 已服务新入口、旧入口 404)。 -- 后端 `supervisorctl restart api-gateway:api-gateway_00` → 新 pid,127.0.0.1:8808 正常, +- 后端 `supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00` → 新 pid,127.0.0.1:8808 正常, `/health` 200、启动日志「已加载 3 供应商」。 - **代码仍未提交 git**(老板明确要求"先别提交")。 @@ -1485,7 +1485,7 @@ dict 即使一个模型都没变也是**真值** → 每天无漂移也重写一 (chat/completions 7106ms、responses 2014ms、messages 1360ms)。 -按轮次记录 api-gateway 的修复与优化(README 侧重能力/配置说明,这里侧重每轮的改动、排查、验证与上线)。 +按轮次记录 xiaoyin-gateway 的修复与优化(README 侧重能力/配置说明,这里侧重每轮的改动、排查、验证与上线)。 --- @@ -1540,7 +1540,7 @@ dict 即使一个模型都没变也是**真值** → 每天无漂移也重写一 - 两个账号(admin / liunuanshu)用**同一个** `conversation_id` 各调 `kimi-k3` → **都 200**(派生后的值被上游正常接受); - 缓存归属实验(直连上游、真实 key,prompt≈940 token):见上文**结论更正**的三组数据。 - 文档:README 补「取值限制 / 派生规则 / OpenAI SDK 用 extra_body」+ 缓存结论更正;本 CHANGELOG 记一轮。 -- **上线状态**:含 Python 代码改动 → 需 `supervisorctl restart api-gateway:api-gateway_00` 才生效(会踢网页会话), +- **上线状态**:含 Python 代码改动 → 需 `supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00` 才生效(会踢网页会话), **待老板批准**;本轮无前端改动,不需要 `npm run build`。 --- @@ -1610,7 +1610,7 @@ dict 即使一个模型都没变也是**真值** → 每天无漂移也重写一 - **单测**:**168 passed / 0 failed**(+10:参数解析/白名单拦截/真配置锁定/强制覆盖/自动修正重发/不无限重试/配置冲突/流式修正/测速文案/面板保留 params);前端 `vue-tsc --noEmit` 通过、`check:i18n` 726/726 对称、`check:svg` 通过、`npm run build` 成功(在副本内构建,未覆盖生产 dist)。 ### 上线(待老板批准) -- 含 Python 代码改动(`config` / `adapters` / `main` / `settings`)→ 需 `supervisorctl restart api-gateway:api-gateway_00` 才生效(会踢网页会话)。 +- 含 Python 代码改动(`config` / `adapters` / `main` / `settings`)→ 需 `supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00` 才生效(会踢网页会话)。 - 前端需 `npm run build` 覆盖 `frontend/dist`(挂锁/提示条才会出现在线上)。 - 远端推送新增提交。 @@ -1647,7 +1647,7 @@ dict 即使一个模型都没变也是**真值** → 每天无漂移也重写一 ### 改动 - **`data/.env`**:新增 `OPENCODE_API_KEY`(600、gitignored)。 - **`data/gateway.yaml`**: - - 新增 `providers.opencode`:`base_url https://opencode.ai/zen/go/v1`、`token_env OPENCODE_API_KEY`、`requires_session_header: true`、`extra_headers.User-Agent: api-gateway/2.4.0 (jakon opencode-go)`,收录 **17 个**文本模型(`glm-5.3-flash/5.3/5.2/5.1`、`kimi-k3/k2.7-code/k2.6`、`longcat-2.0`、`deepseek-v4-pro/v4-flash/flash/v4.1-flash/v4-flash-vision-exp(视觉)`、`mimo-v2.5/v2.5-pro`、`hy4-preview/hy3`)。 + - 新增 `providers.opencode`:`base_url https://opencode.ai/zen/go/v1`、`token_env OPENCODE_API_KEY`、`requires_session_header: true`、`extra_headers.User-Agent: xiaoyin-gateway/2.4.0 (jakon opencode-go)`,收录 **17 个**文本模型(`glm-5.3-flash/5.3/5.2/5.1`、`kimi-k3/k2.7-code/k2.6`、`longcat-2.0`、`deepseek-v4-pro/v4-flash/flash/v4.1-flash/v4-flash-vision-exp(视觉)`、`mimo-v2.5/v2.5-pro`、`hy4-preview/hy3`)。 - `routes.wjd` 追加这 17 个(wjd 链 = 20 个文本模型)。 - 未收录:`glm-5`、`kimi-k2.5`、`hy3-preview`(上游实测 400 Model is unavailable);`/messages`、`/responses` 线模型未接入(适配器不含该契约)。 - **`app/config.py`**:`ProviderConfig` 加 `requires_session_header` 字段并解析。 @@ -1667,7 +1667,7 @@ dict 即使一个模型都没变也是**真值** → 每天无漂移也重写一 - 单测:**155 passed / 0 failed**;前端 `vue-tsc --noEmit` 通过。 ### 上线(待老板批准) -- 含 Python 代码改动(config / adapters / settings)→ 需 `supervisorctl restart api-gateway:api-gateway_00` 才生效(会踢网页会话);纯 yaml 的 hot_reload 只重载供应商/模型定义,`requires_session_header` 字段与注入逻辑要重启后代码才认。 +- 含 Python 代码改动(config / adapters / settings)→ 需 `supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00` 才生效(会踢网页会话);纯 yaml 的 hot_reload 只重载供应商/模型定义,`requires_session_header` 字段与注入逻辑要重启后代码才认。 - 前端 build 覆盖 `dist`(纯前端上线动作)与远端推送待老板确认。 **一句话**:老板拍板——**现有 + 以后新增的每一个文本模型都必须加入 `routes.wjd` 兜底链**。本次把 `agnes-2.5-flash` 补进 wjd,并把这句作为长期规则写入 MEMORY / README / CHANGELOG,供后续新增模型照做。 @@ -1729,7 +1729,7 @@ dict 即使一个模型都没变也是**真值** → 每天无漂移也重写一 - 单测 **155 passed / 0 failed**;全项目 grep `智谱|bigmodel|GLM|cogview|cogvideox|ufileos|ZHIPU|zhipu|video_style|_ZHIPU` 除 CHANGELOG 历史外**全部清零**。 - 前端 `npm run build` 过(typecheck + i18n 对称),新入口 `index-BynIw5Ue.js`。 - 配置校验:providers `[agnes,volc_engine]`、模型 `agnes[3] + volc[1]`、`routes.wjd` 2 项、下载白名单仅 Agnes。 -- `supervisorctl restart api-gateway:api-gateway_00` 上线(`description`/适配器/校验等属代码改动,需重启)。 +- `supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00` 上线(`description`/适配器/校验等属代码改动,需重启)。 --- @@ -1780,7 +1780,7 @@ dict 即使一个模型都没变也是**真值** → 每天无漂移也重写一 ### 验证 - 单测:新增/修正 bigmodel 媒体契约断言、视频轮询必经 `?model=`(现两家视频供应商)、配置往返含新 media 键 → **155 passed / 0 failed**;前端 `npm run build` 过(typecheck + i18n 对称),新入口 `index-CxdHy_Sw.js`。 - 真机隔离(uvicorn:8899 临时 users/history,连真实智谱):`/v1/models` 列出 8 个智谱模型;图像 → 200 `data[].url`;视频创建 → `video_id`+`task_status:PROCESSING`;轮询 → `status:processing`;非法参数(`mode=keyframe`)→ 400 干净拒绝。 -- 上线:`supervisorctl restart api-gateway:api-gateway_00`(代码改动需重启),前端 dist 已 build 覆盖。 +- 上线:`supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00`(代码改动需重启),前端 dist 已 build 覆盖。 - **补「下载白名单」**:上线后老板实测智谱图/视频下载报「不在白名单:maas-watermark-prod-new.cn-wlcb.ufileos.com」。已确认智谱图+视频产物**同一 CDN 域名**(实测视频 `SUCCESS` 结果 url 同域),在 `download.allowed_hosts` 补 `maas-watermark-prod-new.cn-wlcb.ufileos.com`(精确项 + 子域匹配,不泛放整个 `ufileos.com`;`evilufileos.com`、后缀撞车域名仍拒绝)。纯配置改动,`hot_reload` ≤15s 自动生效免重启。已用隔离服务器实测:智谱图经 `/v1/media/download` 拉回 200 + 有效 JPEG 97KB。 --- @@ -1863,7 +1863,7 @@ dict 即使一个模型都没变也是**真值** → 每天无漂移也重写一 - `test_feedback_withdraw_only_when_pending`:feedback 撤回逻辑,非本次改动范围。 ### 部署 -- `supervisorctl restart api-gateway:api-gateway_00`。 +- `supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00`。 - 重启前验证文件已就位:yaml `safe_load` 通过、`providers = [agnes, b_ai, volc_engine, opencode]`、opencode 4 个模型。 - 上线后校验:新 pid 61457、healthz `{"status":"ok"}`、`/v1/models` 200 且含 opencode 4 个免费模型、无凭证/错 key 仍 401、真实 chat 调用 `provider=opencode` 返回 200。 diff --git a/README.md b/README.md index fdeb72c..eb84346 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ ## 架构 ``` -api-gateway/ +xiaoyin-gateway/ ├── data/gateway.yaml # 默认运行时配置(run.py 读取,hot_reload 开) ├── app/ │ ├── config.py # YAML 加载 → dataclass(供应商/模型/协议线/鉴权/熔断/可观测/定价) @@ -886,7 +886,7 @@ curl "http://localhost:8808/v1/videos/?model=agnes-video-2.5-flash&wai > 改为 `repeat(2, minmax(0, 1fr))`(手机端原来的两列覆盖也随之删掉,规则收敛到 `style.css` 一处), > 每格 141px(可用 127px):中英标签全部单行、三格等高(zh 49px / en 46px)、右边界距卡片 15px。 > 实测 1280/1440/1024 桌面 + 390 手机 × 中英 7 组全部 `折行=no`、横向溢出 0。 -> - 上线与复核(2026-09-13 17:13 老板批准重启):`supervisorctl restart api-gateway:api-gateway_00`; +> - 上线与复核(2026-09-13 17:13 老板批准重启):`supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00`; > 线上 `/healthz` 200、非对象 JSON 400、错误密码 401、无凭证 401;线上 CSS 内含 `.meter{height:5px}`、 > `.set-row>.lb{...flex:0 0 auto}`、手机端 `min-height:34px`,旧的 `.bar{height:5px` 已消失; > 专项探针 24 组合(B/A/C 主题 × 1280/390 × 6 页)横向溢出全 0,输入区 34/86px、张数输入 51px、 @@ -1075,7 +1075,7 @@ curl "http://localhost:8808/v1/videos/?model=agnes-video-2.5-flash&wai > - 未实测项(如实记):**390px 手机断点没测到** —— 本会话浏览器没有视口控制(试过 Ctrl+缩放压低 CSS 视口无效),故用 `flex-wrap` 兜住「5 颗图标超宽」的最坏情况,建议真机上瞄一眼。 > > - **上线(2026-09-13 20:0x,老板批准)**:`npm run build` → 线上现役 `index-BYW9huII.js` / `index-BCEpjaoj.css` / `Users-Ym7Y7v4h.js`(旧 `index-BV89HnWe.js` 已 404); -> `supervisorctl restart api-gateway:api-gateway_00`(旧 pid 2102891 → 新 pid 2157737,仍监听 `127.0.0.1:8808`)。 +> `supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00`(旧 pid 2102891 → 新 pid 2157737,仍监听 `127.0.0.1:8808`)。 > **本轮有后端改动,重启会清空内存态网页会话 —— 所有人(含 admin)需要重新登录。** > 复核:公网 `/healthz` 200、`/web/` 200 且引用新 hash、新 asset 200(`immutable` 长缓存)与旧 asset 404、 > CSP 未放宽、`index.html` 仍 `no-cache`;新端点在线判据 = 无凭证调 `PUT /auth/users/x/disabled` 得 **401**(旧代码是 404)。 @@ -1120,7 +1120,7 @@ curl "http://localhost:8808/v1/videos/?model=agnes-video-2.5-flash&wai > 「跳到」滚动生效(目标卡片 y 4221 → 62)、会话时长改成 45 保存 → 盘上文件立刻更新且生成 `.bak`(权限 600)、 > 页面出「已保存并生效」。 > - 上线:`npm run build` → 线上现役 `index-T9rUvEqS.js` / `GatewayConfig-Cujt5GjO.js` -> (旧 `index-BMd-U-9_.js` 已 404);`supervisorctl restart api-gateway:api-gateway_00` → +> (旧 `index-BMd-U-9_.js` 已 404);`supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00` → > 新 pid **2102891**(`127.0.0.1:8808`)—— **本轮有后端改动,重启踢掉所有网页会话,需重新登录**。 > 随后小修一处文案(`{'{'}"status":"ok"{'}'}` 里花括号写法之间多打了空格,渲染成 `{ "status":"ok" }`, > 与 /health 真实报文不符)→ 再 `npm run build` → 现役 **`index-CladK7BT.js` / @@ -1241,7 +1241,7 @@ curl "http://localhost:8808/v1/videos/?model=agnes-video-2.5-flash&wai > 处理中·已处理 400 / API Key 撤不动 403)。撤回部分在隔离实例复核过接口与真浏览器交互。 > - 上线(2026-09-13 18:4x,老板批准「补上说明后直接上线」):`npm run build` → 线上现役 > `index-b0LZHsJm.js` / `index-BCEpjaoj.css`(旧 `index-CDcUA_16.js` 已 404); -> `supervisorctl restart api-gateway:api-gateway_00` → pid **2055315**(127.0.0.1:8808)—— +> `supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00` → pid **2055315**(127.0.0.1:8808)—— > **本轮有后端改动,重启会踢掉所有网页会话,需重新登录**。(该次 pid 已被下方追加项的上线覆盖。) > 追加项(老板 18:39「待处理的单子用户可以自己撤回」)代码与隔离实测完成后,老板 18:5x 批准上线: > 再次 `npm run build` + `supervisorctl restart` → 现役 `index-9Whl_Fn4.js`(旧 `index-b0LZHsJm.js` 已 404)、 @@ -1259,7 +1259,7 @@ curl "http://localhost:8808/v1/videos/?model=agnes-video-2.5-flash&wai > 追加项(老板「处理的每个环节都要记录和展示,改好后直接重启上线」)**已上线**: > `npm run build`(先确认 `frontend/public/` 无探针残留)→ 现役 `index-BTllhoyi.js` > (旧 `index-9Whl_Fn4.js` 已 404;`index-BCEpjaoj.css` 哈希未变,本轮无样式改动); -> `supervisorctl restart api-gateway:api-gateway_00` → pid **2073622**(`127.0.0.1:8808`)—— +> `supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00` → pid **2073622**(`127.0.0.1:8808`)—— > **有后端改动,重启踢掉了所有网页会话,需重新登录**。 > 复核(全部实测):公网 `/web/` 200 且引用新 hash、`index-BTllhoyi.js` 与 > `FeedbackTimeline-CfkAgUmj.js` / `Feedback-DsePxU4t.js` / `FeedbackInbox-D1R_k-8C.js` 全 200、 @@ -1354,7 +1354,7 @@ curl "http://localhost:8808/v1/videos/?model=agnes-video-2.5-flash&wai > 窄屏 151~175px,无横向溢出);`vue-tsc` 0 错、`vite build` 通过、后端单测 **137 passed / 0 failed**。 > - 上线(2026-09-13 17:44,老板批准):`npm run build` → 线上现役 > `index-Yy0kGuVA.js` / `index-DKyqf84q.css` / `Logs-N__ABTKT.js` / `Videos-Bzh1nuOL.js` + `Videos-BVOcHXwL.css`; -> `supervisorctl restart api-gateway:api-gateway_00` → pid **1999293**(127.0.0.1:8808)。 +> `supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00` → pid **1999293**(127.0.0.1:8808)。 > 复核:公网 `/web/` 200 且引用新 hash、新旧 asset 分别 200 / 404、`/healthz` 200、CSP 头未放宽; > 拉线上产物实测含胶囊计数与空结果提示(`Logs`)、新版卡片结构(`Videos`)与窄屏缩略拉伸规则(`Videos` CSS)。 > 注意:**重启会踢掉所有网页会话,需重新登录**。 @@ -1385,7 +1385,7 @@ VERSION = "2.4.0" # ← 只改这一处 ``` 改代码 → 跑测试(python tests/test_gateway.py 或 bash scripts/ci_check.sh) → 纯前端:npm run build(dist 即线上目录) - 后端/代码:supervisorctl restart api-gateway:api-gateway_00 + 后端/代码:supervisorctl restart xiaoyin-gateway:xiaoyin-gateway_00 → 真机验证(线上 healthz / 页面 / 接口) → git commit → 推 Gitea(scripts/push_gitea.sh,仓库 Jidekin/xiaoyin-gateway 分支 main) @@ -1400,7 +1400,7 @@ restart)或 `npm run build` 覆盖 `frontend/dist` 的代码改动,验证通 退出码 2=没凭据 / 3=工作区不干净 / 4=推送后远端≠本地 / 5=`.git/config` 出现明文。 仓库 `https://git.wangjinding.com/Jidekin/xiaoyin-gateway.git`、分支 `main` (`remote` 名就叫 `gitea`)。**三个项目分支已统一为 `main`** -(2026-10-12:api-gateway 原 `master` 改名 `main`,Gitea 默认分支同步改、旧 `master` 分支删除)。 +(2026-10-12:xiaoyin-gateway 原 `master` 改名 `main`,Gitea 默认分支同步改、旧 `master` 分支删除)。 ## 测试 diff --git a/app/adapters/openai_compat.py b/app/adapters/openai_compat.py index 415d823..b2aada6 100644 --- a/app/adapters/openai_compat.py +++ b/app/adapters/openai_compat.py @@ -28,7 +28,7 @@ from app.config import ( ) from app.models import CHAT_CORE_KEYS, PROTECTED_VIDEO_KEYS, strip_protected -log = logging.getLogger("api-gateway") +log = logging.getLogger("xiaoyin-gateway") # ── 上游"某参数只允许取某个值"的报错形态(第二十五轮)── # 各家措辞不同,这里收录已实测到的两类: diff --git a/app/adapters/qwenpaw_engine.py b/app/adapters/qwenpaw_engine.py index d441e82..12ab4f9 100644 --- a/app/adapters/qwenpaw_engine.py +++ b/app/adapters/qwenpaw_engine.py @@ -36,7 +36,7 @@ from typing import Any, AsyncIterator import httpx -log = logging.getLogger("api-gateway.agents") +log = logging.getLogger("xiaoyin-gateway.agents") #: 单轮对话的超时(秒)。引擎可能跑很久(多步工具),给足。 DEFAULT_TIMEOUT = 300.0 diff --git a/app/agents_routes.py b/app/agents_routes.py index a35959c..02b2fde 100644 --- a/app/agents_routes.py +++ b/app/agents_routes.py @@ -37,7 +37,7 @@ from app.adapters.qwenpaw_engine import ( stream_chat, ) -log = logging.getLogger("api-gateway.agents") +log = logging.getLogger("xiaoyin-gateway.agents") QWENPAW_CONFIG = Path("~/.qwenpaw/config.json") diff --git a/app/circuit.py b/app/circuit.py index bebe6f3..cb27ff6 100644 --- a/app/circuit.py +++ b/app/circuit.py @@ -13,7 +13,7 @@ import threading import time from collections import deque -log = logging.getLogger("api-gateway.circuit") +log = logging.getLogger("xiaoyin-gateway.circuit") class CircuitBreaker: diff --git a/app/gomodels.py b/app/gomodels.py index ad3a047..73dc938 100644 --- a/app/gomodels.py +++ b/app/gomodels.py @@ -33,7 +33,7 @@ import time import urllib.request _URL = "https://opencode.ai/inference/go/v1/models" -log = logging.getLogger("api-gateway.gomodels") +log = logging.getLogger("xiaoyin-gateway.gomodels") _TTL = 6 * 3600 _RETRY_AFTER_FAIL = 300 _TIMEOUT = 6 @@ -46,7 +46,7 @@ _at = 0.0 def _fetch() -> dict[str, dict]: req = urllib.request.Request( _URL, - headers={"Accept": "application/json", "User-Agent": "api-gateway/gomodels"}, + headers={"Accept": "application/json", "User-Agent": "xiaoyin-gateway/gomodels"}, ) with urllib.request.urlopen(req, timeout=_TIMEOUT) as resp: # noqa: S310 payload = json.loads(resp.read().decode("utf-8", "replace")) diff --git a/app/main.py b/app/main.py index 76e1965..22ab3c9 100644 --- a/app/main.py +++ b/app/main.py @@ -162,7 +162,7 @@ def _setup_logging() -> None: # 基础日志先起来,进 lifespan 后按 observability 重配 logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(name)s] %(levelname)s: %(message)s") -log = logging.getLogger("api-gateway") +log = logging.getLogger("xiaoyin-gateway") # 调用日志的内容上限(2026-10-23,2.9.12 再放宽):默认 **4 MiB**(≈100 万 token 的文本)。 # 老板要求「详情内容都不要截断」—— 4 MiB 对任何正常对话都等于不截断; @@ -4704,7 +4704,7 @@ async def opencode_go_usage(_auth=Depends(require_auth)): raise HTTPException(503, "OpenCode Go 未配置 API Key") base = str(pconfig.base_url or "https://opencode.ai/zen/go/v1").rstrip("/") - ua = (pconfig.extra_headers or {}).get("User-Agent") or f"api-gateway/{VERSION}" + ua = (pconfig.extra_headers or {}).get("User-Agent") or f"xiaoyin-gateway/{VERSION}" try: async with httpx.AsyncClient(timeout=10) as client: r = await client.get( diff --git a/app/metrics.py b/app/metrics.py index 87a8ac2..b29e7eb 100644 --- a/app/metrics.py +++ b/app/metrics.py @@ -13,7 +13,7 @@ from collections import deque from contextvars import ContextVar from typing import Any -log = logging.getLogger("api-gateway.metrics") +log = logging.getLogger("xiaoyin-gateway.metrics") # 请求级「归属账号」上下文(ContextVar,每 task/请求独立;由 main.py require_auth 写入)。 # 访问日志与指标通过它给每条记录打上账号,实现: diff --git a/app/sessions.py b/app/sessions.py index 7e566d3..3d06102 100644 --- a/app/sessions.py +++ b/app/sessions.py @@ -31,7 +31,7 @@ import threading import time from pathlib import Path -log = logging.getLogger("api-gateway.sessions") +log = logging.getLogger("xiaoyin-gateway.sessions") # 落盘文件名固定为 sessions.json;结构带 version,便于以后改格式时兼容读取。 _FILE_VERSION = 1 diff --git a/app/settings.py b/app/settings.py index f52fd9d..2a907b6 100644 --- a/app/settings.py +++ b/app/settings.py @@ -41,7 +41,7 @@ from app.config import ( validate_warnings, ) -log = logging.getLogger("api-gateway.settings") +log = logging.getLogger("xiaoyin-gateway.settings") # ── 改了必须重启进程才生效的键(其余都是"每请求读配置",保存即生效) ── # host / port:uvicorn 在进程启动时绑定,改文件不会重绑。 diff --git a/app/users.py b/app/users.py index d442f2c..be357a3 100644 --- a/app/users.py +++ b/app/users.py @@ -28,7 +28,7 @@ import secrets import threading import time -log = logging.getLogger("api-gateway.users") +log = logging.getLogger("xiaoyin-gateway.users") USERNAME_RE = re.compile(r"^[A-Za-z0-9]+$") ITERATIONS = 200_000 diff --git a/app/video_owners.py b/app/video_owners.py index e62d7c1..27f6a5f 100644 --- a/app/video_owners.py +++ b/app/video_owners.py @@ -30,7 +30,7 @@ import threading import time from pathlib import Path -log = logging.getLogger("api-gateway.video_owners") +log = logging.getLogger("xiaoyin-gateway.video_owners") _FILE_VERSION = 1 diff --git a/data/gateway.yaml b/data/gateway.yaml index a028e39..1f37c01 100644 --- a/data/gateway.yaml +++ b/data/gateway.yaml @@ -279,7 +279,7 @@ providers: # 每次请求动态注入会话头(不能放静态 extra_headers——会被 _get_adapter 缓存冻结)。 requires_session_header: true extra_headers: - User-Agent: "api-gateway/2.4.0 (jakon opencode-go)" + User-Agent: "xiaoyin-gateway/2.4.0 (jakon opencode-go)" # 无媒体能力(纯文本编程模型;图像/视频不走本供应商) media: {} # ── 协议线(第二十七轮「三线直传」)────────────────────────── diff --git a/frontend/src/views/GatewayConfig.vue b/frontend/src/views/GatewayConfig.vue index e63daf8..1c36ee0 100644 --- a/frontend/src/views/GatewayConfig.vue +++ b/frontend/src/views/GatewayConfig.vue @@ -152,7 +152,7 @@ async function saveYaml() { function backupCfg() { const envs: Record = {} for (const e of envKeys.value) envs[e.env] = e.value - const data = { kind: 'api-gateway-backup', version: 1, config: yamlText.value, envs } + const data = { kind: 'xiaoyin-gateway-backup', version: 1, config: yamlText.value, envs } const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' }) const a = document.createElement('a') a.href = URL.createObjectURL(blob) diff --git a/run.py b/run.py index 73f6e3a..b02e871 100644 --- a/run.py +++ b/run.py @@ -20,7 +20,7 @@ if __name__ == "__main__": import uvicorn gs = int(os.environ.get("GATEWAY_GRACEFUL_SHUTDOWN", config.server.graceful_shutdown)) - print(f"[api-gateway] config={CONFIG_PATH} host={host} port={port} graceful_shutdown={gs}s") + print(f"[xiaoyin-gateway] config={CONFIG_PATH} host={host} port={port} graceful_shutdown={gs}s") # 直接传入 app 对象(而非 import string),避免 uvicorn 二次导入 app.main 而再算一次配置。 uvicorn.run( app, diff --git a/scripts/ci_check.sh b/scripts/ci_check.sh index 9e385c6..7b0b4be 100755 --- a/scripts/ci_check.sh +++ b/scripts/ci_check.sh @@ -34,7 +34,7 @@ run() { # run <说明> <命令...> fi } -echo "api-gateway CI 门禁($(date '+%F %T'))" +echo "xiaoyin-gateway CI 门禁($(date '+%F %T'))" # 1) 后端语法编译(覆盖整个 app 包 + run.py;不再维护手写文件清单) run "后端语法编译" "$PY" -m compileall -q app run.py diff --git a/scripts/sync_models.py b/scripts/sync_models.py index f2126e6..35a487b 100755 --- a/scripts/sync_models.py +++ b/scripts/sync_models.py @@ -46,7 +46,7 @@ import yaml ROOT = Path(__file__).resolve().parent.parent DEFAULT_CFG = ROOT / "data" / "gateway.yaml" -UA = "api-gateway-model-sync/1.0 (+ops; contact admin)" +UA = "xiaoyin-gateway-model-sync/1.0 (+ops; contact admin)" OC_DOC_URL = "https://opencode.ai/v2/docs/console/go/" AGNES_PRICING_URL = "https://www.agnes-ai.cn/zh-Hans/docs/pricing.md" diff --git a/scripts/sync_onemin.py b/scripts/sync_onemin.py index 07bd933..faa195c 100755 --- a/scripts/sync_onemin.py +++ b/scripts/sync_onemin.py @@ -43,7 +43,7 @@ DEFAULT_ENV = ROOT / "data" / ".env" PROVIDER = "onemin" BASE_URL = "https://api.1min.ai/openai/v1" -UA = "api-gateway-onemin-sync/1.0 (+ops; contact admin)" +UA = "xiaoyin-gateway-onemin-sync/1.0 (+ops; contact admin)" # ── 工具 ────────────────────────────────────────────────────────────