Commit Graph

102 Commits

Author SHA1 Message Date
Luis Pater
2422c6b0f5 Merge pull request #6737 from router-for-me/plugins
fix(cliproxy): apply excluded models to plugin models
2026-10-18 21:05:44 +08:00
Luis Pater
66c2758159 feat(pluginhost): remove max line buffer size limit in stream executor to preserve usage telemetry
- Remove `maxLineBufferSize` constant and associated byte-length checks in plugin executor SSE stream processing.
- Prevent premature flushing and dropping of usage metrics for long SSE lines containing response completion payloads.

Closes: #6725
2026-10-18 17:41:30 +08:00
Luis Pater
a7608a8a25 feat(pluginhost): preserve auth identity and model registration for relative auth paths
- Update `authIDForPath` and path resolution logic to consistently handle relative paths within the auth directory.
- Add robust relative path checking to prevent path mismatch issues during credential saves and model lookups.

Closes: #6722
2026-10-18 17:30:27 +08:00
hkfires
adc436ff87 fix(pluginhost): bind catalog-only plugin models to credentials
Stop RegisterModels from publishing a synthetic plugin client for
plugins without an executor, which advertised their models without
any routable credential and bypassed per-auth model exclusions.

Retain the static catalog only for executor arbitration and
per-auth registration, so public availability now follows active
credentials and their exclusions. Reserve native provider models
before plugin arbitration to preserve native priority, and remove
the now unused model client commit path.
2026-10-18 16:12:11 +08:00
Luis Pater
ad9e456d4a feat(claude): support between_tools thinking disable type and adaptive fallbacks
- Add `DisableType` support to plugin host adapters and registry mappings.
- Route disabled thinking to `between_tools` for models like Claude Sonnet 5.5.
- Fall back to low-effort adaptive thinking for models that reject disabled states.

Closes: #6698
2026-10-17 13:56:34 +08:00
Luis Pater
355fd10e76 feat(pluginhost): add content-addressed shadow copies for dynamic library loading
Closes: #6672
2026-10-16 12:04:22 +08:00
Rat0323
50eaed0d16 feat(pluginapi): expose config field defaults 2026-10-14 20:23:34 +08:00
Luis Pater
fdbc610303 feat(auth): enhance plugin auth handling with multi-auth support and improved state management
- Add support for handling multiple auth records from a single file.
- Preserve plugin-disabled states and prioritize existing auth states when updating.
- Unregister stale auths and associated models to maintain consistency.
- Introduce dynamic auth ID assignment and file-based deduplication for better reliability.
- Improve metadata normalization, priority handling, and file path matching.

Closes: #6551
2026-10-12 20:51:15 +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
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
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
67465884ca fix(pluginhost): detach unselected plugins on config apply
- Automatically detach and shut down plugins that are disabled or unselected during configuration reload
- Unload all active plugins when the plugin system is globally disabled

Closes: #6471
2026-10-09 04:04:08 +08:00
이대희
3b69068e6c fix(translator): stop dropping attachments and empty turns
An attachment a translator could not represent was dropped without a word, and
a turn whose only content was that attachment went upstream as an empty
messages, parts, or input array. The model then answered as if nothing was
attached, or the upstream rejected a request that never named the attachment.

A base64 document now reaches OpenAI as a file part. A file the target cannot
receive, such as container_upload, an OpenAI file_id, or input_audio sent to
Claude, is reported by name so the route answers 400 instead of forwarding an
empty turn. Text beside it still travels.

One rule, ErrIfNothingLeft, decides when to refuse, and RegisterCheckedRequest
carries the refusal on the request envelope. Every executor that translates
checks it before calling upstream. The exported converters keep their []byte
signature, so no caller or sibling test had to change.
2026-10-07 19:21:32 +09:00
Luis Pater
c997cbb58a feat(httpwire): introduce error-aware response flushing helper
- Add `FlushResponse` to prefer error-aware flushing and unwrap wrapped response writers
- Bypass Gin's void `Flush` while maintaining header accounting via `WriteHeaderNow` to keep transport errors observable

Closes: #6332
2026-10-04 17:33:19 +08:00
sususu
ad381435a1 fix(antigravity): coalesce probes and respect plugin model ownership
Check plugin model declarations without executing discovery. Share one per-account refresh worker across registration and periodic triggers, retaining one latest queued snapshot with its publication epoch. Add ownership, coalescing, and stale-publication regression tests.
2026-10-03 21:57:23 +08:00
Luis Pater
8348923a17 feat(pluginhost): add host routing reset cooldown callback
- Add `MethodHostRoutingResetCooldown` RPC callback to plugin ABI and host dispatcher
- Introduce `HostRoutingResetCooldownRequest` and `HostRoutingResetCooldownResponse` in plugin API
- Reset credential quota and cooldown routing state in memory without persisting to token files

