Commit Graph
6912 Commits
Author SHA1 Message Date
alfadb 3f64d811bd chore(ollama): close the remaining increment-5 items
- DetectModelPlatform: document why ollama_cloud intentionally has no branch
  (model-name-only input, resold families collide with existing prefixes such as
  gpt- -> openai; adding one would silently misroute) and pin current behaviour
  with table-driven tests
- match models.dev provider by host for ollama.com using the measured registry id
  "ollama-cloud"
- include ollama_cloud (and opencode_go) in the codex model catalog platform list
- let reverse-proxy ollama_cloud accounts pick the anthropic auth scheme via extra
  (official host still forces Bearer)
- use the adaptive chat-protocol base url in the upstream billing probe
- add ollama_cloud to the remaining admin UI badges and spec expectations
2026-09-13 10:39:49 +08:00
alfadb b7e6a54c3e feat(models): give ollama cloud a default model list
C15/E18/E19: add the authoritative ollama_cloud default model catalog
(DefaultOllamaCloudModelIDs, /v1/models measured 2026-09-12, 20 entries
incl. the two tagged snapshots) and wire it into every default-model path:

- service: defaultModelsListCandidateIDs ollama case + composite candidates
- handler: defaultModelIDsForPlatform ollama case + composite array, and
  the /v1/models end-of-chain guard now falls back to the catalog instead
  of an empty list (Claude leak guard kept)
- frontend: getModelsByPlatform 'ollama_cloud' case mirrors the same
  static table (cross-referencing comments both sides, pinning tests on
  both sides), and upstreamSyncPlatforms opens real upstream sync

E20/E28 verified already done in 656accae0 (ChannelsView arrays +
ChannelMonitorView.grok.spec provider count 11).
2026-09-13 10:39:49 +08:00
alfadb 7f80e4365b feat(usage): expose ollama cloud quota mode and monthly credit
D7+E3+E26:把 ollama_cloud 双额度模式(legacy 滚动窗口 / credits 月度
信用池)在用量展示上打通。

- 后端 OllamaCloudUsageState 新增 mode(复用 GetOllamaCloudAccountMode
  解析 credentials.account_mode,非 ollama_cloud 平台留空)与
  monthly_credit_usd(*float64,读 credentials.monthly_credit_usd,
  缺失/非法/非正数时为 nil,不报错不填假值)
- dto mapper 对 platform=ollama_cloud 一律下发 state:不合格账号也要把
  eligible_reason 送到前端用量格;legacy 宿主平台维持仅 eligible 下发
- 前端类型补 eligible_reason / mode / monthly_credit_usd 声明
- 用量格按 mode 分支:legacy 渲染 5h/7d 窗口 + 追加余额文本;credits
  隐藏窗口条、渲染月池进度((pool-balance)/pool clamp,前端派生)+
  余额/分母文本 + 快照时间;池缺失时只显示原始余额文本
- 不合格账号展示 eligible_reason 可解释提示(不再空白占位)
- AccountUsageCell 对 ollama_cloud 本体平台按 state 存在与否挂载 cell

派生展示百分比按规格放前端(D7 二选一);未动建号表单、渠道监控、
ratelimit_service 与迁移。
2026-09-13 10:39:49 +08:00
alfadb 741c9f617d feat(account): support ollama_cloud protocol and quota mode in the create form 2026-09-13 10:39:49 +08:00
alfadb f8f6355280 feat(monitor): support ollama_cloud in the channel monitor UI
Frontend half of increment 5-2 (mirrors backend 39b8649df):

