Commit Graph
5 Commits
Author SHA1 Message Date
admin 26a0f2f4f4 feat(apix): usage_hint 字段 —— /api/v1/me 帮用户 AI 自动发现调用语法 (1.0.22)
`desc` 是中文给运维看的,`params` 只对 vendor 有意义(passthrough 是空数组)。
`/api/v1/me` 把条目下发给用户 AI 后,AI 必须能自己拼出:
- 路径尾部是什么(/ocr /ocr/base64 /ocr/url)
- 每个端点的 Content-Type(multipart 还是 json)
- 上游字段名 / Swagger 在哪

加 `usage_hint` 字段:管理员按 OpenAPI 风格填写自由格式,由 /api/v1/me
原样透传给用户 AI。AI 直接解析,无需再读人工文档。

设计要点:
- 不进 shm(热路径只查 base/key/asset_id/mode,进 shm 占带宽)
- 截断到 1KB(够写 3-5 个端点说明,长 Swagger 截断而非拒绝)
- 默认空字符串,向后兼容旧数据
- passthrough 推荐填,vendor 可选填

改动:
- models.rs: ApiProxy 加 usage_hint 字段
- apix.rs: upsert 收 usage_hint_raw + 截断;view 回显
- api.rs: save 解析 usage_hint;响应回显
- www/apix.html: 描述加 usage_hint 解释
- www/assets/apix.js: 表单加 textarea + 提交带 usage_hint
- tests/llm/e2e.sh: §11.5 加 1 条 usage_hint 写入与回显断言
- 回归 227/0 全绿(修复断言 1 条)
2026-09-15 11:30:16 +08:00
admin d05ebfb5b0 fix(apix): passthrough 新建可空 Key —— upsert 按 mode 放宽校验 (1.0.21)
1.0.20 现场踩坑:upsert 统一要求「基址与密钥」,但 passthrough 设计是
Key 可空(内部服务免鉴权,handler 已经放空 Key 转发),管理台提交 passthrough
+ 空 Key 直接 400。

修:vendor 必须 base + key 都填;passthrough 仅 base 必填,key 可空。

补 2 条测试断言防回归(vendor 缺 Key → 400;passthrough 空 Key → 200)。
回归 227/0 全绿。
2026-09-15 11:12:07 +08:00
admin 4533db8536 feat(apix): 透传模式 passthrough —— 通用内部 REST 出口 (1.0.20)
- 模型加 mode 字段(vendor 默认 / passthrough 新增),shm payload 扩为 4 字段
  base\nkey\nasset_id\nmode;旧数据零迁移(无 mode → vendor)
- 拆 location 而非按 mode 分支:/apixp/ 不施加 vendor 强约束
  (proxy_method POST + 强制 Content-Type + proxy_pass_request_headers off
  是 location 级指令,无法按请求级 shm 的 mode 动态切换)
- handler 校验路径前缀 vs mode 一致(vendor slug 走 /apixp/ → 404,反之亦然),
  避免 vendor 条目继承 passthrough 强制 Content-Type 致 415 之类静默故障
- passthrough:方法/请求体/Content-Type 原样透传(含 multipart),上游路径
  = base + /apixp/<slug> 之后的 URI 尾部(含 query 由模块拼,变量式 proxy_pass
  不自动追加);Key 可空(内部服务免鉴权,下发时 nginx 空串 = 不发该头)
- 探测按 mode 分流:vendor 走 POST 预估 / passthrough 走 GET 打上游根地址
- nginx:lm server 加 /apixp/,mdm server 加 /_apixp_probe/(internal)
- 测试 §11.6 新增 35 条断言(鉴权/路径转发/体透传/Key 下发/路径-mode 一致
  /管理台回显/探测);账号态 count 1→3 同步;回归 225/0 全绿
- 管理台:列表加 mode 标签、表单加 mode 下拉 + 透传说明 + 路径示例复制
- 文档:docs/apix/PASSTHROUGH_MODE.md 真源(决策/兼容/改动一览)

OCR 是第一条 passthrough 配置:/apixp/ocr/ocr、/apixp/ocr/ocr/base64、
/apixp/ocr/ocr/url?src=...
2026-09-15 10:51:29 +08:00
admin 479024c61e feat(api): /api/v1/me 聚合能力目录 (upstreams + apix) (1.0.16)
- plugin-apix: 新增 apix::enabled(),仅列 enabled=true 的代理
- ipass-core: CoreExt::decorate_me 签名加 &User 和 &port,让装饰零额外
  shm 查询就能做权限收敛(upstreams 按 allowed_models 过滤)
- gateway::GatewayExt: decorate_me 多塞 upstreams(白名单过滤)和 apix
  (仅 enabled)两个字段;port 从请求 Host 头取(适配 88 / 443 反代)

老 3 个端点 /api/v1/{upstreams,apix,domains} 保留不破坏。同事拿 key 一个
me 拿全能力目录,不再需要分别调三个端点。

回归 281 全绿(网关 102 + LLM 179)
2026-09-14 17:14:00 +08:00
admin 85ea0a1531 refactor(plugin): P4 拆 plugin-apix —— API 代理迁入独立插件,过渡期路由清空
- plugin-apix 新 crate:apix/handlers/api/config/models/store
- ApiProxy/ApiProxyStore、api-proxies.json 读写、ax: 键空间与 APIX_* 常量自内核迁入
- ApiProxyHandler 与 $apix_* 六变量注册归 ApixPlugin;用量记账仍走 plugin_llm::stats(同一片键空间、单一写入口)
- gateway 路由表只剩 trend 组合端点(需 users+upstreams+apix 三方名册)
- 行为等价:262 项回归全绿(gateway 102 + llm 160)
2026-09-13 12:16:47 +08:00