700 Commits

Author SHA1 Message Date
Luis Pater
a8dbebabdf feat(pluginhost): allow plugins to register multiple OAuth login entries
- Add Capabilities.AuthProviders and MultiAuthProvider (Identifiers() []string) in sdk/pluginapi, bump sdk/pluginabi.SchemaVersion to 10, and forward AuthProviders in sdk/pluginhost
- Extend internal/pluginhost to register, expose, and route multiple OAuth login identifiers per plugin across StartLogin, PollLogin, RefreshAuth, ParseAuths, and ExchangeCallback, while preserving per-credential oauth_provider/portal attribution for shared credential providers
- Expose oauth_providers alongside primary oauth_provider in RegisteredPluginInfo and GET /v0/management/plugins, and support target-credential re-login (StartOAuthV8) across sibling portals

Closes: #7126
2026-10-31 20:20:16 +08:00
Luis Pater
514d09f746 feat(codex): guide recovery when automatic credential renewal becomes impossible
- Classify terminal Codex refresh grant failures (`refresh_token_reused`, `refresh_token_expired`, `refresh_token_invalidated`, `token_revoked`, `invalid_client`, `invalid_grant`, and HTTP 401) as non-retryable, track rejected outer and SIWC refresh tokens independently, and defer retry checks until `access_token` expiry while keeping valid access tokens available for inference.
- Expose structured renewal states, recovery stages, sanitized refresh diagnostics, targeted account-matching OAuth re-authentication (`POST /v8/management/oauth/auth-url`), and pinned inference verification (`POST /v8/management/credentials/verify`) across Management API v8 and the TUI.
- Add unit and workflow regression tests covering terminal vs. transient refresh handling, per-partition SIWC/outer isolation, incomplete stream rejection, quota cooldown preservation, and secret redaction.

Closes: #5783
2026-10-30 07:06:33 +08:00
hkfires
a6b4477b4f fix(home): restrict websocket access in home mode
Skip registering the AI Studio websocket gateway in Home
mode since it is not supported there, and force websocket
authentication in the Home runtime config.
2026-10-29 15:48:45 +08:00
Luis Pater
a3e76891b1 refactor(api): reuse response compression encoders and add tests 2026-10-28 10:31:07 +08:00
Luis Pater
f6ee1e64d8 Merge pull request #7022: reuse response compression encoders 2026-10-28 10:21:43 +08:00
JohnsonRan
12f2cafe33 test(api): measure open-stream heap with empty encoder pools
BenchmarkResponseCompressionOpenStreams took its baseline after one GC,
which only moves pooled encoders to the sync.Pool victim cache. Streams
then reused memory the baseline already counted, so heap per open stream
collapsed toward zero once b.N > 1. Run two GC cycles before the baseline
so every sample starts with empty pools.

TestResponseCompressionReusesPooledEncoders now counts encoder creations
and fails when finished encoders are not returned to the pool. It also
interleaves responses whose client writes fail, so an encoder pooled
after an error must still produce correct output.
2026-10-28 04:08:45 +09:00
JohnsonRan
16c6b4bd8c perf(api): reuse response compression encoders with a smaller zstd window
Every compressed response created a new encoder: zstd with its default
8 MiB window allocated about 18 MB, gzip about 1 MB, and an open SSE
stream held that for its whole life. Pool zstd and gzip encoders, and
give zstd a 1 MiB window with lower encoder memory; API responses are
far smaller than the window, so the wire size is unchanged. finish now
returns the encoder to the pool and fails later writes instead of
sending them uncompressed under Content-Encoding.
2026-10-28 03:51:21 +09:00
Luis Pater
65889d39f0 test: update tests for default template changes and environment compatibility
Closes: #7059
2026-10-28 02:34:39 +08:00
Luis Pater
ad8bdd3f20 fix(middleware): bound zstd decompression output and window in request logging
- Cap captured request body zstd decompression to max-request-body-bytes or 32 MiB when no smaller limit is configured, and remove the unbounded decode helpers.
- Restrict the request-log zstd decoder to concurrency 1 and an 8 MiB maximum window so frames declaring oversized windows fall back to logging raw bytes.
- Add regression tests covering unconfigured limits, single-segment window bombs, and oversized zstd windows.

