Commit Graph

5236 Commits

Author SHA1 Message Date
Seefs
2c0db08f32 Merge pull request #2815 from wans10/main
fix: 修复模型管理"参与官方同步"与"状态"开关无法保存的问题
v0.10.9-alpha.2
2026-02-08 19:56:16 +08:00
Calcium-Ion
11de49f9b9 Merge pull request #2895 from seefs001/fix/model-manager
fix: 如果模型管理有自定义配置则不合并默认配置
2026-02-08 19:53:49 +08:00
Seefs
4950db666f fix: 如果模型管理有自定义配置则不合并默认配置 2026-02-08 19:42:52 +08:00
CaIon
44c5fac5ea refactor(ratio): replace maps with RWMap for improved concurrency handling v0.10.9-alpha.1 2026-02-08 00:48:21 +08:00
Calcium-Ion
7a146a11f5 Merge pull request #2870 from seefs001/feature/cache-creation-configurable
feat: make 5m cache-creation ratio configurable
2026-02-08 00:28:42 +08:00
Calcium-Ion
897955256e Merge pull request #2889 from seefs001/feature/messages2responses
feat: /v1/messages -> /v1/responses
2026-02-08 00:25:27 +08:00
Calcium-Ion
bc6810ca5a Merge pull request #2887 from seefs001/fix/claude
fix: 补全 streaming message_delta 事件缺失的 input_tokens 和 cache 相关字段
2026-02-08 00:18:04 +08:00
Calcium-Ion
742f4ad1e4 Merge pull request #2883 from seefs001/fix/claude-relay-info-input-token
fix: 使用openai兼容接口调用部分渠道在最终端点为claude原生端点下还是走了openai扣减input_token的逻辑
2026-02-08 00:17:50 +08:00
Calcium-Ion
83a5245bb1 Merge pull request #2875 from seefs001/feature/channel-test-stream
feat: channel test with stream=true
2026-02-08 00:17:07 +08:00
Seefs
2faa873caf Merge branch 'feature/messages2responses' into upstream-main
# Conflicts:
#	service/openaicompat/chat_to_responses.go
2026-02-08 00:16:35 +08:00
Calcium-Ion
ce0113a6b5 Merge pull request #2864 from seefs001/fix/thining-summary
fix: add paragraph breaks between reasoning summary chunks
2026-02-08 00:15:32 +08:00
Calcium-Ion
dd5610d39e Merge pull request #2854 from seefs001/fix/claude-tool-index
fix: Claude stream block index/type transitions
2026-02-08 00:15:20 +08:00
Calcium-Ion
8e1a990b45 Merge pull request #2857 from QuantumNous/feat/custom-oauth
feat(oauth): implement custom OAuth provider
2026-02-08 00:13:20 +08:00
Seefs
5f6f95c7c1 Merge pull request #2874 from MUTED64/main
feat: Force beta=true parameter for Anthropic channel
2026-02-08 00:09:28 +08:00
Calcium-Ion
78ddb85f22 Merge pull request #2852 from seefs001/fix/codex-tips
feat: add Codex channel disclaimer (i18n, OpenAI terms)
v0.10.8
2026-02-08 00:07:41 +08:00
Seefs
22d7fdb3ae codex tips 2026-02-08 00:06:06 +08:00
CaIon
0837090fa9 🔧 refactor: Enhance Log struct indexing for improved query performance 2026-02-07 23:20:43 +08:00
CaIon
c8aee5e487 🔧 refactor: Update formatUserLogs function to accept start index
Modified the formatUserLogs function to include a startIdx parameter, allowing for more flexible log ID assignment. Updated calls to this function in GetLogByTokenId and GetUserLogs to pass the appropriate starting index.
2026-02-07 22:51:26 +08:00
Seefs
0b3a0b38d6 fix: patch message_delta usage via gjson/sjson and skip on passthrough 2026-02-07 19:13:58 +08:00
Thomas
bbad917101 fix: 补全 streaming message_delta 事件缺失的 input_tokens 和 cache 相关字段 (#2881)
当上游为 AWS Bedrock 时,message_delta 的 usage 可能缺少 input_tokens、
cache_creation_input_tokens、cache_read_input_tokens 等字段,导致与原生
Anthropic 格式不一致。从 message_start 积累的 claudeInfo 中补全这些字段后
重新序列化,确保客户端收到一致的 usage 格式。
2026-02-07 18:17:22 +08:00
Seefs
a0bb78edd0 fix: 使用openai兼容接口调用部分渠道在最终端点为claude原生端点下还是走了openai扣减input_token的逻辑 2026-02-07 14:21:19 +08:00
Calcium-Ion
aa31b9c77c Merge pull request #2879 from QuantumNous/fix/subscription-preference-fallback
 chore: Improve subscription billing fallback and UI states
2026-02-07 13:55:37 +08:00
Calcium-Ion
60d4750001 Merge pull request #2880 from QuantumNous/feat/subscription-quota-notify
🔔 feat: Add subscription-aware quota notifications and update UI copy
2026-02-07 13:42:23 +08:00
t0ng7u
82138fc0b0 🔔 feat: Add subscription-aware quota notifications and update UI copy
Routes quota alerts through a subscription-specific check when billing from subscriptions, preventing wallet-based thresholds from triggering false warnings.
Updates the notification settings description and localization keys to clarify that both wallet and subscription balances are monitored.
2026-02-07 01:15:59 +08:00
t0ng7u
10c5f5f906 🛠️ fix: billing session error handling for subscription-first fallback.
Aligns the error variable types in the subscription-first path so that quota fallback checks use the correct NewAPIError.
This prevents build failures and preserves the intended wallet fallback when subscription pre-consume returns an insufficient quota error.
2026-02-07 01:03:49 +08:00
t0ng7u
1cc6bf1b45 chore: Improve subscription billing fallback and UI states
Add a lightweight active-subscription check to skip subscription pre-consume when none exist, reducing unnecessary transactions and locks. In the subscription UI, disable subscription-first options when no active plan is available, show the effective fallback to wallet with a clear notice, and distinguish “invalidated” from “expired” states. Update i18n strings across supported locales to reflect the new messages and status labels.
2026-02-07 00:57:36 +08:00
Calcium-Ion
8b8ea60b1e Merge pull request #2877 from QuantumNous/refactor/billing-session
refactor: 抽象统一计费会话 BillingSession
v0.10.8-alpha.12
2026-02-07 00:30:23 +08:00
Calcium-Ion
e57bac7c91 Merge pull request #2878 from QuantumNous/feat/hide-subscription-card-when-no-plans
 refactor(wallet): Top-up layout to embed subscription plans into the recharge card tabs
2026-02-07 00:30:07 +08:00
t0ng7u
158baf0493 refactor(wallet): Top-up layout to embed subscription plans into the recharge card tabs
- Defaulting to subscriptions when available and avoiding initial flash when no plans exist.
- Adjust the wide-screen layout to place wallet and invite sections side by side, simplify the subscription header and controls, and add padding to prevent card borders from clipping.
- Update related i18n strings by adding the new tab label and removing the obsolete subscription blurb.
2026-02-07 00:11:00 +08:00
CaIon
15fc77d400 fix: 修复 BillingSession 多个边界问题
- Settle 部分失败保护:新增 fundingSettled 标记,资金来源提交后
  令牌调整失败不再导致 Refund 误退已结算的资金
- 订阅多扣费修复:trySubscription 传 subConsume 而非 preConsumedQuota
  给 preConsume,保证三者(amount/preConsume/FinalPreConsumedQuota)一致
- 令牌回滚错误记录:preConsume 中 funding 失败时令牌回滚错误不再丢弃
- 移除钱包路径死代码:用户额度不足的 strings.Contains 匹配不可能命中
- WalletFunding.Refund 不重试:IncreaseUserQuota 非幂等,重试会多退
2026-02-06 23:41:51 +08:00
CaIon
0c0ccf510b refactor: 抽象统一计费会话 BillingSession
将散落在多个文件中的预扣费/结算/退款逻辑抽象为统一的 BillingSession 生命周期管理:

- 新增 BillingSettler 接口 (relay/common/billing.go) 避免循环引用
- 新增 FundingSource 接口 + WalletFunding / SubscriptionFunding 实现 (service/funding_source.go)
- 新增 BillingSession 封装预扣/结算/退款原子操作 (service/billing_session.go)
- 新增 SettleBilling 统一结算辅助函数,替换各 handler 中的 quotaDelta 模式
- 重写 PreConsumeBilling 为 BillingSession 工厂入口
- controller/relay.go 退款守卫改用 BillingSession.Refund()

修复的 Bug:
- 令牌额度泄漏:PreConsumeTokenQuota 成功但 DecreaseUserQuota 失败时未回滚
- 订阅退款遗漏:FinalPreConsumedQuota=0 但 SubscriptionPreConsumed>0 时跳过退款
- 订阅多扣费:subConsume 强制为 1 但 FinalPreConsumedQuota 不同步
- 退款路径不统一:钱包/订阅退款逻辑现统一由 FundingSource.Refund 分派
2026-02-06 23:14:25 +08:00
Calcium-Ion
f18aec5281 Merge pull request #2876 from seefs001/fix/json_schema
fix: /v1/chat/completions -> /v1/responses json_schema
2026-02-06 23:08:49 +08:00
Seefs
57059ac73f fix: /v1/chat/completions -> /v1/responses json_schema 2026-02-06 23:03:58 +08:00
Seefs
fac9c367b1 fix: auto default codex to /v1/responses without overriding user-selected endpoint 2026-02-06 22:08:55 +08:00
Seefs
23227e18f9 feat: channel test stream 2026-02-06 21:57:38 +08:00
CaIon
d814d62e2f refactor: enhance API security with read-only token authentication and improved rate limiting 2026-02-06 21:26:26 +08:00
MUTED64
4332837f05 feat: Force beta=true parameter for Anthropic channel 2026-02-06 21:22:39 +08:00
QuentinHsu
8ec16faf28 feat(topup): hide subscription plans card when no plans available 2026-02-06 20:27:25 +08:00
CaIon
04dd761880 fix: update LIKE pattern sanitization for token search
- Change ESCAPE character from '\' to '!' for compatibility with MySQL/PostgreSQL/SQLite
- Adjust sanitization logic to escape '!' and '_' correctly, improving input validation for search queries
v0.10.8-alpha.11
2026-02-06 19:52:35 +08:00
Seefs
50ee4361d0 feat: make 5m cache-creation ratio configurable 2026-02-06 19:46:59 +08:00
CaIon
5ff9bc3851 chore: add fmt import for improved logging in token controller v0.10.8-alpha.10 2026-02-06 18:01:11 +08:00
Calcium-Ion
053699fa98 Merge commit from fork
fix: harden token search with pagination, rate limiting and input validation
2026-02-06 17:54:40 +08:00
CaIon
3e1be18310 fix: harden token search with pagination, rate limiting and input validation
- Add configurable per-user token creation limit (max_user_tokens)
- Sanitize search input patterns to prevent expensive queries
- Add per-user search rate limiting (by user ID)
- Add pagination to search endpoint with strict page size cap
- Skip empty search fields instead of matching nothing
- Hide internal errors from API responses
- Fix Interface2String float64 formatting causing config parse failures
- Add float-string fallback in config system for int/uint fields
2026-02-06 17:52:19 +08:00
Calcium-Ion
f3d6e99b28 Merge pull request #2863 from prnake/feat/claude-opus-4-6
feat: add claude-opus-4-6
v0.10.8-alpha.9
2026-02-06 16:18:00 +08:00
Calcium-Ion
6de8dea9b9 Merge commit from fork
🔒 fix(security): sanitize AI-generated HTML to prevent XSS in playground
2026-02-06 16:16:20 +08:00
Seefs
3af53bdd41 fix max_output_token 2026-02-06 16:04:49 +08:00
Seefs
aa8240e482 feat: /v1/messages -> /v1/responses 2026-02-06 15:22:32 +08:00
t0ng7u
ab5456eb10 🔒 fix(security): sanitize AI-generated HTML to prevent XSS in playground
Mitigate XSS vulnerabilities in the playground where AI-generated content
is rendered without sanitization, allowing potential script injection via
prompt injection attacks.

MarkdownRenderer.jsx:
- Replace dangerouslySetInnerHTML with a sandboxed iframe for HTML preview
- Use sandbox="allow-same-origin" to block script execution while allowing
  CSS rendering and iframe height auto-sizing
- Add SandboxedHtmlPreview component with automatic height adjustment

CodeViewer.jsx:
- Add escapeHtml() utility to encode HTML entities before rendering
- Rewrite highlightJson() to process tokens iteratively, escaping each
  token and structural text before wrapping in syntax highlighting spans
- Escape non-JSON and very-large content paths that previously bypassed
  sanitization
- Update linkRegex to correctly match URLs containing & entities

These changes only affect the playground (AI output rendering). Admin-
configured content (home page, about page, footer, notices) remains
unaffected as they use separate code paths and are within the trusted
admin boundary.
2026-02-06 15:10:05 +08:00
Seefs
a1695b7657 feat: gpt-5.3-codex 2026-02-06 14:47:23 +08:00
Seefs
b580b8bd1d fix: add paragraph breaks between reasoning summary chunks in chat2responses stream 2026-02-06 14:46:29 +08:00