Commit Graph
1474 Commits
Author SHA1 Message Date
erio 8abaea43a8 fix(ci): remove local replace directive and revert sora.NewWebClient
The local go.mod replace directive for go-sora2api pointed to a Windows
path which breaks CI on Linux. Revert sora.NewWebClient back to sora.New
since the remote module doesn't have this method yet.
2026-03-08 18:25:45 +08:00
erio 0bf7111e27 feat: add Antigravity 403 forbidden status detection and display
- Backend: detect and classify 403 responses (validation/violation/forbidden)
- Backend: extract verification/appeal URLs from 403 response body
- Frontend: display forbidden status badges with color coding
- Frontend: show clickable/copyable verification links
- Also includes: sora SDK client rename, table header style fix, tier badge in accounts list

chore: bump version to 0.1.93.23
2026-03-08 18:23:07 +08:00
erioandClaude Opus 4.6 597c19e80b fix: comprehensive Sora & GDrive code review fixes
P0 fixes:
- StorageType: UploadFromURL now returns actual storageType, fixing
  GDrive tasks being incorrectly recorded as "s3"
- Concurrency: selectAccount returns ReleaseFunc to caller, fixing
  premature slot release before task creation
- Race condition: applyRecoveredToken uses copy-on-write for
  account.Credentials map to prevent concurrent write panic
- GetCameoStatus: use direct HTTP call to populate missing fields
  (StatusMessage, InstructionSetHint, InstructionSet)
- Frontend: progress bar uses reactive now.value instead of
  non-reactive Date.now()

P1 fixes:
- EditImage: pass req.Image through to CreateImageRequest
- ListPending: add LIMIT 200 to prevent unbounded queries
- Worker encapsulation: add ListPendingTasks/UpdateTask proxy methods
  to SoraTaskService, worker no longer accesses repo directly
- Frontend polling: add retry counter (3 attempts) before giving up

P2-P3 fixes:
- QuotaBar: handle both quota_source and source field names
- i18n: replace hardcoded Chinese labels in SoraPromptBar and
  example prompts in SoraGeneratePage with i18n keys
- Fix regenrate → regenerate i18n typo
- SoraMediaPreview: skip Escape handler when not visible
- SoraGeneratePage: void handleGenerate promise in handleRetry

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 01:02:55 +08:00
erioandClaude Opus 4.6 0af1f5841d fix: Sora task API improvements
- selectAccountByID: use original task's account for remix instead of
  random selection, preventing permission issues in OAuth path
- Upstream error passthrough: forward HTTP status code and body from
  upstream instead of always returning 500
- Add accountRepo to SoraTaskService for direct account lookup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 22:43:19 +08:00
erioandClaude Opus 4.6 70f5827a8f fix: add missing ClearAccountAffinity mocks and update API contract test
- Add ClearAccountAffinity to mockGatewayCacheForPlatform,
  openAIWSStateStoreTimeoutProbeCache, mockGatewayCacheForGemini