Closes: GHSA-4w5v-m7vx-jpmh
2026-10-27 23:23:26 +08:00
Luis Pater
477605dc6d fix(api): prevent incomplete unauthenticated request bodies from exhausting descriptors
Defer eager request body reads and temporary file creation until after authentication or over the 1 MiB in-memory threshold, expire read deadlines and close connections when responses finish with unconsumed request bodies, bound HTTP header and unauthenticated RESP setup reads, and retry transient EMFILE/ENFILE accept errors with exponential backoff.

Fixes GHSA-j4xx-x47j-7h54
2026-10-27 23:11:21 +08:00
Luis Pater
10417e5b6b feat(registry,management): support on-demand v8 management refresh for model catalogs
- Add on-demand model catalog refresh functions in internal/registry with generation and sequence fencing, policy boundary checks, and immediate provider refresh notifications.
- Expose POST /v8/management/routing/model-definitions/refresh and POST /v8/management/models/refresh to trigger catalog refreshes and report resolved sources and changed providers.

Closes: #7039
2026-10-27 15:32:39 +08:00
Luis Pater
058b803b2c fix(api): explicitly allow Authorization in CORS preflight responses
- Replace the wildcard Access-Control-Allow-Headers value with an explicit list covering Authorization, Content-Type, and the API key and Anthropic headers the API accepts, since Fetch treats Authorization as a non-wildcard request-header name.
- Echo requested headers on preflight responses so arbitrary custom client headers keep working without widening allowed origins or enabling credentials.
- Add real-server preflight regression tests for the models, chat completions, alternative credential, and Anthropic header cases.

Closes: #6999
2026-10-26 16:25:39 +08:00
Luis Pater
064e008b07 feat(codex): add full-chain compression for Codex upstream and downstream traffic
- Compress finalized Codex OAuth request bodies with zstd on the verified ChatGPT backend path, with size/benefit gating, header-body alignment, and one uncompressed retry on 400/415 rejection.
- Negotiate downstream HTTP response compression under server.response-compression (zstd/gzip with q-values, SSE-safe flushing, commit-time Vary merging) and enable negotiated permessage-deflate on Codex and downstream WebSockets.
- Advertise Accept-Encoding to Codex upstreams and decode gzip/deflate/br/zstd upstream responses through a shared decoder before parsing or relaying.

