executor

package
v0.0.57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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"
	// DerivedSessionIDMetadataKey stores a stable session identity inferred from request context.
	DerivedSessionIDMetadataKey = "derived_session_id"
	// SessionAffinityProviderMetadataKey carries the affinity selection namespace
	// (provider string, e.g. the literal "mixed" pool key) used by SessionAffinitySelector.Pick,
	// so OnResult keys the session cache identically to how selection read it.
	SessionAffinityProviderMetadataKey = "session_affinity_provider"
	// SessionAffinityModelMetadataKey carries the model used during session affinity selection.
	SessionAffinityModelMetadataKey = "session_affinity_model"
	// LCPAffinitySessionIDMetadataKey stores an LCP-only routing identity.
	LCPAffinitySessionIDMetadataKey = "lcp_affinity_session_id"
	// CanonicalSessionIDMetadataKey stores the single unified session identity reconciled.
	CanonicalSessionIDMetadataKey = "canonical_session_id"
	// ParentSessionIDMetadataKey stores the parent session identity for hierarchical sessions and forks.
	// For top-level Merkle LCP forks, it represents the deterministic Merkle prefix hash at the divergence point.
	ParentSessionIDMetadataKey = "parent_session_id"
	// IsForkMetadataKey indicates whether the request represents a conversational branch or fork.
	IsForkMetadataKey = "is_fork"
	// IsCompactionMetadataKey indicates whether the request represents a context compaction continuation.
	IsCompactionMetadataKey = "is_compaction"
	// NodeKindMetadataKey indicates the session DAG topology kind ("compaction", "fork", or "trunk").
	NodeKindMetadataKey = "node_kind"
	// LCPTailFingerprintsMetadataKey stores the actual trailing turn fingerprints for context compaction matching.
	LCPTailFingerprintsMetadataKey = "lcp_tail_fingerprints"
	// LCPEnvironmentDigestMetadataKey stores the environment digest across all system and developer instructions.
	LCPEnvironmentDigestMetadataKey = "lcp_environment_digest"
	// LCPAccessGenerationMetadataKey stores the monotonic access generation when an LCP entry was touched or bound.
	LCPAccessGenerationMetadataKey = "lcp_access_generation"
	// LCPFingerprintMetadataKey stores bounded request-scoped turn fingerprints.
	LCPFingerprintMetadataKey = "lcp_fingerprints"
	// LCPMinPrefixLengthMetadataKey stores the minimum eligible prefix boundary.
	LCPMinPrefixLengthMetadataKey = "lcp_min_prefix_length"
	// CallerScopeMetadataKey isolates inferred session identities between downstream callers.
	CallerScopeMetadataKey = "caller_scope"
)
View Source
const AuthSelectionModelMetadataKey = "auth_selection_model"

AuthSelectionModelMetadataKey overrides the model used only for auth selection. Restored execution requests carry the upstream execution model in Request.Model while this key keeps the original selection model for auth picking (upstream parity).

View Source
const DisallowFreeAuthMetadataKey = "disallow_free_auth"

DisallowFreeAuthMetadataKey instructs auth selection to skip known free-tier credentials.

View Source
const ReasoningEffortMetadataKey = "reasoning_effort"

ReasoningEffortMetadataKey stores the client-requested reasoning effort for usage logs.

View Source
const RequestPathMetadataKey = "request_path"

RequestPathMetadataKey stores the inbound HTTP request path (e.g. "/v1/images/generations") in Options.Metadata. It is optional and may be absent for non-HTTP executions.

View Source
const RequestedModelMetadataKey = "requested_model"

RequestedModelMetadataKey stores the client-requested model name in Options.Metadata.

Variables

This section is empty.

Functions

func AuthorizeWebsocketTurn added in v0.0.56

func AuthorizeWebsocketTurn(ctx context.Context, payload []byte) ([]byte, error)

func BindExecutionResource added in v0.0.21

func BindExecutionResource(opts Options, closer io.Closer) error

BindExecutionResource binds a closer to the execution lifecycle.

func CodexCloakingDisabled added in v0.0.23

func CodexCloakingDisabled(ctx context.Context) bool

CodexCloakingDisabled reports whether Codex identity cloaking is disabled for this request.

func DownstreamWebsocket

func DownstreamWebsocket(ctx context.Context) bool

DownstreamWebsocket reports whether the current request originates from a downstream websocket connection.

func IsUpstreamWebsocketReplayRequired added in v0.0.42

func IsUpstreamWebsocketReplayRequired(err error) bool

IsUpstreamWebsocketReplayRequired reports whether err is the internal replay signal.

func NewUpstreamWebsocketReplayRequiredError added in v0.0.42

func NewUpstreamWebsocketReplayRequiredError() error

NewUpstreamWebsocketReplayRequiredError creates a request-scoped replay signal.

func ResponseFormatOrSource added in v0.0.39

func ResponseFormatOrSource(opts Options) sdktranslator.Format

ResponseFormatOrSource returns the response target format for an execution. Ported from upstream CLIProxyAPI sdk/cliproxy/executor/types.go.

func WebsocketAuthEnabled added in v0.0.42

func WebsocketAuthEnabled(ctx context.Context, authID string) bool

func WebsocketInputFromContext added in v0.0.42

func WebsocketInputFromContext(ctx context.Context) <-chan WebsocketInput

func WithCodexCloakingDisabled added in v0.0.23