Closes: #6274
2026-10-02 23:32:32 +08:00
Luis Pater
8fbf152b5b fix(executor): preserve top-level responses token usage when service tier is present
- Fall back to top-level token usage when Codex response usage contains only service tier metadata
- Propagate parsed service tier while retaining top-level token counts
- Avoid early return during stream usage observation for chunks with zero token counts

Closes: #6261
2026-10-02 16:01:23 +08:00
Luis Pater
3ebee06516 fix(interactions): bridge apply_patch tool calls in responses translation
- Handle apply_patch custom tool call streaming deltas and snapshots for Responses API translation
- Track and resolve step indexes, function call identities, and error states across stream events
- Propagate apply_patch tool input errors and upstream failure states in stream and non-stream responses
2026-10-02 03:49:51 +08:00
Luis Pater
b7f321f2a1 feat(api): support request path overrides and image protocols in model execution
- Add `Path` field to model execution requests and plugin interceptor responses
- Propagate custom request paths through execution metadata
- Allow image models during execution when entry or exit protocol is `openai-image`

Closes: #6196
2026-09-29 22:44:33 +08:00
Luis Pater
5756d76ef3 fix(pluginhost): preserve disabled state in host auth callbacks
- Parse `disabled` field from auth file metadata when listing and registering auth files
- Update auth entry status to disabled when `disabled` flag is set to true
- Generalize boolean parsing helper to support common boolean metadata fields

Closes: #6153
2026-09-27 22:09:13 +08:00
Luis Pater
31f4cfab3f feat: migrate CLIProxyAPI to version 8 2026-09-27 14:42:26 +08:00
hkfires
d9922f0589 feat(config): add v8 configuration API
Introduce the v8 management configuration tree with migration-aware reads and
writes, grouped upstream API-key providers, and independent v8 operational
routes.

Preserve legacy configuration compatibility while ensuring successful v8 writes
migrate layouts, redact JSON TURN secrets, and keep OAuth-only provider
settings from affecting API-key credentials.
2026-09-27 14:16:27 +08:00
Luis Pater
6cd86fb272 feat(auth): support terminal rejection in plugin scheduler
- Add reject flags and reason fields to `SchedulerPickResponse` with snake_case JSON unmarshaling support
- Terminate candidate selection with an auth error when scheduler rejection is flagged
- Normalize rejection response with default error code and reason in the plugin host

Closes: #6130
2026-09-26 21:50:02 +08:00
Luis Pater
5530cbd2a5 fix(auth): preserve attributes and path across plugin refreshes
- Merge existing auth attributes and preserve file path metadata across plugin refreshes
- Avoid overwriting existing source and path attributes during auth data conversion
- Retry file stat during atomic replace to prevent premature removal of known auth files

Closes: #6119
2026-09-25 11:55:21 +08:00
Luis Pater
c9a06ba6f2 fix(interceptors): avoid cloning request body for read-only interceptors
- Share request payload reference during session identity enrichment when original request is unset
- Avoid cloning request payload when interceptors do not mutate the body
- Pass request body directly to handler and conductor interceptors

Closes: #6101
2026-09-25 00:34:17 +08:00
sususu
107d7f76c9 fix(translator,auth): avoid synthetic bypass on unsigned text parts and reduce stream rewrite log noise
- In gemini_openai-responses_request.go, do not attach 'skip_thought_signature_validator' to visibleText or thought parts when there is no genuine signature to replay.
- In response_model_rewriter.go, track rewritten model paths per stream to emit a single start debug log and a final summary upon stream completion, avoiding hot-path per-chunk log flooding.
2026-09-24 18:59:13 +08:00
Luis Pater
c404af96eb fix(auth): preserve file priority across plugin auth refreshes
- Introduce `AttributeFilePriority` and helper to track priority inherited from auth files
- Preserve file-configured priority attributes and metadata in plugin host during auth refresh
- Apply file priority metadata consistently across synthesizer, token filestore, and management handlers

Closes: #6089
2026-09-24 08:09:21 +08:00
Luis Pater
855a722349 feat(pluginhost): add host http operation bridge and lifecycle scoping
- Introduce `hostHTTPOperationBridge` to manage, claim, and cancel host HTTP operations with scoped cleanups
- Scope HTTP operations and streams to specific plugin instances to isolate lifecycles and prevent cross-plugin access
- Add RPC handlers for `MethodHostHTTPOperationOpen` and `MethodHostHTTPCancel`
- Link operation cancellation and resource cleanup to host callback contexts and stream termination

