mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-21 13:50:51 +08:00
feat(logging, executor): add request logging tests and WebSocket-based Codex executor
- Introduced unit tests for request logging middleware to enhance coverage. - Added WebSocket-based Codex executor to support Responses API upgrade. - Updated middleware logic to selectively capture request bodies for memory efficiency. - Enhanced Codex configuration handling with new WebSocket attributes.
This commit is contained in:
23
sdk/cliproxy/executor/context.go
Normal file
23
sdk/cliproxy/executor/context.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package executor
|
||||
|
||||
import "context"
|
||||
|
||||
type downstreamWebsocketContextKey struct{}
|
||||
|
||||
// WithDownstreamWebsocket marks the current request as coming from a downstream websocket connection.
|
||||
func WithDownstreamWebsocket(ctx context.Context) context.Context {
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
}
|
||||
return context.WithValue(ctx, downstreamWebsocketContextKey{}, true)
|
||||
}
|
||||
|
||||
// DownstreamWebsocket reports whether the current request originates from a downstream websocket connection.
|
||||
func DownstreamWebsocket(ctx context.Context) bool {
|
||||
if ctx == nil {
|
||||
return false
|
||||
}
|
||||
raw := ctx.Value(downstreamWebsocketContextKey{})
|
||||
enabled, ok := raw.(bool)
|
||||
return ok && enabled
|
||||
}
|
||||
@@ -10,6 +10,17 @@ import (
|
||||
// RequestedModelMetadataKey stores the client-requested model name in Options.Metadata.
|
||||
const RequestedModelMetadataKey = "requested_model"
|
||||
|
||||
const (
|
||||
// PinnedAuthMetadataKey locks execution to a specific auth ID.
|
||||
PinnedAuthMetadataKey = "pinned_auth_id"
|
||||
// SelectedAuthMetadataKey stores the auth ID selected by the scheduler.
|
||||
SelectedAuthMetadataKey = "selected_auth_id"
|
||||
// SelectedAuthCallbackMetadataKey carries an optional callback invoked with the selected auth ID.
|
||||
SelectedAuthCallbackMetadataKey = "selected_auth_callback"
|
||||
// ExecutionSessionMetadataKey identifies a long-lived downstream execution session.
|
||||
ExecutionSessionMetadataKey = "execution_session_id"
|
||||
)
|
||||
|
||||
// Request encapsulates the translated payload that will be sent to a provider executor.
|
||||
type Request struct {
|
||||
// Model is the upstream model identifier after translation.
|
||||
|
||||
Reference in New Issue
Block a user