Closes: #6905
2026-10-26 10:09:56 +08:00
Luis Pater
27f3abfb70 feat(management): support session-scoped OAuth proxy with per-account persistence (#6973) 2026-10-25 22:17:45 +08:00
Luis Pater
888f23824d fix(api): add RESP protocol bounds validation and connection panic recovery
- Add explicit bulk string length, array count, and line length limits to prevent integer overflows and buffer exhaustion.
- Enforce cumulative byte budgets on incoming RESP arrays and frame payloads.
- Protect protocol multiplexer and Redis command readers with panic recovery and graceful error handling.
2026-10-24 01:44:17 +08:00
Luis Pater
83cb1b95eb fix(gemini): populate token limits in Gemini model catalog responses
- Populate inputTokenLimit and outputTokenLimit in Home Gemini model responses when positive token limits are available, and backfill missing metadata across duplicate Home catalog entries.
- Fall back to ContextLength and MaxCompletionTokens when converting registry models for the Gemini handler so catalog entries using generic limit fields expose Gemini token limits.

Closes: #6914
2026-10-23 17:09:19 +08:00
Luis Pater
8bd1795599 fix(management): read Handler.cfg under h.mu in OAuth login flows and token save helpers
- Add Handler.configSnapshot to read h.cfg under h.mu for OAuth login handlers and background callback waiters that outlive the request.
- Use configSnapshot in Claude, Codex, and Antigravity OAuth login handlers as well as token persistence helpers to prevent data races with config saves.

Closes: #6871
2026-10-22 20:15:15 +08:00
Luis Pater
b9bb031dcb fix(openai): reauthorize responses websocket turns and support denied status
- Re-run AccessManager authentication before each responses websocket turn and duplex continuation using a cloned POST request with handshake headers stripped.
- Add AuthErrorCodeDenied and NewDeniedError in sdk/access so terminal provider refusals preserve their HTTP status and stop the provider chain.
- Add DenyStatusCode and DenyMessage to pluginapi.FrontendAuthResponse and map explicit plugin denials in accessAdapter.Authenticate.

Closes: #6843
2026-10-22 03:41:06 +08:00
Luis Pater
0db1902557 fix(codex): use original oauth credentials for alpha search
- Select the original OAuth partition for ChatGPT Alpha Search without changing SIWC Responses behavior.
- Reject missing original OAuth tokens before sending and preserve existing API-key and custom-header behavior.
- Add real-executor transport and API regression coverage for credential partition isolation.

Closes: #6830
2026-10-21 23:04:23 +08:00
Luis Pater
06fd5b8bc2 feat(management): add read-only SIWC credential status endpoint
- Persist the real SIWC token expiration time from expires_in and evaluate local SIWC status using real expiration (or JWT exp) and upstream 401 rejection state without triggering network requests.
- Track SIWC token rejections independently from outer Codex OAuth refreshes, execution retries, and use_siwc toggles until the SIWC token is replaced.
- Expose the read-only v8 management SIWC status endpoint and summary field for Codex credentials.

Closes: #6819
2026-10-21 08:07:38 +08:00
Luis Pater
88041f0cfb fix(auth): serialize legacy auth-file uploads with SIWC bind commits
- Acquire the Codex file lock around in-place disk writes in writeAuthFile when writing or replacing Codex credentials, and resolve symlinked paths in canonicalLockPath so upload and bind paths share the same lock.
- Verify in BindCodexSIWC before atomic replacement that the backing file bytes on disk still match the initial read, preventing uncooperative in-place rewrites from being silently overwritten.
- Add regression tests covering in-place rewrites during SIWC bind commits and legacy uploads contending on the Codex file lock.

Closes: #6811
2026-10-21 01:09:40 +08:00
Luis Pater
6bbd2cb785 fix(auth): fence SIWC bind commits against replaced credential accounts
- Record the target credential's start-time account ID in the SIWC bind session and validate disk consistency before starting authorization.
- Require BindCodexSIWC to match the start-time account against both the live in-memory credential and the backing file before persisting SIWC tokens.
- Add unit and management handler regression tests covering account replacement via legacy uploads and watcher updates during active SIWC binds.

Closes: #6809
2026-10-21 00:24:22 +08:00
Luis Pater
bb2d8f82bc fix(auth): resolve relative SIWC binding paths against working directory
- Resolve relative path and source attributes against the current working directory in codexBindingPath instead of re-joining them with auth-dir, keeping the auth-dir join only for bare FileName fallbacks.
- Normalize relative auth-dir and credential paths to absolute paths before symlink evaluation in codexBindingPath and resolveSIWCBindFile so confinement checks remain consistent when working directory ancestors contain symlinks.

Closes: #6805
2026-10-21 00:05:04 +08:00
Supra4E8C
ae3ee3be30 fix(management): reject legacy SIWC callbacks and symlink targets 2026-10-20 00:55:07 +08:00
Supra4E8C
d50a1995ce feat(management): add v8 SIWC credential binding 2026-10-20 00:38:04 +08:00
Luis Pater
3bbd1652be Merge pull request #6765 from router-for-me/models
fix(api): allow empty home model catalog
2026-10-19 12:26:16 +08:00
hkfires
4d34502f07 fix(api): reject home models error envelopes
Reject any home models payload containing an error key before
parsing provider sections. Array-shaped error values were
previously treated as model sections, masking upstream errors
as valid or empty catalogs instead of returning an error.
2026-10-19 12:11:57 +08:00
hkfires
07feedf7b7 fix(api): allow empty home model catalog
Return an empty catalog when home returns no model records, e.g.
when the client's access scopes have no routes, instead of erroring.
Still reject null payloads, null sections, and non-empty sections
with no usable model IDs as malformed.
2026-10-19 10:30:30 +08:00
Luis Pater
50cfd2380f feat(management): add support for static and plugin model definitions retrieval by channel
- Implement fallback logic in model definitions handler to query plugin host and global registry for unknown channels.
- Add sorting for registry model definitions by provider and ID to ensure consistent responses.

Closes: #6736
2026-10-19 00:23:19 +08:00
Luis Pater
d69962e40c feat(management): add safe Modify method for auth records with epoch validation and locking
- Implement `Modify` method on auth manager to load, clone, edit, and commit records atomically under a per-auth mutation lock.
- Refactor auth field patches and status updates to use the new `Modify` API, preventing race conditions and lost concurrent updates.
- Add comprehensive test coverage verifying concurrent patch operations, token refreshes, removals, and epoch checks.

Closes: #6733
2026-10-18 23:00:32 +08:00
hkfires
3e309fb474 fix(auth): preserve plugin excluded models on synthesis
Stop clearing existing excluded_models attributes in
ApplyAuthExcludedModelsMeta so plugin-provided rules survive
when an auth file defines none; callers rebuilding attributes
must drop stale values first, as PatchAuthFileFields now does.

Also reject config-sourced credentials in PatchAuthFileFields
with 404 and require excluded_models to be a string array or
null, rejecting legacy comma-separated string forms.
2026-10-18 11:53:43 +08:00
hkfires
1a28c61e56 fix(auth): tolerate invalid excluded models on load
Keep existing credentials loading when excluded_models is invalid
instead of dropping them, warning and retaining only valid string
entries. Reject invalid rules at write entry points instead: auth
file uploads now validate before persisting and return 400, and
PATCH validates via the same extractor, accepting the legacy
comma-separated string form and persisting it as a canonical array.

Add regression coverage that a fence-dropped model registration is
replaced by applyConfigRuntime re-registration in Home mode.
2026-10-18 11:53:42 +08:00
hkfires
94d1a9a046 Refactor authentication exclusion handling and improve model registration
- Simplified the ApplyAuthExcludedModelsMeta function to focus solely on credential-specific exclusions, removing unnecessary configuration dependencies.
- Updated tests to reflect changes in the exclusion handling logic, ensuring that credential-level exclusions take precedence over global configurations.
- Removed the metadata_exports.go file as it was no longer needed.
- Enhanced model registration logic to maintain global exclusion summaries and prevent obsolete configurations from affecting new registrations.
- Introduced new tests to verify that global exclusions are retained after authentication updates and that irrelevant config reloads do not discard valid registrations.
- Improved the handling of plugin model providers to ensure that exclusion rules are correctly applied and updated.
2026-10-18 11:52:09 +08:00
Supra4E8C
b015f208d2 fix(oauth): restore credential exclusion priority 2026-10-18 11:34:11 +08:00
Luis Pater
fa68946ad5 feat(management): add optimistic concurrency control with ETag and If-Match to v8 config endpoints
- Implement ETag generation using SHA-256 source hashes on v8 management config reads.
- Enforce RFC 9110 If-Match validation on mutating requests to prevent stale overwrites.
- Expose ETag headers for CORS and mask sensitive `value` query parameters in request logs.

Closes: #6666
2026-10-16 07:20:24 +08:00
Luis Pater
1631875b9a fix(watcher): guard management saves against stale config reloads and serialize file updates
- Add `SourceHash` tracking to config parsing to identify stale config file reloads.
- Reject reloads in management handlers and watchers if they are based on an older file snapshot.
- Serialize concurrent config reloads and secure lock handling in basic/list management endpoints.

Closes: #6631
2026-10-15 09:56:31 +08:00
Luis Pater
345cc9d5a8 feat(claude): add timeout and retry logic for silent TLS handshakes
Closes: #6615
2026-10-14 20:23:35 +08:00
Rat0323
50eaed0d16 feat(pluginapi): expose config field defaults 2026-10-14 20:23:34 +08:00
Luis Pater
81573f0429 fix(server): prevent data races during concurrent config access and reloads
- Access configuration safely via getters across server routes, middleware, and service routines.
- Clone configuration snapshots for runtime and synchronize access in management handlers.
- Guard configuration YAML snapshots with mutex locks during reloads.

Closes: #6592
2026-10-14 05:07:44 +08:00
Luis Pater
e235fb3d64 fix(server): prevent data races during concurrent config access and reloads
- Access configuration safely via getters across server routes, middleware, and service routines.
- Clone configuration snapshots for runtime and synchronize access in management handlers.
- Guard configuration YAML snapshots with mutex locks during reloads.

Closes: #6559
2026-10-13 07:04:51 +08:00
Luis Pater
dd7b433492 feat(server): support max-request-body-bytes request body limit
Closes: #6550
2026-10-12 20:21:50 +08:00
hkfires
3d61c9542c fix(management): conditionally expose quota_plugin_id for v8 auth files 2026-10-12 16:17:50 +08:00
hkfires
0c7084019b fix(management): resolve v8 plugin quota contract gaps
Expose quota_plugin_id on credential entries using the host's two-pass selection precedence, excluding fused plugins and selecting healthy alternatives.

Stop advertising declarative quota_probe support in v8 while preserving v0 behavior. Add regression tests for selection precedence, plugin fusion, and version-specific quota metadata.

Fixes #6519
2026-10-12 15:50:00 +08:00
Luis Pater
03a3cfecb5 feat(claude): honor upstream.claude.tool-search in executor, catalog and server 2026-10-11 14:08:49 +08:00
Luis Pater
11f04c2077 feat(codex): advertise tool search only for natively supported Claude routes 2026-10-11 11:09:17 +08:00
gitrvc-hub
a68ad1344f fix(claude): address tool_search review findings
Enable deferred filtering only when the client tool_search declaration
wins the tool_search name, so a same-named user function keeps the
deferred tools. Pass Home catalog provider routes to the search
capability check so Claude-only Home models advertise tool search.
2026-10-10 15:30:40 -04:00
Luis Pater
37fe2608ee feat(usage): propagate access provider and native key metadata to usage records
- Inject API key, access provider, and native key flags into the request context during authentication
- Add `IsNativeKey` and `AccessProvider` fields to usage records, plugin API types, and redis queue payloads
- Provide context helper functions and automatic fallback resolution in the usage manager and reporter

Closes: #6509
2026-10-10 22:16:00 +08:00
Luis Pater
0a23627d22 fix(config): normalize collection styles and unquote mapping keys in v8 api
- Export `NormalizeCollectionNodeStyles` to traverse document nodes and clear double quotes from string mapping keys
- Apply collection style normalization before YAML marshaling in the v8 management config handler

Closes: #6451
2026-10-08 13:20:41 +08:00
Supra4E8C
7c41cd05e4 feat: add global server GitHub token configuration 2026-10-08 00:33:27 +08:00
luohui1
6a853dce05 feat(xai): expose Grok TTS on /v1/audio/speech
Route OpenAI speech requests to the official xAI /tts endpoint and register grok-tts and grok-voice-tts-1.0.
2026-10-06 02:49:21 -07:00