Commit Graph
7562 Commits
Author SHA1 Message Date
alfadb a6f83e9d04 fix(billing): keep gpt-oss names out of the OpenAI pricing fallback chain
复现:动态目录含 gpt-5.4 时,gpt-oss:120b/20b 经 matchOpenAIModel 末端
catch-all 落到 DefaultTestModel(gpt-5.4) 价卡($2.5/$15 per MTok,实测
日志 "OpenAI fallback to default model gpt-oss:120b -> gpt-5.4"),绕过
fallbackPrices 的 ollama 价卡($0.15/$0.60 与 $0.07/$0.30),输入价
静默多收约 17~36 倍。

修复:GetModelPricing 第 5 步排除 gpt-oss 前缀进 OpenAI 回退链(返回 nil
交还 BillingService 走 fallbackPrices 的 ollama 价卡);不动任何其它匹配
规则与价格数值。gpt-oss-120b-medium(Antigravity 白名单同名族,仓库无其
定价条目)由误计 gpt-5.4 价转为 fail-closed,与无目录时行为一致。

回归护栏:ollama_cloud_dynamic_catalog_pricing_test.go 表驱动钉死 8 个
ollama 独占模型在目录已加载形态下的实际解析价,并钉住真实 OpenAI 名
(gpt-5.4 目录精确命中 / gpt-4o catch-all / gpt-5.5 静态兜底)不受影响。
2026-10-08 15:24:05 +08:00
alfadb c42b758372 feat(billing): price ollama cloud models and resolve tagged model names
B2-②: add fallbackPrices entries for the 8 ollama-exclusive cloud models
(gpt-oss:120b/20b, gemma4:31b, mistral-large-3:675b, qwen3.5:397b,
nemotron-3-super/nano:30b/ultra) with official per-token rates, plus
exact/prefix family rules in getFallbackPricing. gpt-oss tiers and the
three nemotron tiers are matched precisely (no bare gpt-oss/nemotron
prefix); models without a published cached-input tier bill cached input
at the input rate instead of 0.

B2-①: two-level pricing lookup for ":tag" model names. Shared helper
normalizePricingModelNameForLookup yields the stripped candidate; wired
into getModelPricingAt (full chain rerun, pricingAt preserved),
matchGroupModelPricing (exact retry) and lookupChannelPricingNormalized
(third retry after the codex normalization; applyChannelOverrides
inherits it). Literal name always wins, so bedrock canonical keys like
us.anthropic.claude-sonnet-4-5-20250929-v1:0 are never destructively
stripped; normalizeChannelPricingModelName stays untouched.

Tests: full /v1/models listing pinned with hit paths, tag-strip and
fail-closed behavior, bedrock double-key regression at base/channel/
group layers.
2026-10-08 15:24:05 +08:00
alfadb 361e584bcf feat(ollama): make responses and max_tokens hooks platform-aware
- C31: include ollama_cloud in SupportsNativeCNResponses so /v1/responses
  ingress routes to the platform-native endpoint instead of degrading to
  raw CC, and the stateless normalize hook (store=false + strip
  previous_response_id) now applies to ollama accounts
- D2/C37': reject the stateful conversation field with an explicit 400
  invalid_request_error on native Responses accounts instead of silently
  dropping context; normalizeDeepSeekResponsesRequestBody now returns
  ([]byte, error) with all three production call sites propagating the
  typed error as a client-visible 400
- D1': clamp max_tokens for non-DeepSeek models too on ollama.com
  upstreams (raw CC, native Responses, Anthropic Messages); the host
  check is the boundary, the >65535 upstream 400 is model-independent;
  delete the now-dead isOllamaCloudRawChatCompletionsAccount predicate
- C39: mark ollama_cloud accounts force_responses in the Responses
  probe (per-protocol, no network probe) and let the admin handler
  schedule the probe for ollama_cloud accounts