- Add allow_messages_dispatch field to groups/available contract test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 20:37:00 +08:00
erioandClaude Opus 4.6 ceb9dec8e4 fix: reject non-UTF-8 request body in Sora handler
Windows terminals may send request bodies in GBK encoding, causing
garbled prompts and upstream failures. Validate UTF-8 encoding in
readBody and return 400 for invalid encodings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 20:15:09 +08:00
erioandClaude Opus 4.6 812135b57e fix: add ClearAccountAffinity to remaining GatewayCache mock implementations
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 20:13:59 +08:00
erioandClaude Opus 4.6 0306119e12 fix: validate UTF-8 before storing request_body as JSONB
PostgreSQL JSONB columns require valid UTF-8 encoding. Skip storing
request_body if it contains invalid UTF-8 byte sequences (e.g. from
non-UTF-8 terminal encodings).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 19:59:51 +08:00
erioandClaude Opus 4.6 e617dfa009 fix: convert []byte to *string for JSONB columns in sora_task_repo
pq driver treats []byte as bytea, not jsonb. Convert charJSON and
reqBody to *string before passing to ExecContext for character_info
and request_body JSONB columns.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 19:52:13 +08:00
erioandClaude Opus 4.6 a64dca7c41 fix: use SoraObjectStorage interface for storage router compatibility
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 19:23:59 +08:00
erioandClaude Opus 4.6 8c412b32d1 feat: add Sora async task API (videos/images)
Add async task management for Sora video/image generation with two
forwarding modes: OAuth (SDK) and API Key (HTTP upstream). Includes
background worker for status polling and 3-layer storage degradation
(S3 > local disk > upstream URL passthrough).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 19:19:11 +08:00
erio 56d9d5cd60 Merge branch 'release/custom-0.1.92' into release/custom-0.1.93
# Conflicts:
#	backend/ent/group.go
#	backend/ent/group/group.go
#	backend/ent/group/where.go
#	backend/ent/group_create.go
#	backend/ent/group_update.go
#	backend/ent/migrate/schema.go
#	backend/ent/mutation.go
#	backend/ent/runtime/runtime.go
#	backend/ent/schema/group.go
#	backend/go.sum
#	backend/internal/handler/dto/mappers.go
#	backend/internal/repository/group_repo.go
#	frontend/src/views/admin/GroupsView.vue
2026-03-07 18:35:52 +08:00
erioandClaude Opus 4.6 91c7a4dccb fix: affinity zone filter must run after priority filter in scheduling
classifyByAffinityZone was running before filterByMinPriority, causing
high-priority accounts in the red zone to be removed before priority
filtering, allowing low-priority accounts in the green zone to be
selected instead. Move zone classification into the priority loop so
it operates within same-priority groups, with fallback to next priority
group when current group is entirely in the red zone.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 17:30:48 +08:00
Wesley Liddick c2b14693b4 Merge pull request #835 from biubiutata/codex/fix-openai-originator-detection
fix(openai): 统一官方 Codex 客户端识别逻辑
2026-03-07 17:03:52 +08:00
shaw 92d35409de feat: 为openai分组增加messages调度开关和默认映射模型 2026-03-07 17:02:19 +08:00
erioandClaude Opus 4.6 59869b2b07 feat: client affinity three-zone scheduling model (green/yellow/red)
Backend: Add AffinityZone type with GetAffinityBase/GetAffinityBuffer/GetAffinityZone
methods. Integrate classifyByAffinityZone into Layer 2 scheduling and red zone
check into Layer 1.6 affinity hit path. 17 unit tests covering all zone boundaries.

Frontend: Add AffinityConfigCard for base/buffer configuration in EditAccountModal.
Move affinity badge from status column to capacity column with zone-based coloring
(count/limit format). Extract CapacityBadge and QuotaBadge components to reduce
AccountCapacityCell from 444 to 215 lines.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 16:56:23 +08:00
shaw 7079edc2d0 feat: announcement支持强制弹窗通知 2026-03-07 15:06:13 +08:00
erioandClaude Opus 4.6 e890f177b9 refactor: usage queue groups by proxy exit identity instead of proxy_id
Anthropic OAuth/setup-token accounts are throttled by actual proxy
connection (host:port:username). Other platforms bypass the queue
entirely. Also adds unit tests for affinity and usage queue features.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 14:33:52 +08:00
admin da89583ccc fix(openai): detect official codex client by headers 2026-03-07 14:12:38 +08:00
erioandClaude Opus 4.6 9b382a2dc7 feat: add affinity clients hover popover with last active times
- New API: GET /accounts/:id/affinity-clients returns client list with
  last_active timestamps from Redis ZSET scores
- New Lua script: get_affinity_clients_with_scores.lua uses ZREVRANGEBYSCORE
  WITHSCORES to return both client IDs and their timestamps
- New frontend component: AffinityBadge.vue replaces inline badge with
  hover popover that lazy-loads client details on first hover
