Commit Graph
100 Commits
Author SHA1 Message Date
Calcium-Ion 31d70fca39 refactor(auth): replace dashboard sessions with stateless tokens and session control (#6329)
* refactor(auth): replace dashboard sessions with stateless tokens

* feat(auth): harden session issuance and distributed enforcement

* fix(proxy): preserve trusted proxy compatibility defaults

* refactor: address dashboard auth review feedback

* refactor: remove classic frontend and flatten web app
2026-07-20 16:48:43 +08:00
CaIon 5a6c53d496 feat: standardize OpenAI Models label usage across components 2026-07-18 15:44:48 +08:00
CaIon 923a17ca8a fix: update high-risk status code retry confirmation texts 2026-07-17 21:54:29 +08:00
CaIon bde9b2f448 fix: harden unset price models tab batch copy, feedback, and memo equality
Persist committed editor drafts to the source model during batch copy so
targets never carry pricing the source would lose, surface loading/error
states for the enabled-models query, and compare saved* props in the
visual editor memo so rows leave the unset list reliably after save.
2026-07-11 22:57:22 +08:00
CaIon 7a2b9d86e8 feat: enhance model search functionality with status and sync filters 2026-07-11 22:36:09 +08:00
CaIon 92d3c9d18f fix: bound uncached remainder by prompt-max(cached,write) and forward compact prompt_cache_key 2026-07-11 22:18:26 +08:00
CaIon 48068ce923 feat: bill OpenAI cache_write_tokens at cache-creation price with zero clamp
Parse OpenAI's native cache_write_tokens (chat prompt_tokens_details /
responses input_tokens_details), bill it at the cache-creation ratio, and
clamp the uncached prompt remainder at zero since cached + cache-write can
exceed prompt_tokens. Propagate the field through chat/responses/claude
format conversions and tiered expression billing (cc variable).
2026-07-11 21:18:49 +08:00
Calcium-Ion c36418c863 feat: enhance text protocol conversion and advanced custom routing (#5825)
* refactor: consolidate relay protocol converters

* refactor relayconvert text converters

* feat: refine relay converters and advanced custom routing

* refactor: enhance logging and add thought signature handling for Gemini requests

* refactor: enhance channel cache and pricing endpoint handling for advanced custom models

* feat: preserve billing usage semantics

* feat: add protocol-aware billing usage

* Delete useless files

* chore: update action versions in workflow files

* chore: update Docker action versions in workflow files

* fix: harden billing usage settlement and hot-path route matching

- estimate Gemini completion tokens locally when billable usageMetadata is
  prompt-only but output content was received (e.g. client aborts the stream
  before the final chunk), and rebuild the attached billing_usage as estimated
  so settlement does not bill zero output tokens
- guard NewClaudeMessagesBillingUsage against all-zero ClaudeUsage, matching
  the OpenAI/Gemini constructors, so a zero billing_usage cannot override a
  non-zero top-level usage during settlement
- cache compiled advanced-custom route model regexes; they run on the request
  hot path and were recompiled per request
- move the effectiveBillingUsage remap to PostTextConsumeQuota only, and
  document that calculateTextQuotaSummary expects remapped usage
- document the updatePricingLock -> channelSyncLock lock ordering that
  InitChannelCache/CacheUpdateChannel rely on, and the aux-struct pitfall in
  GeminiChatResponse.UnmarshalJSON
2026-07-11 20:44:12 +08:00
CaIon 1250fb2eb5 fix: adjust margin for StatusBadge component in logs columns 2026-07-11 20:23:15 +08:00
CaIon e400619656 feat: enhance stale instance handling and update theme colors 2026-07-11 19:37:34 +08:00
CaIon 162f87925c feat: update theme colors 2026-07-11 19:25:04 +08:00
CaIon 6bbddb1046 feat(timing): add timing metrics display for stream logs and enhance localization 2026-07-11 15:32:35 +08:00
CaIon 1b1b23d1d0 revert: restore StatusBadge horizontal padding
Revert 6869cd94b (perf(web): align table badge spacing).
Restores px padding on status badges so usage-log timing/duration
pills are not flush against the edges.
2026-07-11 15:04:12 +08:00
CaIon 337169e0a4 revert: undo t0ng7u UI design-system refactor
Revert the following commits:
- 308e3e347 feat(web): polish themed data views and add task log details
- b2a890e75 fix: Fontsource asset resolution across workspace layouts
- 9d1ca545e refactor(web): refine data-table cards and pricing page layout
- 0918bdb49 refactor(web): consolidate design-system primitives and responsive data views
- 262ab9312 style(web): unify design system across default frontend
2026-07-11 14:51:54 +08:00
CaIon 269e4ff390 feat(image): enhance image stream handling with client disconnect logic and billing adjustments 2026-07-11 13:14:22 +08:00
CaIon d9595831bf fix(billing): improve quota handling and error reporting for pre-consume operations 2026-07-11 13:14:22 +08:00
CaIon 621927f710 fix(billing): reject saturated pre-consume quota 2026-07-11 13:14:21 +08:00
CaIon a79f96919e fix(affiliate): update referral message 2026-07-09 16:49:53 +08:00
CaIon 97bbb7c8cd feat(pricing): enhance dynamic pricing calculations with group selection support 2026-07-08 15:11:32 +08:00
CaIon 6a437a337d feat(oauth): add OAuth callback URL display and copy functionality 2026-07-08 12:50:57 +08:00
CaIon 57865fc1f8 fix: restore default channel connection paste 2026-07-08 12:39:23 +08:00
CaIon 6ce7305cd3 feat(price): add token ratios for GPT-5.6 models 2026-07-07 21:42:28 +08:00
CaIon fc1259f583 refactor(price): improve handling of other ratios in PriceData 2026-07-07 21:22:19 +08:00
CaIon 2f5f6ba84f feat: prepare for 5.6 2026-07-07 20:57:08 +08:00
CaIon 8bc4bf1d6b feat(docker): add cosign for signing manifests and update permissions 2026-07-07 20:08:27 +08:00
CaIon 3fbad6a72f fix(price): add default token estimate for tiered expression pre-consume 2026-07-07 15:42:21 +08:00
CaIon becc18e300 fix(i18n): add language detection mapping for Chinese locales 2026-07-07 14:02:09 +08:00
CaIon 8f31b30598 fix(i18n): standardize locale formatting for Intl APIs 2026-07-07 13:40:06 +08:00
CaIon 5cbb7b0be1 docs: update system architecture requirements 2026-07-07 13:15:04 +08:00
CaIon 48b7f4918f fix(billing): adjust quota calculation to prevent exceeding int32 limits 2026-07-07 13:11:55 +08:00
CaIon 70ea899e37 fix(model): centralize row locking in transactional flows 2026-07-07 12:40:09 +08:00
CaIon bae799ccb1 fix(billing): surface quota saturation events for admin auditing
Thread int32 saturation clamps from tiered settlement and video task
recompute into the consume/task logs under admin_info, so oversized or
malformed billing inputs stay auditable. Clamp negative audio duration
before token conversion and gate the saturation UI markers on admin.
2026-07-07 12:20:07 +08:00
CaIon c9943d37ad fix(billing): extend quantity validation and saturating conversions to remaining paths
Bound max-tokens fields across all relay format validators, saturate
tiered-expression rounding and audio/tool/task token conversions, and
route legacy remix ratios through the guarded setter.
2026-07-07 01:08:52 +08:00
CaIon d0bd8aac74 fix(billing): validate quantity parameters and harden quota calculations
Bound user-supplied count/duration parameters at request validation,
route ratio multipliers through guarded setters, and use saturating
int conversions in all quota math paths.
2026-07-07 00:21:06 +08:00
CaIon fc26b88fd1 feat(group): enhance group ratio editor with improved visibility rules and JSON parsing 2026-07-06 16:22:18 +08:00
CaIon df087b022d feat(ssrf): implement SSRF protection in HTTP clients and validation functions 2026-07-06 14:52:01 +08:00
CaIon 1e11dfcfb5 feat(user): better messages for redeem failures 2026-07-06 14:52:01 +08:00
CaIon 2281c9e3d8 fix(web): refine mobile user cards 2026-07-05 15:02:08 +08:00
CaIon 4a64b87072 test(user): cover self-service password update guard
Pin down the checkUpdatePassword contract:

- changing a password requires the correct current password
- OAuth/passwordless accounts (empty password hash) cannot set a
  password through the self-service endpoint and must use the password
  reset flow instead
- setupLogin never writes back the password column

These guard against regressing the password-change path back into a
short-circuit that lets passwordless accounts set a password directly.
2026-07-05 13:53:25 +08:00
CaIon 56dbaab1d4 feat(session): support opt-in Secure session cookies
- add SESSION_COOKIE_SECURE / SESSION_COOKIE_TRUSTED_URL env vars with
  startup validation: enabling Secure requires at least one trusted
  HTTPS entry URL
- wire common.SessionCookieSecure into the session cookie store instead
  of a hardcoded Secure=false
- print a startup warning when Secure session cookies are disabled
- document the new settings in .env.example and docker-compose files

Secure stays off by default because many deployments front new-api with
plain-HTTP reverse proxies, where a hardcoded Secure default would break
logins entirely; enabling it safely depends on the deployment's TLS
setup, so it ships as an opt-in deployment-hardening flag.
2026-07-05 13:53:16 +08:00
CaIon 0d5995eb63 fix(auth): allow read-only access for non-disabled tokens 2026-07-05 13:35:10 +08:00
CaIon 5fc35e28a2 fix(user): harden account email and password handling
- normalize emails (trim + lowercase) and enforce uniqueness across
  registration, OAuth auto-registration, and email binding
- serialize concurrent writers on the same normalized email within a
  transaction to avoid duplicate accounts
- resolve password reset to a single matching account and reject
  ambiguous or absent matches
- require an existing password before self-service password change and
  reject login for accounts without a usable password
2026-07-05 13:15:41 +08:00
CaIon bed4a3f916 fix(user): trim whitespace from username and validate input 2026-07-04 16:56:37 +08:00
CaIon 12603a7765 fix(redemption): add status filtering and cleanup action 2026-07-04 16:15:47 +08:00
CaIon 86021d8ed2 Refine default web UI and backend sync handling 2026-07-04 14:57:53 +08:00
CaIon 55858f353c feat: add manual Docker image publishing workflow 2026-07-03 16:54:52 +08:00
Calcium-Ion dfc0d6324b Merge commit from fork
* Harden user setting cache updates

* Fix user update test isolation
2026-07-03 15:25:33 +08:00
CaIon bfddc5fea0 fix: omit access_token from user queries 2026-07-03 15:15:16 +08:00
CaIon 8874d1929f Make quota logging synchronous and delay startup log 2026-07-02 21:58:41 +08:00
CaIon bff701b0cd docs: update AGENTS.md 2026-07-02 21:53:53 +08:00
CaIon 12fc010060 Bump Electron lockfile dependencies 2026-06-30 14:06:48 +08:00
CaIon 43591fba77 feat: improve advanced custom route editor 2026-06-29 12:45:30 +08:00
CaIon 25f998595d feat: refine channel management UI 2026-06-28 16:36:32 +08:00
CaIon 1d166532fe fix: update section titles and improve layout in channel components 2026-06-28 15:21:45 +08:00
Calcium-Ion 2d5a041639 feat: support Responses to Chat (#5787)
* fix(openai): harden Chat-to-Responses compatibility

Add a shared Responses-to-Chat stream state machine and use it from the OpenAI relay path. Preserve assistant text alongside tool calls, bind tool argument deltas by output_index, map incomplete finish reasons, support reasoning/custom tool events, and buffer upstream SSE for non-stream Chat clients.

Add deterministic service tests and relay SSE tests for the conversion path.

Related to #5745.

* refactor: rename openaicompat to relayconvert for improved clarity

* feat(gemini): support responses request conversion

* feat: add responses to chat conversion support

* fix: harden responses chat conversion edge cases
2026-06-28 14:25:47 +08:00
Calcium-Ion 3a506f50f0 fix(openai): harden Chat-to-Responses compatibility (#5772)
Add a shared Responses-to-Chat stream state machine and use it from the OpenAI relay path. Preserve assistant text alongside tool calls, bind tool argument deltas by output_index, map incomplete finish reasons, support reasoning/custom tool events, and buffer upstream SSE for non-stream Chat clients.

Add deterministic service tests and relay SSE tests for the conversion path.

Related to #5745.
2026-06-27 19:16:56 +08:00
CaIon 626dadb556 fix(web): secure rich content rendering 2026-06-27 17:44:52 +08:00
CaIon df44a75d53 fix: adapt ClickHouse log LIKE filters 2026-06-27 17:03:25 +08:00
Calcium-Ion 4aee5f7d5a feat: better admin permissions (#5755)
* feat: add casbin admin permissions

* feat: improve audit logging to associate logs with actual operators and target users

* feat: enhance admin permissions and UI interactions for sensitive actions

* Refactor authz RBAC and tighten channel permissions

* Split channel authz field policy

* Address channel authz review findings
2026-06-27 17:01:59 +08:00
CaIon 6c35e1ef26 chore: update i18n skill 2026-06-27 12:42:54 +08:00
CaIon b191f47375 fix: use neutral drawing task labels 2026-06-24 22:15:29 +08:00
CaIon 69b0f0b56f feat: add date-fns and date-fns-tz paths to build configuration 2026-06-24 20:56:01 +08:00
CaIon 48da37a3df feat: add date-fns and date-fns-tz dependencies 2026-06-24 20:51:58 +08:00
CaIon ad35ab1d9a feat: enhance i18n-translate skill 2026-06-24 20:46:30 +08:00
CaIon 5814ca90c3 fix: add token limit save label translations 2026-06-24 20:45:48 +08:00
CaIon d2dcbc3137 feat: add channel async polling delay toggle
Fixes #5717
Fixes #4244
2026-06-24 20:40:10 +08:00
Calcium-Ion 2cbdfa0398 feat: add system instance info panel (#5716)
* feat: add system instance reporting

* feat: show system instance resources

* fix: update translations for heartbeat messages in Russian and Vietnamese
2026-06-24 19:16:56 +08:00
Calcium-Ion 5377192293 feat: add system task runner (#5680) 2026-06-24 17:16:21 +08:00
CaIon acb52d0f78 chore(deps): update clickhouse-go and orb dependencies 2026-06-24 16:20:02 +08:00
CaIon 72b3f34576 chore: update agent skills and project config
- add vercel-react-best-practices skill (SKILL.md + full-guide.md)
- slim CLAUDE.md to import shared AGENTS.md conventions
- promote go-ntlmssp to a direct dependency in go.mod
2026-06-24 13:52:51 +08:00
CaIon cf6ae6fdeb fix: preserve SMTP PLAIN auth TLS guard 2026-06-24 12:50:54 +08:00
CaIon 9fc9c8f1e3 chore: avoid duplicate shadcn skill exposure 2026-06-23 13:53:52 +08:00
CaIon f8cfbfa4df refactor(log): remove legacy log deletion endpoint and associated types 2026-06-22 19:40:04 +08:00
CaIon f84b7d591f refactor(log): simplify ClickHouse log deletion and add unit tests
Replace the per-batch ClickHouse mutation loop with a single
ALTER TABLE ... DELETE, since ClickHouse DELETE is a heavy mutation
that rewrites data parts and per-batch mutations are pathologically
slow. Add deterministic unit tests covering ClickHouse DSN handling,
main-database rejection, TTL DDL generation, log ordering, request_id
backfill, and display id assignment.
2026-06-22 19:32:32 +08:00
CaIon a162163b48 feat: add persistent system task log cleanup progress 2026-06-22 19:16:53 +08:00
Calcium-Ion 6dc4030fdf feat: support ClickHouse log database (#5663)
* feat: support ClickHouse log database

* feat(log): optimize log deletion process for ClickHouse
2026-06-22 18:41:26 +08:00
CaIon e5694748c7 chore(web): use tsgo for type checking 2026-06-22 13:38:43 +08:00
CaIon 44e0e68689 feat: add channel test env toggle 2026-06-22 12:45:45 +08:00
CaIon 5e86644649 feat(dashboard): add sensitive data toggle to flow chart
Add an eye toggle in the flow section header that masks sensitive node
labels (users, tokens, nodes, groups, channels) in the Sankey while keeping
model names visible. Masking only rewrites display text; nodes stay distinct
via their key so graph structure, links, and highlighting are unaffected.
2026-06-20 22:09:04 +08:00
CaIon 8ad83bf62f feat(dashboard): interactive sankey highlighting and persistent filters
- Highlight full paths through a clicked node or link in the flow Sankey,
  dimming unrelated nodes/links instead of removing them
- Disable VChart built-in emphasis to avoid crash, use custom highlight sets
- Initialize models filter dialog from currently applied filters so manual
  time ranges are not overridden by preferences; auto-pick granularity by range
- Lift user charts time range/granularity/limit to dashboard as controlled state
2026-06-20 22:09:03 +08:00
CaIon 061948011c feat: limit dashboard flow nodes 2026-06-20 22:09:03 +08:00
CaIon f9e508bdae perf(channels): optimize card view layout and reduce re-renders
- Show 3-column card grid from xl breakpoint instead of 2xl
- Cap inline priority/weight width to avoid huge values stretching cards
- Collapse right-column grid to content-sized columns, removing wasted space
- Memoize channel columns, context value, upstream-update result, and ChannelCard
  to avoid rebuilding/re-rendering all cards on unrelated state changes
2026-06-20 16:06:06 +08:00
CaIon cb841850b7 fix: update channel icon 2026-06-20 14:06:53 +08:00
CaIon 91ab664c53 feat: add routing reliability management 2026-06-20 13:55:50 +08:00
CaIon 2c2d92116f refactor: simplify model list 2026-06-20 12:16:42 +08:00
CaIon 0229dc2057 refactor: refine toolbar controls and model drawer 2026-06-19 20:17:45 +08:00
CaIon 9100e15e4e feat: add channel sensitive info toggle 2026-06-19 20:09:18 +08:00
CaIon 4206d7fd58 feat(data-table): enhance mobile card view handling and improve layout logic 2026-06-19 19:58:20 +08:00
CaIon 50b8f2a272 refactor: update styling and improve code readability across multiple components 2026-06-19 19:29:00 +08:00
CaIon a0de4b560e refactor(channels): restructure channel card into left/right columns
Group #id/name and balance on the left and priority/weight plus
response/last-tested on the right. Simplify field labels by dropping
the CJK-unfriendly uppercase/letter-spacing, left-align the right
column, and shorten the "Last Tested" zh label.
2026-06-19 18:30:13 +08:00
CaIon 0467d54014 chore: update frontend branding copy 2026-06-19 18:14:40 +08:00
CaIon 29c3dcb927 feat(table): support card layout 2026-06-19 17:43:13 +08:00
CaIon 68585568d6 feat(data-table): add reusable card/table view toggle
Add an opt-in card view to the shared data-table stack (DataTablePage),
toggled via a segmented control in the toolbar with per-table localStorage
persistence. Cards render generically from column meta by default, with an
optional renderCard slot. Defaults to table-only so existing pages are
unchanged.

Wire it into the channels page with a bespoke ChannelCard that reuses every
column's cell renderer, preserving all table information and interactions
(selection, inline priority/weight, balance refresh, status, actions, tag
expand).
2026-06-19 17:43:11 +08:00
CaIon 6bd69f3edf feat(ui): enhance endpoint selection and date picker 2026-06-19 15:10:50 +08:00
CaIon 0c806db996 refactor(theme): update color classes 2026-06-19 14:53:44 +08:00
CaIon 490395b2f8 feat(performance): enhanced metrics display 2026-06-19 14:27:16 +08:00
CaIon 6ad5dbb641 fix(main): prevent refetching on window focus to optimize performance 2026-06-19 12:45:20 +08:00
CaIon f7dae5cbe6 fix(drawing): update timestamp formatting to include milliseconds 2026-06-18 21:38:55 +08:00
CaIon f4575fe664 feat(format): add locales support to number formatting 2026-06-18 21:30:05 +08:00
CaIon cfc9bbcdbf feat(logs): improve layout 2026-06-18 21:29:55 +08:00