- Add ollama_cloud to the Provider union, channelMonitor constants
  (PROVIDER_OLLAMA_CLOUD, PROVIDERS, DEFAULT_OLLAMA_CLOUD_ENDPOINT =
  https://ollama.com; the probe adapter appends /v1/chat/completions,
  same source as the backend DefaultOllamaCloudBaseURL), the monitor
  form provider grid / endpoint preset, the filter bar, and the
  template manager tabs. ollama_cloud supports all three check modes
  and chat_completions only, so no antigravity-style restriction and
  no default-model preset (backend only defaults grok's model).
- Extend providerLabel/badge/picker/gradient (stone palette, aligned
  with utils/platformColors.ts), the user MonitorCard icon tint, and
  the ProviderIcon exhaustive map with the official llama mark.
- i18n: monitorCommon.providers.ollama_cloud and
  admin.groups.platforms.ollama_cloud in en+zh.
- ChannelsView: add ollama_cloud to platformOrder and
  compositePlatforms (backend isConcreteRequestPlatform already
  includes it); no per-platform extra config needed - matching
  opencode_go, which also carries none in the channel form.
- Update the stale ChannelMonitorView.grok.spec.ts provider count
  8 -> 11 (the grid already had 10 before this change and the spec
  was failing on the clean baseline).
2026-09-13 10:39:49 +08:00
alfadb f5deed85e5 feat(monitor): support ollama_cloud in channel monitors and account diagnostics
Increment 5-2a of the ollama_cloud plan (backend half):

- M-1: accept provider=ollama_cloud for channel monitors (create/update
  binding oneof) and request templates (create binding oneof, historical
  short list intentionally not extended to the CN platforms); add the
  service-side monitorProviders/probeCapableProviders entries, an OpenAI-
  compatible chat adapter and merge-mode denylist entry; replace-mode body
  validation intentionally stays lenient (opencode_go precedent).
- C36: route ollama_cloud accounts in TestAccountConnection to protocol-
  aware probes (adaptive = CC + Anthropic + native Responses; pinned
  protocols = single endpoint) instead of the Claude tester that appended
  ?beta=true; default the empty model to the account's first outbound
  model; share the native Responses probe with opencode_go; resolve the
  platform-default Anthropic base for pinned-anthropic accounts.
- C29: quota-mode monitors read the OllamaCloudUsageService snapshot from
  account extra (no live fetch) and map windows/balance/plan to
  MonitorQuotaSnapshot; ineligible accounts (e.g. reverse-proxy base_url)
  and missing/failed snapshots yield explainable errors with the snapshot
  fetched_at instead of the generic usage-query error.
- C28: verified no change needed - monitorAccountQuotaCapability already
  allows ollama_cloud via its default branch.
- Pin the composite default-model candidate list: ollama_cloud explicitly
  contributes no static default list (admin_group.go), aligning with
  gateway_handler.
2026-09-13 10:39:49 +08:00
alfadb 83ad970700 test(contract): refresh settings goldens and fix ollama conversation null handling
- api_contract_test: default_platform_quotas goldens now include ollama_cloud
  (actual settings response is correct; goldens were stale)
- api_contract_test: stubAccountRepo.GetByIDs returns the bulk-update fixture
  accounts (101/102) required by the BulkUpdateAccounts prefetch
- openai_gateway: conversation gate rejects only non-null values
  (gjson Type != Null); conversation: null is treated as an omitted field and
  forwarded, with a Forward-layer regression test covering both paths
- ollama_cloud pricing gate: message now states the global base pricing
  requirement and that channel/group-only pricing is not accepted; doc comment
  records the deliberate stricter-than-runtime design limitation
2026-09-13 10:38:56 +08:00
alfadb 426649a5cd fix(ollama): stop swallowing protocol marker persist errors
探针的协议 marker 后台落标(国产供应商 / ollama_cloud 分支)此前用
_ = UpdateExtra(...) 把错误完全吞掉:协议更新可以「成功」而旧的
force_responses / auto marker 静默残留,且与函数注释「所有错误都会记录
日志」直接矛盾。现改为结构化 slog 告警(openai_responses_probe_marker_
persist_failed,含 account_id / account_name / platform / responses_mode /
err),两个落标分支(force_responses 与重置 auto)都覆盖。

为什么只做可观测性、不引入原子保存/改路由权威(第 2 层评估结论):
实读路由决策后确认,ollama_cloud 的请求路由以 credentials.api_protocol
为权威,探针 marker 不是权威输入——
- shouldForwardOpenAIResponsesViaRawChatCompletions 的 IsOllamaCloud()
  分支只读 GetAPIProtocol(),在 ShouldUseResponsesAPI(Extra) 之前返回;
- 调度能力过滤只在请求平台归一为 openai 时才要求 responses 能力
  (ollama_cloud 归一化后保持原值),marker 不会被用于排除 ollama 账号;
- CC→Responses 的 404/405 兜底分支要求 marker 解析为 unknown,残留值
  解析为 yes/no,不会触发误兜底。
因此残留 marker 对 ollama_cloud 生产路由不构成错投,原子保存的额外复杂度
不值得引入;新增测试锁住「落标失败必须产生可观测信号」(对旧代码该测试
失败:无任何日志输出)。
2026-09-13 10:38:56 +08:00
alfadb f1afabb6a9 fix(ollama): validate the ollama cloud pricing gate on all account write paths
评审确认三条 admin 写路径绕过保存期无价门禁
(validateOllamaCloudAccountModelPricingGate),本修复把同一门禁与同一触发
收窄判定复用到这三条路径,不另写判定规则:

- BulkUpdateAccounts:对每个受影响的 ollama_cloud 账号,按仓库 BulkUpdate
  的实际生效方式(credentials/extra JSONB 顶层 key 合并、status/schedulable
  列覆盖)先算出「变更后的账号」再校验;任一账号不合规即整批拒绝、不落库,
  错误信息点名账号 ID/名称与未定价模型名,便于批量操作定位。
- DuplicateAccount:用「将要创建的账号」(深拷贝后的最终 credentials/extra)
  校验,不合规拒绝;复制产物保持暂停语义不变。
- SetAccountSchedulable:只在启用方向(当前不满足 active+Schedulable → true)
  且账号是 ollama_cloud 时校验,判定复用 ollamaCloudSchedulableBySave;停用
  放行。

定位说明:运行时模型白名单(IsModelSupported)与转发前定价预检已经落地,
即使绕过保存期门禁也不会再产生「成功但不计费」的流量(最坏是账号 deny-all
或对客户端返 400)。因此这是「门禁不可绕过」的一致性与运维反馈修复,不是
计费漏损修复。

非 ollama 平台行为不变:门禁短路 + 触发收窄(维护性更新放行)均有回归测试
覆盖(bulk 改名/停用、kimi 平台的同样操作全部放行)。
2026-09-13 10:38:56 +08:00
alfadb 5801d10b5f fix(admin): mirror the full quota platform list in the frontend
后端对 default_platform_quotas(setting_update.go)与用户平台配额
(user_handler.go PUT)都是整体替换语义,且以 AllowedQuotaPlatforms
(11 平台)为白名单。前端配额平台镜像此前只硬编码 5 平台
(anthropic/openai/gemini/antigravity/grok),导致:

- 保存 Settings 会静默丢弃 kimi/zhipu/deepseek/minimax/opencode_go/
  ollama_cloud 六个平台的默认配额;
- 管理员在用户配额弹窗不做修改直接保存,就会软删该用户经 API 配置的
  ollama_cloud 等平台配额行(缺行等价于不限额 → 限额 fail-open)。

- settings.ts 新增单一常量 QUOTA_PLATFORMS(对齐后端
  AllowedQuotaPlatforms 全部 11 平台),PlatformType/PlatformQuotaPlatform
  由它派生,删除其余 5 平台硬编码副本(users.ts、配额弹窗、
  UserPlatformQuotaCell、SettingsView 两处模板字面量);
- normalizePlatformQuotasMap / sanitizePlatformQuotasMap 保留输入中
  前端未知(后端新加)的平台 key;用户配额弹窗保留响应中的未知平台行,
  避免后端先行加平台时再次静默删数据;
- 测试:用户配额弹窗预置 ollama_cloud 不修改直接保存仍包含该配额;
  Settings 同路径覆盖;kimi/zhipu/deepseek/minimax/opencode_go 不再
  被丢;未知平台 key 保留。
2026-09-13 10:38:56 +08:00
alfadb 9777392dc2 fix(ollama): narrow the gpt-oss pricing exclusion and unblock legacy account updates
三处独立小修(来自 T0 评审):

1. gpt-oss 排除收窄为冒号命名空间(pricing_service.go GetModelPricing)。
   此前的全局前缀排除误伤 Antigravity 默认模型映射目标名 gpt-oss-120b-medium
   (连字符形态):它被拦在 OpenAI 回退链外 → GetModelPricing 返回 unavailable
   → 非 Ollama 路径 fail-open 成 0 元记账。收窄后 ollama 侧(gpt-oss:120b /
   gpt-oss:20b / gpt-oss:120b-cloud)照修不误,Antigravity 恢复既有行为
   (OpenAI catch-all → gpt-5.4 价卡,与 main 一致)。

2. 保存期无价门禁改为只在会改变「可出站模型集合」或影响调度准入时重验
   (AccountService.Update / adminServiceImpl.UpdateAccount):platform、
   model_mapping、allowed_models 集合实际变化,或从不可调度改为可调度时校验;
   name、notes、并发数、状态等维护性更新放行——存量 legacy 账号(无 mapping/
   清单)此前连改 name 都被 MODEL_PRICING_MISSING 拒绝。全对象 PUT 原样带回
   credentials/extra 时集合未变同样放行。Create 与 BulkUpdate/Duplicate/
   SetAccountSchedulable 三条写路径门禁不变。

3. respondOpenAIStatelessFieldError 补 MarkResponseCommitted(照 bcfef18ae 给
   定价预检 400 的先例):conversation 400 的错误消息不在
   openAIForwardErrorAlreadyCommunicated 识别的前缀内,不置位时 handler 会向
   完整 400 JSON body 尾部追加 SSE 终止帧。三入站路径实测:仅 Responses 入站
   可触发该 400(CC/Messages 转换不透传 conversation 字段)。
2026-09-13 10:38:56 +08:00
alfadb ee462c7fa7 fix(ollama): enforce the ollama cloud model whitelist at runtime 2026-09-13 10:38:56 +08:00
alfadb 7d64d73813 fix(billing): reject unpriced ollama cloud requests before upstream I/O
ollama_cloud 的定价门禁此前位于 RecordUsage 成本计算(openai_gateway_usage.go
B2-④ 分支)——那是异步记账阶段:上游已被调用、响应已写给客户端,拒绝只会让
usage 整条不落账,形成「请求成功但不计费」的静默漏损。

本 commit 把门禁前移到上游 I/O 之前(预检是主门,未定价直接 400、上游零调用):
- buildUpstreamRequest(原生 Responses 出站;三条入站路径的转换分支都经过)
- sendCCUpstreamRequest(raw CC 出站;三条入站路径的回退分支都经过)
- buildNativeAnthropicUpstreamRequest(api_protocol=anthropic 独立构造器)

判定与计费同源:复用 RecordUsage → CalculateCostUnified → ModelPricingResolver
同一条解析链(Group → Channel → LiteLLM → Fallback);无价判定取
calculateTokenCost 的失败条件(token 模式下 GetIntervalPricing 无价可取),
按次/图片/视频模式从不因缺价报错故不视为未定价——预检不比计费更严格,
「只有渠道价」的合法流量不会被误拒(含测试)。

400 照抄 conversation 显式拒绝范式:类型化错误 + 服务层写 400
invalid_request_error(写前 MarkResponseCommitted,同 cyber_policy 先例),
handler 检测响应已提交不追加 fallback;错误非 UpstreamFailoverError ⇒
不换号、不写账号处置。

同时撤销异步阶段的 ollama_cloud 显式拒绝,未定价请求回到既有的零成本落账 +
pricing_missing_record_zero_cost 告警路径——该告警是放量观察断言的观测依据,
不能被记账阶段的拒绝吃掉;相应改写 usageRepo.calls==0 的两个用例为
「兜底观测保持可用」的回归。
2026-09-13 10:38:55 +08:00
alfadb 59ea2290e6 feat(scheduling): suspend exhausted legacy ollama cloud accounts
增量 4a(③ 组 A6+C25+E9 + ⑤ 组 A2 + F4,同批落地):

- A2: 新增 AccountModeOllamaLegacy/OllamaCredits 常量与
  Account.GetOllamaCloudAccountMode 解析器(非 ollama_cloud/非 apikey
  返回空串;未设置或值不认识默认 legacy,存量账号保持受阈值保护)
- A6: AllowedSchedulingThresholdPlatforms 纳入 ollama_cloud(4 个消费点
  同步生效:评估器门禁、设置校验、存储解析、设置审计 diff)
- C25: 评估器新增 ollama 分支 + ollamaCloudThresholdCandidates,仅 legacy
  产生 5h/weekly 停调候选(credits 型月度信用池候选恒空);快照缺失/
  status!=ok/无窗口数据不停调;取最晚 reset(与 openai/anthropic 同类)
- E9: 前端 SchedulingThresholdPlatformType union 与
  SCHEDULING_THRESHOLD_PLATFORMS 数组加 ollama_cloud(与后端白名单两侧同步)
- F4: 评估器表驱动用例(legacy 停/credits 不停/默认 legacy/坏快照不停)、
  ApplyAccountSchedulingThreshold 端到端(temp_unschedulable 落库断言)、
  mode 解析器用例、设置校验 ollama_cloud 往返用例

无迁移、无 DTO 变更(account_mode 为自由 JSONB,无 CHECK 约束)。
2026-09-13 10:38:55 +08:00
alfadb d36c935255 feat(billing): gate unpriced ollama cloud models at save and request time
- save-time gate on admin account create/update (and AccountService, which has
  no production consumers but is the spec-mandated location): non-empty
  model_mapping values and empty-mapping allowed_models lists must all resolve
  via GetModelPricing, otherwise 400 MODEL_PRICING_MISSING
- request-time gate: ollama_cloud accounts no longer fall into the global
  zero-cost path when pricing is unavailable; explicit 4xx instead
- operational preflight SQL documented as comments (not a migration)
- include ollama_cloud in the billing model candidate filter (S1) so claude-*
  names can no longer be priced at Anthropic rates for this platform
- keep ollama_cloud out of the LiteLLM platform map on purpose (comment only)
- refresh a stale comment in upstream_billing_probe.go
2026-09-13 10:38:55 +08:00
alfadb 707bcafd82 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-09-13 10:38:55 +08:00
alfadb 04ce8a499c 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-09-13 10:38:55 +08:00
alfadb e701fd2dbc 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-09-13 10:38:55 +08:00
alfadb b16d411aa6 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-09-13 10:38:55 +08:00
alfadb e98f8d20e5 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-09-13 10:38:55 +08:00
alfadb 348f4dc82f 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-09-13 10:38:55 +08:00
alfadb 1777ec4b91 feat(platform): admit ollama_cloud to scheduling pool and composite routes 2026-09-13 10:38:55 +08:00
alfadb ab67f3d444 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-09-13 10:38:55 +08:00
alfadb 27b9e2357e fix(ollama): clamp DeepSeek max_output_tokens on all native Responses paths 2026-09-13 10:38:55 +08:00
alfadb 35d05f3d25 fix(ollama): apply DeepSeek reasoning/max_tokens adapter on CC bridge paths 2026-09-13 10:38:55 +08:00
alfadb 8321c57bd6 fix(ollama): normalize DeepSeek reasoning by upstream endpoint, not platform 2026-09-13 10:38:55 +08:00
alfadb 84c5ae94d4 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-09-13 10:38:55 +08:00
Wesley Liddick bdb42e22f8 Merge pull request #7064 from xlplbo/codex/openai-ws-v2-pool-capacity
fix(openai-ws): 对齐新版 ctx_pool 连接容量计算
2026-09-12 20:13:03 +08:00
Wesley Liddick 9383e0b154 Merge pull request #7057 from Sjeary/codex/issue-7042-max-context-window
fix(codex): 保留本地模型目录的最大上下文窗口
2026-09-12 20:11:40 +08:00
Wesley Liddick c7ed614240 Merge pull request #7001 from SavitarC/feat/ops-token-stats-all-platforms
feat(ops): 扩展 Token 请求统计至所有平台
2026-09-12 19:34:45 +08:00
Wesley Liddick a59f0c7fac Merge pull request #5833 from xuhaihan/fix/openai-fast-missing-tier
fix(openai): force priority when fast tier is omitted
2026-09-12 19:31:21 +08:00
Wesley Liddick 0a378f3432 Merge pull request #7026 from ouchihao/codex/bug-key-quota-reset-state
fix(keys): sync status after resetting quota
2026-09-12 19:30:40 +08:00
Wesley Liddick f2b51e3b24 Merge pull request #7023 from ouchihao/codex/bug-profile-api-errors
fix(profile): show normalized API error messages
2026-09-12 19:30:29 +08:00
Wesley Liddick 329641a86f Merge pull request #7025 from ouchihao/codex/bug-proxy-partial-import-refresh
fix(proxies): refresh the list after partial imports
2026-09-12 19:30:09 +08:00
Wesley Liddick f0dd497780 Merge pull request #7054 from ouchihao/codex/bug-usage-export-filter-snapshot
fix(usage): keep export filters consistent across pages
2026-09-12 19:29:57 +08:00
Wesley Liddick 99b93b2985 Merge pull request #7053 from ouchihao/codex/bug-proxy-filter-pagination
fix(proxies): reset pagination when changing filters
2026-09-12 19:29:41 +08:00
Wesley Liddick 67845665d6 Merge pull request #7050 from ouchihao/codex/bug-balance-email-verification-race
fix(profile): remove verified notification emails by identity
2026-09-12 19:29:24 +08:00
Wesley Liddick 3a070ec1bf Merge pull request #7010 from xpflying/fix/openai-privacy-client-cf-challenge
fix(openai): 隐私/账号检查客户端改用 Firefox 指纹,规避 chatgpt.com Cloudflare 质询
2026-09-12 19:28:09 +08:00
Wesley Liddick 749cd7c354 Merge pull request #7062 from wc4440222/fix/channel-monitor-minimax-provider
fix(channel-monitor): add missing minimax to provider allowlists
2026-09-12 19:27:46 +08:00
Wesley Liddick eaa4083e23 Merge pull request #6995 from alfadb/fix/claude-mid-conversation-output-config
fix(claude): 修复对话中 output_config 的 beta 兼容问题
2026-09-12 19:27:21 +08:00
Wesley Liddick 3873215908 Merge pull request #7049 from xlplbo/perf/openai-ws-pool-queue-wake
perf(openai): WS 连接池排队等待者按账号池变更重选连接
2026-09-12 19:26:56 +08:00
Wesley Liddick 2a4f3d1a71 Merge pull request #7043 from xlplbo/fix/openai-ws-max-conns-factor-default
fix(openai-ws): ctx_pool 每账号连接上限系数默认值改为 5.0
2026-09-12 19:26:26 +08:00
Wesley Liddick 4ff3e6dfb9 Merge pull request #7055 from ouchihao/codex/bug-redeem-profile-refresh
fix(redeem): preserve success when account refresh fails
2026-09-12 19:26:02 +08:00
Wesley Liddick f78c4b241e Merge pull request #7011 from ouchihao/codex/issue-7003-compact-default-model
fix(config): use GPT-5.5 as the default compact model
2026-09-12 19:25:43 +08:00
Wesley Liddick e67ffda7ae Merge pull request #7012 from ouchihao/codex/issue-6982-easypay-upstream-type-dots
fix(payment): allow periods in EasyPay upstream types
2026-09-12 19:24:48 +08:00
Wesley Liddick d2067668d3 Merge pull request #7024 from ouchihao/codex/fix-subscription-assignment-selection
fix(subscriptions): clear assignment user before search debounce
2026-09-12 19:24:00 +08:00
Wesley Liddick ba57ea914b Merge pull request #7052 from ouchihao/codex/issue-2912-transient-auth-failures
fix(auth): preserve sessions during temporary service failures
2026-09-12 19:23:12 +08:00
Wesley Liddick 5948988aae Merge pull request #7022 from ouchihao/codex/issue-3623-accept-encoding-header
fix(gateway): avoid duplicate Accept-Encoding headers
2026-09-12 19:22:44 +08:00
xlplbo 76b3f3c7cf docs(ui): 精简 OpenAI WS 模式提示 2026-09-12 17:38:55 +08:00
xlplbo db15ddf07f docs(ui): 区分 OpenAI WS 开关与连接模式说明 2026-09-12 16:54:22 +08:00