Add gpt-5.3-codex-spark to model service and config.
Also add gpt-5.3-codex to model service (was only in config).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Clients (e.g. opencode) may truncate conversation history in long sessions, leaving tool_use blocks without corresponding tool_result. The upstream Claude API strictly validates this pairing and returns 400. This adds _patchOrphanedToolUse() to claudeRelayService._processRequestBody(), which detects orphaned tool_use IDs and synthesizes error tool_result blocks — the same approach already used in anthropicGeminiBridgeService for the Antigravity path.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Claude Console API (e.g., GLM accounts) does not accept messages with
role='system' in the messages array, returning 422 error:
"Input should be 'user' or 'assistant'"
This fix automatically transforms system messages by merging them into
the first user message's content, maintaining compatibility with clients
like opencode that send system role messages.
Changes:
- Add _transformSystemMessages() method to merge system content into user messages
- Apply transformation in both relayRequest() and relayStreamRequestWithUsageCapture()
- Only affects claude-console account type, no impact on official API
Fixes issues where opencode users get 422 errors when using Console API accounts.
- Keep account status as 'active' when quota exceeded (not 'quota_exceeded')
- Keep isActive as true, only use quotaStoppedAt to mark quota exceeded
- Show green status in UI for quota exceeded accounts (normal state)
- Show '余额不足' as unschedulable reason instead of '已暂停'
- Simplify resetDailyUsage() to only check quotaStoppedAt field
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- redis.getWeeklyOpusCost: read only usage:opus:weekly:* (remove claude fallback)
- weeklyClaudeCostInitService: write to usage:opus:weekly:* instead of claude
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- auth.js: keep 402 status code with Opus message
- redis.js: keep dual-cost tracking (rated/real) with opus key prefix, add setWeeklyOpusCost method
- apiKeyService.js: keep both imports, serviceRates handling, and 5-param recordOpusCost
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix updateApiKey to use JSON.stringify for permissions field
- Add comma-separated string handling in normalizePermissions
- Add frontend parsing for comma-separated permissions format
Fixes issue where selecting multiple permissions (e.g. Claude + OpenAI)
would be saved as "claude,openai" instead of '["claude","openai"]'
- message_start: nest fields inside 'message' object with type: 'message'
- content_block_delta: add type field to data
- message_delta: add type field to data
- message_stop: remove usage field, just return type
- Extract usage from message_delta instead of message_stop