interceptor

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package interceptor implements the fail-closed AfterAuth request pipeline.

Index

Constants

View Source
const HostCallbackIDMetadataKey = "__deepseek_vision_host_callback_id"

Variables

View Source
var ErrRuntimeUnavailable = errors.New("vision interceptor runtime is unavailable")

Functions

func HandleUnavailable

func HandleUnavailable(req pluginapi.RequestInterceptRequest, targetModels ...string) (pluginapi.RequestInterceptResponse, error)

HandleUnavailable is the lifecycle fallback used while no generation is configured (including after shutdown). It preserves non-target traffic but terminates image-shaped Responses requests for the configured target models so an absent callback handler cannot turn a security boundary into host-level passthrough.

Types

type AnalyzerFactory

type AnalyzerFactory func(*config.Config) (vision.Analyzer, error)

AnalyzerFactory constructs the thin host-model adapter for one immutable configuration snapshot. It is initialized lazily only for eligible images.

type DiagnosticFunc

type DiagnosticFunc func(callbackID, level, message string, fields map[string]any)

DiagnosticFunc emits bounded, content-free runtime diagnostics through the host. callbackID lets CLIProxyAPI attach its request ID when available.

type Runtime

type Runtime struct {
	// contains filtered or unexported fields
}

Runtime manages immutable generations and implements the plugin handler.

func NewRuntime

func NewRuntime(factory AnalyzerFactory, diagnostics ...DiagnosticFunc) *Runtime

func NewRuntimeWithTrace

func NewRuntimeWithTrace(factory AnalyzerFactory, trace *tracelog.Sink, diagnostics ...DiagnosticFunc) *Runtime

func (*Runtime) Handle

Handle is intentionally fail-closed: it always returns a concrete response and never returns a processing error to the host, because host adapters are allowed to fail open when callback errors are returned.

func (*Runtime) Reconfigure

func (r *Runtime) Reconfigure(cfg *config.Config)

Reconfigure atomically publishes a new immutable snapshot. In-flight calls retain their previous state through ordinary Go references.

func (*Runtime) Shutdown

func (r *Runtime) Shutdown()

Shutdown is idempotent and prevents new requests from acquiring a state.

Jump to

Keyboard shortcuts

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