2026-10-08 15:24:05 +08:00
alfadb 61441ba44d feat(ui): render ollama_cloud usage cell
E17: account for ollama_cloud explicitly in both usage-cell computeds.
Empirically the cell already renders via the generic api-key root branch
(eligible -> OllamaCloudUsageCell + today-stats, ineligible -> '-'
placeholder), because eligibility itself is server-driven
(ollama_cloud_usage.eligible, fixed backend-side in the previous
commit); so the computeds pin that behavior instead of flipping to the
scrolling-window root branch, which would drop today-stats rows and
fire /usage calls the backend rejects for api-key accounts.

- showUsageWindows: explicit ollama_cloud api-key branch -> false
  (generic api-key branch renders the Ollama cell)
- shouldFetchUsage: document why ollama_cloud stays unfetched (backend
  /usage rejects api-key accounts; data arrives via account payload and
  the dedicated refresh endpoint, same shape as CN platforms)
- tests: eligible renders OllamaCloudUsageCell without /usage fetch;
  missing/eligible=false renders placeholder, never CN quota cells
2026-10-08 15:24:04 +08:00
alfadb 551797e24f feat(ollama): platform-ize ollama_cloud usage service
- D1(u): usage platform whitelist now admits platform=ollama_cloud via
  authoritative OllamaCloudUsagePlatforms (ollama_cloud + legacy host
  platforms); host gate (official ollama.com) untouched
- D3(u): repository SQL platform whitelist derived from the service list
  (const -> var via ollamaCloudPlatformsSQLLiteral) instead of a hand
  mirrored literal - drift now structurally impossible
- D4(u)+F3: TestOllamaCloudUsagePlatformsMirror locks the derivation
  (parse count, ElementsMatch, eligible SQL contains every platform);
  existing predicate test covers ollama_cloud and dynamically sized list
- D2(u): ErrOllamaCloudUsageAccountInvalid message derived from the
  whitelist (code unchanged - external contract)
- D6(u): doc comment on IsOllamaCloudUsageAccount (three conditions,
  reverse-proxy eligible=false is expected)
- D8(u): decision record on ollamaCloudUsageSettingsURL (hardcoded
  official settings page, not configurable - host gate / SSRF surface)
- D9(u): OllamaCloudUsageState.EligibleReason distinguishes
  platform_not_eligible / wrong_account_type / unsupported_base_url
- F5: service usage tests cover ollama_cloud platform (official host
  pass, reverse-proxy fail, oauth reject) and reason codes
2026-10-08 15:24:04 +08:00
alfadb b868e94c15 feat(platform): align ollama_cloud platform lists for composite routing and pricing
- C11: matchingPlatforms composite branch includes ollama_cloud so channel
  pricing/mapping cache lookups stay consistent with isConcreteRequestPlatform
- C20: openAICompatibleTextTargetAllowed allows ollama_cloud resolved targets
- C21: compositeAvailableModels aggregates ollama_cloud account mapping keys
  (claude default-list fallback already gated off by IsMultiProtocolAPIKeyProvider)
- test sync: composite matchingPlatforms expectation, bulk account event
  rebuild coverage for the ollama_cloud bucket, ollama_cloud text-target case
2026-10-08 15:24:04 +08:00
alfadb 3b0e4f792c feat(platform): admit ollama_cloud to scheduling pool and composite routes 2026-10-08 15:24:04 +08:00
alfadb 0d22f90e04 feat(platform): wire ollama_cloud into scheduling and routing
增量 2(⑥ 组 + ⑨ 组,严格同批):

⑥ adaptive 准入 / 协议路由 / base 守卫:
- A9/A13: IsOllamaCloud 谓词 + Account.IsOllamaCloud();
  IsMultiProtocolAPIKeyProvider 纳入 ollama_cloud(adaptive 总开关)