Closes: #6085
2026-09-24 06:08:51 +08:00
Luis Pater
2fe9932bb9 feat(usage): track execution request ID and trace ID across usage records
- Add `RequestID` (unique execution UUID) and `TraceID` (inbound request ID) fields to usage records and plugin API
- Generate unique UUIDs per model attempt in `UsageReporter` while linking to parent trace context
- Expose `execution_id` and `trace_id` in Redis queue usage payloads while preserving legacy `request_id`
2026-09-23 19:31:39 +08:00
Luis Pater
d582067c06 feat(executor): support execution-scoped request proxy overrides
- Add context helpers to manage execution-scoped proxy overrides
- Prioritize request proxy over credential and global proxy settings across HTTP and uTLS clients
- Propagate request proxy in conductor execution and plugin host adapters
- Isolate Codex WebSocket connection reuse by proxy endpoint

Closes: #6013
2026-09-22 03:54:34 +08:00
Luis Pater
ac3849e5d9 feat(pluginapi): propagate response model, service tier, and stream flag to usage plugins
- Add `ResponseServiceTier`, `ResponseModel`, and `Stream` fields to `pluginapi.UsageRecord`
- Propagate upstream response model, service tier, and stream status in usage translation adapter

Closes: #6008
2026-09-21 21:47:59 +08:00
Luis Pater
1c87874966 fix(pluginhost): preserve http status codes in host callback and execution errors
- Introduce `modelExecutionStatusError` to retain explicit HTTP status codes on model execution errors
- Propagate HTTP status codes from callback errors across Unix and Windows host callback dispatchers
- Update `marshalRPCError` to encode HTTP status codes into error envelopes using `pluginabi.NewErrorEnvelope`

Closes: #5970
2026-09-20 00:23:42 +08:00
Luis Pater
b715526add feat(plugin): support scheduling across priorities
- Add `SchedulerAcrossPriorities` capability to allow plugin schedulers to receive candidates across all priority tiers.
- Propagate scheduler priority preferences through the plugin host and RPC capabilities.
- Update auth manager selection logic to supply candidates across all priorities when the scheduler opts in.

Closes: #5894
2026-09-17 21:21:56 +08:00
Luis Pater
748d576731 feat(pluginhost): propagate forced provider and auth ID in host model execution
- Add `ForcedProvider` and `AuthID` fields to `HostModelExecutionRequest` and `ModelExecutionRequest`.
- Pin credentials via `WithPinnedAuthID` and forward forced provider options during model execution and streaming.
- Forward forced provider and auth ID from plugin host callbacks to model execution handlers.

Closes: #5814
2026-09-14 21:59:32 +08:00
Luis Pater
6ba444557c feat(pluginabi): support HTTP status code propagation in plugin error envelopes
- Add `Error.Error`, `Error.StatusCode`, `NewError`, and `NewErrorEnvelope` helpers in `sdk/pluginabi`.
- Support extracting and forwarding HTTP status codes in Go plugin executor examples and generator script.
- Document plugin executor error handling and client HTTP status mapping conventions.

Closes: #5809
2026-09-14 18:44:04 +08:00
Luis Pater
b8477c7181 fix(pluginhost): keep request and method buffers alive during native call
- Ensure `methodBytes` and `request` are kept alive across dynamic library invocation on Windows to prevent premature garbage collection.

Closes: #5807
2026-09-14 17:32:33 +08:00
sususu
0719520f2a feat(api-call): support $TOKEN$ replacement in request body data 2026-09-14 09:20:03 +08:00
Luis Pater
3c3938feb1 feat(plugins): forward query parameters as metadata in auth provider start login
- Accept optional metadata parameters in SDK and internal plugin host `StartLogin` methods.
- Clone and pass metadata to the auth provider's `AuthLoginStartRequest`.
- Convert management auth URL query parameters into metadata before initiating plugin login flows.

Closes: #5760
2026-09-12 20:05:34 +08:00
Luis Pater
b192f6550c feat(management): add plugin quota and declarative probe endpoints
- Add endpoints to list quota providers and fetch or reset credential quotas via plugins.
- Support declarative metadata quota probes with token substitution and response mapping.
- Clear core routing quota state when provider quota reset succeeds.

Closes: #5752
2026-09-12 19:07:43 +08:00
Luis Pater
c8f723e0fb feat(usage): propagate upstream base_url across usage records and plugin auth
- Add `BaseURL` field to usage records and host auth file entries.
- Extract `base_url` from auth attributes and metadata during usage reporting.
- Propagate `base_url` through plugin usage adapters and runtime auth callbacks.

Closes: #5693
2026-09-11 00:25:17 +08:00
Luis Pater
0796d6d133 feat(plugin): add host session affinity lookup callback
- Decode and validate host affinity lookup requests for provider, model, and session ID.
- Query the active auth manager for session affinity bindings and status.
- Return lookup responses containing the auth index, observation timestamp, and credential availability state.

