server

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package server implements a deterministic local protocol fixture. It only represents this project's current pack interpretation and is not a claim of protocol authority.

Index

Constants

View Source
const (
	SyntheticBearerToken = "synthetic-test-token"
	SyntheticAPIKey      = "synthetic-test-key"
)

Variables

View Source
var ErrTransformerNotApplicable = errors.New("transformer not applicable")

ErrTransformerNotApplicable indicates that a transformer deliberately does not target the current exchange. The handler preserves the unmodified reference response and does not advertise the transformer ID. Other errors are treated as transformer failures.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxBodyBytes   int64
	RequestTimeout time.Duration
	Transformer    Transformer
}

type Exchange

type Exchange struct {
	Protocol                 Protocol
	Scenario                 Scenario
	Streaming                bool
	ResponsesMaxOutputTokens int
	Status                   int
	Headers                  http.Header
	JSON                     map[string]any
	Events                   []SSEEvent
	RawSuffix                []byte
	MutationID               string
}

type Handler

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

func New

func New(config Config) (*Handler, error)

func (*Handler) ServeHTTP

func (handler *Handler) ServeHTTP(writer http.ResponseWriter, request *http.Request)

type Protocol

type Protocol string
const (
	ProtocolOpenAIChat      Protocol = "openai-chat"
	ProtocolOpenAIResponses Protocol = "openai-responses"
	ProtocolAnthropic       Protocol = "anthropic-messages"
)

type SSEEvent

type SSEEvent struct {
	Event    string
	Data     any
	RawData  []byte
	Terminal bool
}

type Scenario

type Scenario string
const (
	ScenarioText Scenario = "text"
	ScenarioTool Scenario = "tool"
)

type Transformer

type Transformer interface {
	ID() string
	Apply(*Exchange) error
}

Jump to

Keyboard shortcuts

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