- A11: GetAPIProtocol 缺省档扩为 opencode_go || ollama_cloud → adaptive
- A7/A10 + C30/Q2-3: DefaultOllamaCloudBaseURL(https://ollama.com/v1) /
  DefaultOllamaCloudAnthropicBaseURL(https://ollama.com),并补
  GetOpenAIBaseURL 与 defaultCNProtocolBaseURL 的平台分支
- C33/Q2-4 + S6 层 1: GetOpenAIBaseURL 平台守卫纳入 ollama_cloud;
  多协议账号缺省端点不再回落 https://api.openai.com
- C32: shouldForwardOpenAIResponsesViaRawChatCompletions 新增 ollama_cloud
  分支(不复用 opencode 的恒 false)
- S5: nativeAnthropicTargetURL 改用版本感知 buildOpenAIEndpointURL,
  删除 opencode_go 特判(消灭 /v1/v1/messages)
- S6 层 2: CC / Responses / passthrough 三处 OpenAI 官方域名兜底
  对多协议账号改为显式报错(防凭据外泄)

⑨ count_tokens(必须与 C40 同批):
- findings B1: openai_gateway_count_tokens.go 本地估算分支加入
  IsOllamaCloud()(命中时不产生任何出站请求)
- C40: routes/gateway.go 的 responses 兼容白名单与 count_tokens
  分派白名单加入 service.PlatformOllamaCloud

新增单测 ollama_cloud_platform_routing_test.go:
默认协议/base、nativeAnthropicTargetURL 带与不带 /v1 双向、C32 分流、
count_tokens 本地估算零出站。
2026-10-08 15:24:04 +08:00
alfadb 3182f6d1cc fix(ollama): clamp DeepSeek max_output_tokens on all native Responses paths 2026-10-08 15:24:04 +08:00
alfadb fb8408029d fix(ollama): apply DeepSeek reasoning/max_tokens adapter on CC bridge paths 2026-10-08 15:24:04 +08:00
alfadb 0ec37bd26b fix(ollama): normalize DeepSeek reasoning by upstream endpoint, not platform 2026-10-08 15:24:04 +08:00
alfadb 110958f77a feat(platform): add ollama_cloud platform skeleton
- 新增 PlatformOllamaCloud 常量与 AllowedQuotaPlatforms 白名单
- 同步 ent schema 平台校验(user_platform_quota / channel_monitor /
  channel_monitor_request_template)及生成物
- 新增迁移 239:4 类 CHECK 放宽至 238 的超集(含 ollama_cloud),零 DML 回填
- 新增迁移测试断言 239 为 238 严格超集
- 前端:平台目录、类型联合、配色、图标、i18n 文案
2026-10-08 15:24:04 +08:00
alfadb 7ff8fd3458 feat(composite): serve cross-family pools via per-account protocol dispatch
解除 composite 候选池的协议族限制:入站任意协议族端点可服务池内任意
平台账号,厂商多协议时优先与入站相同的协议族(零转换),否则协议转换。

- routes:混族/全原生族池不再 400,落 generic 网关按选中账号分发;
  全 OpenAI 族池仍走 OpenAI handler(不变)
- generic 调度器放行池:跨平台候选合并选号、池感知平台/模型门、
  sticky 复检防塌缩(镜像 OpenAI 族池调度)
- generic 转发 base 协议化:多协议账号打 GetAnthropicProtocolBaseURL
  的 {base}/v1/messages(无 ?beta=true、认证/clamp 同源),classic
  anthropic 不回归
- generic Messages/Responses/ChatCompletions 循环池化:per-attempt
  配额与渠道策略(复用 OpenAI 池策略)、attempt ctx + platform 作用域
  渠道映射;纯 OpenAI 族账号按端点委派 OpenAI 网关同族链,usage 适配
  进既有计费流;count_tokens 不可计数账号排除重选
- 谓词能力驱动(IsAnthropicProtocol/adaptive/GetAnthropicProtocolBaseURL),
  不引入平台硬编码清单,后续多协议平台合入后零改动继承
2026-10-08 15:24:04 +08:00
alfadb 16612cd6a7 test(composite): align empty-mapping deepseek fixtures with official model whitelist
组合 fix/deepseek-model-name-validation 后,DeepSeek 空 mapping 账号的
IsModelSupported 改按官方白名单判定,deepseek-chat 已不在白名单。composite
规则B(空 mapping native claim)语义不变,测试夹具从已退役的 deepseek-chat
换成白名单名 deepseek-flash / deepseek-v4-pro。
2026-10-08 15:24:04 +08:00
alfadb 006ed5af25 fix(composite): handle unavailable sticky accounts without panic 2026-10-08 15:24:04 +08:00
alfadb d1f65572c1 feat(composite): balance compatible providers with sticky sessions
composite 路由改为按兼容平台候选池跨平台调度:调度状态归属候选池并支持 previous_response_id sticky 绑定,per-attempt 策略按渠道限制、平台/渠道配额与 RPM 准入筛选,出站记录仅记实际选中的 upstream。
2026-10-08 15:24:04 +08:00
Wesley Liddick 5fc0e486c3 Merge pull request #7916 from wucm667/fix/issue-7914-monitor-request-sample
fix(channel-monitor): require request samples before health scoring
2026-10-08 13:52:34 +08:00
Wesley Liddick 3e69643392 Merge pull request #7721 from ouchihao/codex/bug-fractional-byte-rate
fix(ops): retain byte units for sub-byte throughput
2026-10-08 13:51:52 +08:00
Wesley Liddick 3a012ac0ce Merge pull request #7725 from ouchihao/codex/bug-select-disabled-open
fix(ui): close selectors when they become disabled
2026-10-08 13:51:40 +08:00
Wesley Liddick 80dd7288a6 Merge pull request #7728 from ouchihao/codex/bug-oauth-code-unmount
fix(auth): avoid starting OAuth code cooldowns after unmount
2026-10-08 13:51:30 +08:00
Wesley Liddick 5a6e826f83 Merge pull request #7716 from ouchihao/codex/bug-scaled-price-exponent
fix(pricing): preserve exponents when trimming scaled prices
2026-10-08 13:51:19 +08:00
Wesley Liddick d068b866f3 Merge pull request #7718 from ouchihao/codex/bug-bulk-user-error-message
fix(users): show normalized errors when bulk updating limits
2026-10-08 13:51:05 +08:00
Wesley Liddick a618338987 Merge pull request #7719 from ouchihao/codex/bug-notify-email-timers
fix(profile): ignore obsolete notification email code responses
2026-10-08 13:50:54 +08:00
Wesley Liddick b0c2c4d623 Merge pull request #7720 from ouchihao/codex/bug-usage-zero-rate
fix(usage): preserve zero user multipliers in cost details
2026-10-08 13:50:39 +08:00
Wesley Liddick 9663b5ccf0 Merge pull request #7722 from ouchihao/codex/bug-announcement-read-failure
fix(announcements): report failed read confirmations accurately
2026-10-08 13:50:19 +08:00
Wesley Liddick 6cfa0f4ef8 Merge pull request #7723 from ouchihao/codex/bug-batch-image-access-retry
fix(batch-image): allow access lookup retries after request failures
2026-10-08 13:50:08 +08:00
Wesley Liddick 3149d62851 Merge pull request #7724 from ouchihao/codex/bug-cleanup-task-race
fix(usage): ignore obsolete cleanup task list responses
2026-10-08 13:49:58 +08:00
Wesley Liddick 0b51cbe15d Merge pull request #7729 from ouchihao/codex/bug-backup-polling-unmount
fix(backup): prevent polling from restarting after navigation
2026-10-08 13:49:48 +08:00
Wesley Liddick 3dc2a9c371 Merge pull request #7731 from ouchihao/codex/bug-dialog-escape-stack
fix(ui): limit Escape to the most recently opened dialog
2026-10-08 13:49:34 +08:00
Wesley Liddick 2c13fb595e Merge pull request #7764 from ouchihao/codex/bug-plugin-config-session-race
fix(plugins): ignore obsolete configuration UI sessions
2026-10-08 13:49:23 +08:00
Wesley Liddick 068239305e Merge pull request #7765 from ouchihao/codex/bug-compliance-reset-race
fix(auth): keep cleared compliance state isolated from pending requests
2026-10-08 13:49:13 +08:00
Wesley Liddick 9e46f2d77e Merge pull request #7732 from ouchihao/codex/bug-step-up-concurrent-prompts
fix(auth): share pending step-up verification prompts
2026-10-08 13:48:52 +08:00
Wesley Liddick 2eb7ccb6d2 Merge pull request #7703 from wucm667/fix/issue-7700-thinking-signature
fix(openai): recover rejected encrypted reasoning signatures
2026-10-08 13:48:33 +08:00
Wesley Liddick 745ff1d3ca Merge pull request #7911 from lyy0709/codex/usage-output-tps
feat(usage): add output TPS to usage logs and ops dashboard
2026-10-08 11:40:15 +08:00
Wesley Liddick 8e2c4fad32 Merge pull request #7793 from wucm667/fix/issue-7784-composite-route-model-list
fix(models): list composite exact route aliases
2026-10-08 11:39:51 +08:00
Wesley Liddick 0ac774e378 Merge pull request #7853 from wucm667/feat/issue-7847-compact-account-filters
feat(accounts): compact account search and filters
2026-10-08 11:39:40 +08:00
Wesley Liddick ba3af61251 Merge pull request #7897 from wucm667/fix/issue-7894-long-context-marker
fix(usage): replace misleading long-context multiplier badge
2026-10-08 11:37:40 +08:00
Wesley Liddick 48c647b5d2 Merge pull request #7833 from ShanYi-Hui/fix/preserve-email-binding-draft
fix(profile): preserve email binding draft during user refresh
2026-10-08 11:37:25 +08:00
Wesley Liddick b94974467b Merge pull request #7818 from ouchihao/codex/bug-custom-page-request-race
fix(custom-pages): ignore obsolete Markdown responses
2026-10-08 11:37:11 +08:00
Wesley Liddick 4747827e35 Merge pull request #7819 from ouchihao/codex/bug-stripe-payment-unmount
fix(payment): stop late Stripe callbacks after leaving the page
2026-10-08 11:36:59 +08:00
Wesley Liddick f3bcad3c33 Merge pull request #7839 from ouchihao/codex/bug-scheduled-results-race
fix(admin): keep scheduled test results scoped to the expanded plan
2026-10-08 11:36:33 +08:00
Wesley Liddick 2c6bd63de9 Merge pull request #7840 from ouchihao/codex/bug-monitor-template-list-race
fix(monitor): ignore obsolete template manager list responses
2026-10-08 11:36:19 +08:00
Wesley Liddick 02aad478f3 Merge pull request #7841 from ouchihao/codex/bug-alert-events-pagination-race
fix(ops): discard stale alert event pages after filter changes
2026-10-08 11:36:07 +08:00
Wesley Liddick 486b226b69 Merge pull request #7842 from ouchihao/codex/bug-ops-settings-load-guard
fix(ops): require loaded settings before saving
2026-10-08 11:35:56 +08:00
Wesley Liddick d1202bea5f Merge pull request #7843 from ouchihao/codex/bug-alert-rule-integer-duration
fix(ops): validate alert rule durations as whole minutes
2026-10-08 11:35:42 +08:00
Wesley Liddick 1865f28469 Merge pull request #7900 from ouchihao/codex/bug-rpm-edit-number
fix(groups): preserve numeric values when editing RPM overrides
2026-10-08 11:35:27 +08:00
Wesley Liddick c2f0edc137 Merge pull request #7901 from ouchihao/codex/bug-airwallex-navigation
fix(payment): stop Airwallex checkout after leaving the page
2026-10-08 11:35:15 +08:00
Wesley Liddick cdbf1d6f4d Merge pull request #7902 from ouchihao/codex/bug-passthrough-toggle-state
fix(admin): use the saved passthrough rule enabled state
2026-10-08 11:35:01 +08:00
Wesley Liddick b126b94525 Merge pull request #7903 from ouchihao/codex/bug-profile-username-draft
fix(profile): preserve username edits made during save
2026-10-08 11:34:49 +08:00
Wesley Liddick 7fc5332b45 Merge pull request #7904 from ouchihao/codex/bug-group-rate-load-race
fix(groups): ignore stale rate multiplier loads
2026-10-08 11:34:38 +08:00