- Shows client ID (monospace) + relative time (e.g. "3h ago")

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 13:50:39 +08:00
shaw a42a1f08e9 fix: 编辑error状态账号时保存报Status验证失败
后端UpdateAccountRequest.Status的oneof验证缺少error状态,
前端编辑表单也未处理error状态,导致编辑异常账号时无法保存
2026-03-07 13:47:08 +08:00
shaw ebd5253e22 fix: /response端点移除强制注入大量instructions内容 2026-03-07 13:39:47 +08:00
erioandClaude Opus 4.6 1864f41f33 merge: sync upstream/main into release/custom-0.1.92
Merge upstream main branch changes including:
- OpenAI Codex support and websearch adaptation
- API key rate limit auto-reset fix
- golangci-lint v2.11 upgrade for Go 1.26 compatibility
- Go 1.26.1 stdlib security fixes
- Empty stream failover fix
- CCSwitch import improvements
- API key credentials preserve existing fields
- Usage query rate limit optimization
- Setup Token real utilization fix

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 12:53:12 +08:00
erioandClaude Opus 4.6 7d276bc91d fix: ensure Lua scripts are loaded before pipeline EVALSHA calls
Pipeline mode only sends EVALSHA (no automatic fallback to EVAL).
If Redis restarts and script cache is lost, all pipeline Lua calls
silently fail with NOSCRIPT. Add ensureScriptLoaded() to pre-load
scripts before pipeline execution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 12:34:36 +08:00
erio 87e0a0f299 debug: add temporary logging for affinity client batch query 2026-03-07 12:31:54 +08:00
erioandClaude Opus 4.6 e73710144e fix: always return affinity_client_count for affinity-enabled accounts
Previously the count was only returned when Redis had data, causing
the badge to not display for accounts with zero affinity clients.
Now returns count=0 for all affinity-enabled accounts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 12:12:11 +08:00
shaw 6411645ffc fix: 适配claude code调度openai账号的websearch功能 2026-03-07 11:33:08 +08:00
shaw 7a353028e7 fix: 修复keys速率限制未自动重置额度的bug 2026-03-07 10:13:51 +08:00
Wesley Liddick 4190293b07 Merge pull request #823 from StarryKira/fix/empty-stream-failover
Fix/empty streamfix issue #791
2026-03-07 08:51:07 +08:00
shaw 1b4d2a41c9 fix(openai): /v1/messages端点补齐Codex用量快照提取与错误透传规则
对齐/v1/responses的Forward方法,修复两处不一致:
- 成功响应时从响应头提取OAuth账号的Codex使用量数据
- 非failover错误场景下应用管理员配置的错误透传规则
2026-03-07 08:40:07 +08:00
erioandClaude Opus 4.6 2b6f3317d6 fix: resolve pre-existing CI failures (sora test mock, staticcheck)
- Add missing CountByStorageType method to stubSoraGenRepo test mock
- Suppress SA1019 for WithCredentialsJSON (admin-controlled source)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 05:31:01 +08:00
erioandClaude Opus 4.6 97343ed371 fix: resolve remaining gofmt alignment and deprecated API issues
- Fix struct tag alignment in dto/types.go (AffinityClientCount)
- Fix struct literal alignment in sora_generation_service.go
- Replace deprecated google.CredentialsFromJSONWithParams with
  option.WithCredentialsJSON for service account auth (SA1019)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 05:20:16 +08:00
erioandClaude Opus 4.6 4aada8a336 fix: resolve golangci-lint errors (gofmt, staticcheck, unused)
- Fix struct field alignment in dto/types.go, settings_view.go,
  sora_generation_service.go for gofmt compliance
- Remove embedded field "Account" from selector in account_handler.go (QF1008)
- Remove unused settingService field from SoraGDriveOAuthService
- Replace deprecated google.CredentialsFromJSON with CredentialsFromJSONWithParams (SA1019)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 05:13:33 +08:00
erioandClaude Opus 4.6 ea5e5dd9c7 feat: display client affinity count badge in account status column
Add colored circle badge showing affinity client count before the account
status indicator. Badge color reflects count severity (gray=0, green=1-5,
yellow=6-15, red=16+). Tooltip shows full client ID list on hover.

Backend: AccountHandler batch queries reverse affinity index via
GetAccountAffinityClientsBatch, returns affinity_client_count and
affinity_clients in DTO. GatewayCache interface extended with the new
batch method backed by a Lua script (get_affinity_clients.lua).

All test mocks synchronized with updated GatewayCache interface.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 04:52:10 +08:00
erioandClaude Opus 4.6 b9dc2e8eb5 refactor: remove dead RemoveClientAffinity code, add affinity scheduling tests
- Remove RemoveClientAffinity from GatewayCache interface, implementation,
  Lua script, and all test mocks (never called in production code)
- Add 26 unit tests for affinity scheduling: filterByMinAffinityCount,
  populateAffinityCounts, Layer 1/2 sort chain integration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 04:26:08 +08:00
erioandClaude Opus 4.6 d707c1f93f feat: client affinity reverse index and balanced scheduling
- Separate clientAffinityTTL (24h) from stickySessionTTL (1h)
- Atomic Lua dual-write for forward (client→accounts) and reverse
  (account→clients) affinity indexes with lazy expiry cleanup