func WithCodexCloakingDisabled(ctx context.Context) context.Context

WithCodexCloakingDisabled marks the current request as disabling Codex identity cloaking.

func WithDownstreamWebsocket

func WithDownstreamWebsocket(ctx context.Context) context.Context

WithDownstreamWebsocket marks the current request as coming from a downstream websocket connection.

func WithWebsocketAuthCheck added in v0.0.42

func WithWebsocketAuthCheck(ctx context.Context, check func(string) bool) context.Context

func WithWebsocketInput added in v0.0.42

func WithWebsocketInput(ctx context.Context, input <-chan WebsocketInput) context.Context

func WithWebsocketTurnAuthorizer added in v0.0.56

func WithWebsocketTurnAuthorizer(ctx context.Context, authorize func([]byte) ([]byte, error)) context.Context

Types

type ExecutionLifecycle added in v0.0.21

type ExecutionLifecycle interface {
	Bind(func() error) error
	End(string)
}

ExecutionLifecycle owns resources associated with an execution attempt.

type Options

type Options struct {
	// Stream toggles streaming mode.
	Stream bool
	// Alt carries optional alternate format hint (e.g. SSE JSON key).
	Alt string
	// Headers are forwarded to the provider request builder.
	Headers http.Header
	// Query contains optional query string parameters.
	Query url.Values
	// OriginalRequest preserves the inbound request bytes prior to translation.
	OriginalRequest []byte
	// SourceFormat identifies the inbound schema.
	SourceFormat sdktranslator.Format
	// ResponseFormat identifies the downstream response schema.
	// When empty, SourceFormat is used as the response target.
	ResponseFormat sdktranslator.Format
	// Metadata carries extra execution hints shared across selection and executors.
	Metadata map[string]any
	// ExecutionLifecycle owns Home-dispatched execution resources. Executors must not add it to request metadata.
	ExecutionLifecycle ExecutionLifecycle
	// KeepTopLevelEffort tells SIWC request-body rules to keep the resolved
	// top-level reasoning.effort when configuration_update items are collapsed.
	KeepTopLevelEffort bool
}

Options controls execution behavior for both streaming and non-streaming calls.

func (*Options) EnsureMetadata added in v0.0.25

func (o *Options) EnsureMetadata() map[string]any

EnsureMetadata initializes and returns Metadata, ensuring it is non-nil.

type Request

type Request struct {
	// Model is the upstream model identifier after translation.
	Model string
	// Payload is the provider specific JSON payload.
	Payload []byte
	// Format represents the provider payload schema.
	Format sdktranslator.Format
	// Metadata carries optional provider specific execution hints.
	Metadata map[string]any
}

Request encapsulates the translated payload that will be sent to a provider executor.

type Response

type Response struct {
	// Payload is the provider response in the executor format.
	Payload []byte
	// Metadata exposes optional structured data for translators.
	Metadata map[string]any
	// Headers carries upstream HTTP response headers for passthrough to clients.
	Headers http.Header
}

Response wraps either a full provider response or metadata for streaming flows.

type StatusError

type StatusError interface {
	error
	StatusCode() int
}

StatusError represents an error that carries an HTTP-like status code. Provider executors should implement this when possible to enable better auth state updates on failures (e.g., 401/402/429).

type StreamChunk

type StreamChunk struct {
	// Payload is the raw provider chunk payload.
	Payload []byte
	// Metadata exposes optional structured data for runtime accounting.
	Metadata map[string]any
	// Err reports any terminal error encountered while producing chunks.
	Err error
}

StreamChunk represents a single streaming payload unit emitted by provider executors.

type StreamResult

type StreamResult struct {
	// Headers carries upstream HTTP response headers from the initial connection.
	Headers http.Header
	// Chunks is the channel of streaming payload units.
	Chunks <-chan StreamChunk
}

StreamResult wraps the streaming response, providing both the chunk channel and the upstream HTTP response headers captured before streaming begins.

type StreamTruncatedError added in v0.0.57

type StreamTruncatedError interface {
	error
	IsStreamTruncated() bool
}

StreamTruncatedError identifies a locally synthesized failure for an accepted upstream stream that ended without its terminal frame. The upstream generation was already submitted, so auth managers must not cool the credential or replay the request on another credential because of it.

type UpstreamWebsocketReplayRequiredError added in v0.0.42

type UpstreamWebsocketReplayRequiredError struct{}

UpstreamWebsocketReplayRequiredError indicates that an incremental request cannot safely continue because its upstream websocket is no longer reusable.

Ported from upstream CLIProxyAPI commit 42c9680eee55 (sdk/cliproxy/executor/websocket.go).

func (*UpstreamWebsocketReplayRequiredError) Error added in v0.0.42

func (*UpstreamWebsocketReplayRequiredError) IsRequestScoped added in v0.0.42

func (*UpstreamWebsocketReplayRequiredError) IsRequestScoped() bool

func (*UpstreamWebsocketReplayRequiredError) StatusCode added in v0.0.42

type WebsocketInput added in v0.0.42

type WebsocketInput struct {
	Payload []byte
	Err     error
}

WebsocketInput is a frame from the single downstream reader. Err terminates the connection; Payload is owned by the receiver and must not be replayed.

Ported from upstream CLIProxyAPI commit 42c9680eee55 (sdk/cliproxy/executor/websocket_input.go).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL