- 24 Apr, 2026 9 commits
-
-
keh4l authored
Real Claude CLI traffic sends cache_control as `{"type":"ephemeral","ttl":"1h"}`. Our previous payload only sent `{"type":"ephemeral"}`, which is a bytewise mismatch with the official CLI and one more third-party detection signal. Policy: client-provided ttl is always passed through unchanged. Proxy-generated cache_control blocks default to 5m (vs Parrot's 1h) to avoid burning the 1h cache budget on automatic breakpoints while still aligning with the `ttl` field being present. - claude/constants.go: DefaultCacheControlTTL = "5m" - apicompat/types.go: new AnthropicCacheControl type with TTL field; AnthropicTool gains optional CacheControl pointer so the mimicry path can attach a cache breakpoint to tools[-1] later. - service/gateway_service.go: anthropicCacheControlPayload gains TTL; marshalAnthropicSystemTextBlock and rewriteSystemForNonClaudeCode emit ttl=5m by default. -
keh4l authored
The previous commit added FullClaudeCodeMimicryBetas() but the two call sites in buildUpstreamRequest still hardcoded the old 3-token subset. Anthropic now checks the complete set of beta tokens to decide if a request qualifies as Claude Code. Wire them up: - /v1/messages mimic path: requiredBetas = FullClaudeCodeMimicryBetas() - /v1/messages/count_tokens mimic path: same + BetaTokenCounting Haiku models keep the 2-token exemption (BetaOAuth + InterleaveThinking).
-
keh4l authored
Before: the OpenAI-compat forwarders only called injectClaudeCodePrompt, which prepends the Claude Code banner but leaves the rest of the body in its original non-Claude-Code shape. The codebase already admits this is insufficient (see the comment on rewriteSystemForNonClaudeCode in gateway_service.go: "仅前置追加 Claude Code 提示词无法通过检测"). Effect: OAuth accounts served through /v1/chat/completions or /v1/responses were detected as third-party apps and bled plan quota with: Third-party apps now draw from your extra usage, not your plan limits. Fix: - apicompat.AnthropicRequest: add Metadata json.RawMessage so metadata survives the OpenAI->Anthropic->Marshal round trip; without it the downstream rewrite has no user_id to work with. - service: extract applyClaudeCodeOAuthMimicryToBody, a ParsedRequest-free variant of the /v1/messages mimicry pipeline (rewriteSystemForNonClaudeCode + normalizeClaudeOAuthRequestBody + metadata.user_id injection) so the OpenAI-compat forwarders can reuse it. - service: add buildOAuthMetadataUserIDFromBody + hashBodyForSessionSeed for the same reason (no ParsedRequest at the call site). - ForwardAsChatCompletions / ForwardAsResponses: replace the 3-line prompt-prepend with the full mimicry pipeline. - applyClaudeCodeMimicHeaders: set x-client-request-id per-request (real Claude CLI always does); missing/duplicated values are one more third-party fingerprint signal. No change to the native /v1/messages path: it already called the full pipeline, we only lift those helpers into a reusable function. Tests: - go build ./... passes - go test ./internal/service/... ./internal/pkg/apicompat/... passes - lsp_diagnostics clean on all touched files - pre-existing failures in internal/config are unrelated (env-sensitive tests that also fail on upstream main) -
keh4l authored
Align Claude Code mimicry constants with the latest real CLI traffic (see Parrot's src/transform/cc_mimicry.py). Anthropic now uses the full set of anthropic-beta tokens to decide whether a request counts as "official Claude Code"; requests missing tokens that real CLI ships today are demoted to third-party usage: Third-party apps now draw from your extra usage, not your plan limits. Changes: - claude/constants.go: add new beta tokens (prompt-caching-scope, effort, redact-thinking, context-management, extended-cache-ttl) and expose FullClaudeCodeMimicryBetas() for the OAuth mimicry path. - claude/constants.go: bump default User-Agent to claude-cli/2.1.92. - identity_service.go: bump defaultFingerprint User-Agent accordingly. No behavioral change for clients that already send a newer UA (fingerprint merge still prefers the incoming value). -
github-actions[bot] authored
-
shaw authored
-
shaw authored
In reconstructResponseOutputFromSSE, text content Marshal/Unmarshal failure previously caused an early return that silently discarded already-extracted image_generation_call outputs. Now serialization errors are tolerated so image results still reach the client.
-
Wesley Liddick authored
fix(openai): 完善 Codex 在 Responses 链路下的图片生成兼容性
-
Wesley Liddick authored
feat(monitor): channel monitor with available channels & feature flags
-
- 23 Apr, 2026 31 commits
-
-
erio authored
-
erio authored
-
erio authored
-
erio authored
- Change overall status logic: >50% failed = UNAVAILABLE, any failed or degraded = DEGRADED, all ok = OPERATIONAL - Extract useAutoRefresh composable with localStorage persistence - Create AutoRefreshButton dropdown component (reusable) - Integrate auto-refresh into channel status page via MonitorHero
-
gaoren002 authored
-
erio authored
# Conflicts: # backend/cmd/server/wire_gen.go
-
erio authored
-
erio authored
-
erio authored
Revert payment/wechat, sora/claude-max cleanup, fork-only migrations, and cosmetic changes that were brought in by the release sync commit. Keep only channel-monitor related improvements: - PublicSettingsInjectionPayload named struct with drift test - ChannelMonitorRunner graceful shutdown in wire - image_output_price in SupportedModelChip - Simplified buildSelfNavItems in AppSidebar - Gateway WARN logs for 503 branches
-
erio authored
-
erio authored
HelpTooltip.spec.ts and PaymentProviderDialog.spec.ts were removed in release/custom-0.1.115; commit the deletion.
-
erio authored
- Extract PublicSettingsInjectionPayload named struct with drift test - Add channel_monitor_default_interval_seconds to SSR injection - Add image_output_price to SupportedModelChip - Simplify AppSidebar buildSelfNavItems (admins see available channels) - Add gateway WARN logs for 503 no-available-accounts branches - Wire ChannelMonitorRunner into provideCleanup for graceful shutdown - Add migrations 130/131 (CC template userid fix + mimicry field cleanup) - Clean up fork-only features (sora, claude max simulation, client affinity) - Remove ~320 obsolete i18n keys - Add codexUsage utility, WechatServiceButton, BulkEditAccountModal - Tidy go.sum
-
erio authored
Service layer (payment_fulfillment_order_not_found_test.go): - TestHandlePaymentNotification_UnknownOrder_ReturnsSentinel: in-memory sqlite ent client, query for a non-existent out_trade_no → errors.Is must recognise ErrOrderNotFound (handler relies on this to ack 200). - TestHandlePaymentNotification_NonSuccessStatus_Skips: non-success notification short-circuits before DB lookup → nil error. - TestErrOrderNotFound_DistinctFromOtherErrors: generic errors must not match the sentinel (prevents silently swallowing DB failures). Handler layer (payment_webhook_handler_test.go): - TestUnknownOrderWebhookAcksWithSuccess: locks the two ingredients the handleNotify ack path depends on — fmt.Errorf %w wrapping preserves errors.Is recognition, and writeSuccessResponse(stripe) returns an empty 200 body that Stripe treats as acknowledged.
-
erio authored
Introduce a sentinel ErrOrderNotFound in the payment service layer so the webhook handler can distinguish "the out_trade_no does not exist in our DB" from other fulfillment failures, and downgrade the former to a WARN log + success response. Background - Providers (Stripe, Alipay, Wxpay, EasyPay, ...) retry webhooks whenever we answer non-2xx. When a webhook endpoint is misconfigured (e.g. a foreign environment points at us) or our orders table has been wiped, we return 500 forever and the provider retries for days, spamming logs. - The old code also collapsed "order not found" and "DB query failed" into the same branch — a DB blip would be reported as "order not found" and swallowed. Service layer (payment_fulfillment.go) - Add `var ErrOrderNotFound = errors.New("payment order not found")`. - In HandlePaymentNotification, distinguish the two error paths: * dbent.IsNotFound(err) → wrap with ErrOrderNotFound so callers can errors.Is(...) it. * anything else → wrap the original err with %w so it still bubbles up as 500 and the provider retries (DB hiccup should be retried). Handler layer (payment_webhook_handler.go) - Before returning 500, check errors.Is(err, service.ErrOrderNotFound): emit a WARN (with provider / outTradeNo / tradeNo for discoverability), then call writeSuccessResponse so the provider sees its expected 2xx body (Stripe empty body / Wxpay JSON / others "success"). - Other errors retain the existing 500 behavior. Monitoring note: because this path now swallows unknown-order webhooks silently from the provider's perspective, the WARN log line is the only signal. Alert on "unknown order, acking to stop retries" if you want visibility into misrouted webhooks or accidental data loss. -
erio authored
featureFlags.ts registry uses 'available_channels_enabled' as a public-settings key, but the PublicSettings TS type (types/index.ts) and the app store default (stores/app.ts) only had channel_monitor_enabled. Adds the missing field so pnpm build passes.
-
erio authored
The drift test referenced service.PublicSettingsInjectionPayload, a named type introduced by a5b05538 but dropped when we cherry-picked that commit into feat/channel-insights (we kept the inline struct from HEAD to avoid pulling fork-only helpers from setting_service.go). The test therefore could not compile. The 2 new public-settings fields (channel_monitor_enabled, available_channels_enabled) are still covered by manual wiring in GetPublicSettingsForInjection.
-
github-actions[bot] authored
-
shaw authored
Use ${VERSION} (without v prefix) instead of ${TAG_NAME} to match GoReleaser's actual Docker image tags. -
shaw authored
-
Wesley Liddick authored
fix: 明确 OpenAI OAuth 未配置代理时的错误提示
-
Wesley Liddick authored
fix: 修复账户配额跨越时调度快照入队逻辑
-
Wesley Liddick authored
feat(rpm): RPM 限流模块优化
-
james-6-23 authored
P0: - rpm_override 嵌入 Auth Cache Snapshot,消除每请求 DB 查询 (snapshot v6→v7) - 429 RPM 响应返回 Retry-After 头(当前分钟剩余秒数) P1: - ClearAll 按钮直连 DELETE API,带 loading 防重复 - 新增 GET /admin/users/:id/rpm-status 管理员 RPM 用量查询端点 优化: - checkRPM 从级联互斥改为并行取最严,user.rpm_limit 作为全局硬上限始终生效 - Override/Group 变更后自动失效 auth cache - fail-open 语义不变,Redis 故障不阻塞业务
-
shaw authored
-
Wesley Liddick authored
使用codex的生图接口代替web2api
-
wx-11 authored
-
wucm667 authored
-
wx-11 authored
-
wx-11 authored
-
zhoukailian authored
-
shaw authored
Limit image download and multipart upload reads to 20MB to prevent unbounded memory allocation from abnormal upstream responses.
-