- Extract Lua scripts to standalone .lua files with //go:embed
- Add filterByMinAffinityCount to Layer 1 & 2 scheduling so new
  clients are routed to accounts with fewest existing affinities
- Skip Redis query when no affinity-enabled accounts exist (zero
  overhead for non-affinity users)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 04:10:54 +08:00
JIA-ssandClaude Opus 4.6 1f3f9e131e fix: resolve golangci-lint errors (gofmt alignment, errcheck)
- Fix gofmt: align struct field comments in UsageCache, trim trailing
  whitespace on const comments
- Fix errcheck: use comma-ok on type assertion for singleflight result

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 00:58:08 +08:00
JIA-ssandClaude Opus 4.6 4ddedfaaf9 merge: resolve conflict with main (keep both openAI probe and usage fix)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 00:49:30 +08:00
JIA-ssandClaude Opus 4.6 3ebebef95f fix(usage): add negative caching, singleflight, and jitter to usage queries
Prevents 429 rate-limit retry storms and reduces upstream correlation risk
for Anthropic usage API queries.

Three changes:
1. Negative caching (1 min TTL) — 429/error responses are now cached,
   preventing every subsequent page load from re-triggering failed API calls.
2. singleflight dedup — concurrent requests for the same account are
   collapsed into a single upstream call, preventing cache stampede.
3. Random jitter (0–800 ms) — staggers multi-account cache-miss bursts so
   requests from different accounts don't hit upstream simultaneously with
   identical TLS fingerprints, reducing anti-abuse correlation risk.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 00:39:16 +08:00
erio 29d948bbfd Merge branch 'worktree-feature/sora' into release/custom-0.1.92 2026-03-07 00:35:35 +08:00
erioandClaude Opus 4.6 a21f7d650b feat: display daily/weekly/total quota dimensions in account list
- Add quota_daily_limit/used and quota_weekly_limit/used to DTO and
  frontend Account type
- AccountCapacityCell shows D (daily), W (weekly), and $ (total) badges
  with color-coded status (green/yellow/red)
- AccountActionMenu shows reset button when any quota dimension is set
- Extract quotaBadgeClass/quotaBadgeTooltip as shared functions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 00:18:41 +08:00
erio 5acf888d06 Merge remote-tracking branch 'origin/release/custom-0.1.92' into worktree-feature/sora 2026-03-06 23:58:40 +08:00
erioandClaude Opus 4.6 9e107fae73 feat(sora): improve storage management page with split columns, test buttons, quota and video stats
- Split compound "Profile" column into separate Profile ID and Name columns
- Replace "Endpoint" column with "Storage Path" showing bucket/prefix or folder info
- Add GDrive quota display (capacity/used) via new backend API endpoint
- Add video count statistics per storage type via new backend API endpoint
- Add inline test button per profile with 15s timeout and per-profile loading state
- Backend: GetQuotaInfo, CountByStorageType, GetGDriveQuota, GetStorageVideoStats

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 23:58:27 +08:00
Wesley Liddick 963b3b768c Merge pull request #825 from FizzlyCode/fix/setup-token-real-utilization
fix: Setup Token 账号使用真实 utilization 值替代状态估算
2026-03-06 22:46:20 +08:00
Wesley Liddick f6709fb5d6 Merge pull request #824 from pkssssss/fix/ws-usage-window-pr
fix(openai): 修复 WS 模式下用量窗口不显示
2026-03-06 22:45:36 +08:00
shaw 921599948b feat: /v1/messages端点适配codex账号池 2026-03-06 22:44:07 +08:00
erio 298f5c1baf feat(sora): add GDrive full-cycle test endpoint (upload/download/delete) 2026-03-06 22:33:37 +08:00
神乐 5df3cafa99 style(go): format account usage service 2026-03-06 21:31:36 +08:00
erio 3f1ca43514 debug: add OAuth exchange logging 2026-03-06 21:21:29 +08:00
erioandClaude Opus 4.6 33ab8413db feat: support independent daily/weekly/total quota limits for API Key accounts
Replace single-period-selector (三选一) with three independently configurable
quota dimensions (日/周/总) that can all be set simultaneously. Account is
paused when ANY dimension is exceeded. Periodic quotas (daily/weekly) use
lazy reset via atomic SQL — no cron job needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 21:20:29 +08:00