Closes: #5604
2026-09-09 03:25:42 +08:00
Luis Pater
c6327a86c9 feat(plugin): preserve raw json in management responses on schema version 6
- Bump plugin ABI `SchemaVersion` to 6 and add `SchemaVersionRawManagementResponse`.
- Skip HTML entity escaping for plugin management JSON responses on schema version 6 and above.
- Retain legacy HTML escaping behavior for plugins with schema versions prior to 6.

Closes: #5605
2026-09-09 00:45:45 +08:00
Luis Pater
00c63a5669 feat(pluginhost): expose outbound HTTP wire profile to plugin requests
- Add HTTPWireProfile to sdk/pluginapi on HTTPRequest with wire_profile JSON tag
- Decode wire_profile in host callbacks for flat and nested RPC payloads
- Match header casing in httpwire ordered_conn and allow non-HTTP handshakes
- Apply wire profile settings (HTTP/1.1 enforcement, auto compression disable, header ordering) in plugin host HTTP client
- Preserve proxy configuration, custom TLS dialers, redirect handling, and connection lifecycle

Closes: #5062
2026-09-06 20:41:58 +08:00
sususu
580df36423 feat(usage): propagate session and parent session hierarchy to usage reporting queue
- Reuse coresession.ExtractSessionInfo across HTTP headers and request payloads to unify canonical session prefix namespaces with the scheduler.
- Extract hierarchical session identities in two phases: initial extraction from request headers on entry, and authoritative deep extraction once request payloads and metadata are available.
- Support Claude Code multi-level subagents (X-Claude-Code-Agent-Id, metadata.agent_id) and Codex thread fork lineages.
- Propagate SessionID and ParentSessionID across ClientRequestMetadata, UsageReporter, and coreusage.Record without root_session_id.
- Include session_id and parent_session_id in queuedUsageDetail for Home LPushUsage forwarding and Redis consumption with self-loop guards.
- Add comprehensive test coverage for canonical headers, body extraction, ghost parent elimination, and self-referential loop guards.
2026-09-06 10:45:32 +08:00
Luis Pater
649a8bdb6f feat(plugin): omit stream chunk history on payload chunks for schema v5
- Bump plugin schema version to 5 and introduce `SchemaVersionStreamChunkOmitHistory`.
- Omit `HistoryChunks` on payload stream chunks for schema version 5+ to avoid per-chunk cloning and serialization overhead.
- Conditionally accumulate and clone history chunks only when legacy plugins with schema version < 5 are active.

Closes: #5451
2026-09-04 01:19:50 +08:00
Luis Pater
02c02cda50 fix: harden concurrent session handling, listener lifecycle, and token accounting
- Use `context.AfterFunc` and buffered delivery in websocket relay sessions to avoid per-request goroutine leaks.
- Synchronize in-flight puts and drain queued connections upon mux listener close.
- Ensure home streaming log writer goroutines terminate cleanly when the log client is unhealthy.
- Prevent integer arithmetic overflow in token breakdown validations and calculations.
- Clone request headers in logging middleware to prevent concurrent mutation issues.
- Implement standard `io.WriterTo` return signature for file body sources.

Closes: #4709
2026-09-02 20:02:42 +08:00
Luis Pater
d31b15916d feat(executor): support token usage parsing for plugin executors
- Add `ParsePluginExecutorResponseUsage` to extract token usage from non-streaming plugin responses across Claude, Gemini, Interactions, Antigravity, and OpenAI/Codex protocols.
- Add `ObservePluginExecutorStreamUsage` to observe and aggregate token usage across streaming chunks.

Closes: #5340
2026-08-30 14:51:08 +08:00
hkfires
6a489fa84d fix(auth): prefer errors from upstream attempts
Track when executor calls cross an upstream transport boundary and use that
signal to keep model/provider errors from being replaced by later local
preparation, selection, or internal failures.

Mark HTTP, websocket, relay, and usage-tracked transports as upstream
attempts, while avoiding marks for local validation, logging, missing
sessions, and successful websocket handshakes before request send.

Parse relative auth expiry metadata and adjust Antigravity refresh timing.
2026-08-29 12:50:46 +08:00
Luis Pater
4b5f1eab25 feat(plugin): support observing upstream websocket response events
- Introduce `WebSocketResponseObserver` capability and bump plugin ABI schema version to 4.
- Forward upstream WebSocket response frames from Codex and xAI executors to configured observers.
- Wire `WebSocketResponseObserver` across API handlers and plugin host dispatchers.

Closes: #5248
2026-08-27 05:30:19 +08:00
Luis Pater
b7f6c15f83 fix(pluginhost): detach context and log rpc failures in usage handling
- Detach cancellation from context before dispatching usage records to plugins.
- Log debug messages when RPC `usage.handle` calls fail.

Closes: #5244
2026-08-27 04:35:51 +08:00