attemptproxy

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EndpointPath       = "/internal/agent/attempt"
	HeaderMeta         = "X-Vaala-Bound-Attempt"
	HeaderMode         = "X-Vaala-Attempt-Mode"
	TrailerResult      = "X-Vaala-Attempt-Result"
	ModeControl        = "control"
	ModeResponse       = "response"
	MaxResultWireBytes = 48 * 1024
)
View Source
const (
	SourceAdmin   ChannelSource = "admin"
	SourcePrivate ChannelSource = "private"

	ModeNative      ExecutionMode = "native"
	ModePassthrough ExecutionMode = "passthrough"
	ModeLegacy      ExecutionMode = "legacy"

	ResultSucceeded            ResultKind = "succeeded"
	ResultProviderFailed       ResultKind = "provider_failed"
	ResultExecutionRejected    ResultKind = "execution_rejected"
	ResultTransportUnavailable ResultKind = "transport_unavailable"
	ResultProxyRejected        ResultKind = "proxy_rejected"
	ResultCommitUncertain      ResultKind = "commit_uncertain"
	ResultCanceled             ResultKind = "canceled"
)

Variables

View Source
var ErrInvalidContract = errors.New("attempt proxy contract invalid")
View Source
var ErrResultTooLarge = errors.New("attempt proxy result too large")

Functions

func EncodeMeta

func EncodeMeta(meta AttemptProxyMeta) (string, error)

func EncodeResult

func EncodeResult(result AttemptProxyResult) (string, error)

func EncodeResultJSON

func EncodeResultJSON(result AttemptProxyResult) ([]byte, error)

EncodeResultJSON encodes a control response as bounded raw JSON. It uses the same trace trimming order as the base64 trailer encoder.

func ProviderPathAllowed

func ProviderPathAllowed(method, path string) bool

func WithMeta

func WithMeta(ctx context.Context, meta AttemptProxyMeta) context.Context

Types

type AttemptProxyMeta

type AttemptProxyMeta struct {
	Attempt     BoundAttempt `json:"attempt"`
	RequestPath string       `json:"request_path"`
}

func DecodeMeta

func DecodeMeta(raw string) (AttemptProxyMeta, error)

func MetaFromContext

func MetaFromContext(ctx context.Context) (AttemptProxyMeta, bool)

func (AttemptProxyMeta) Validate

func (meta AttemptProxyMeta) Validate() error

type AttemptProxyResult

type AttemptProxyResult struct {
	Kind                ResultKind        `json:"kind"`
	PromptTokens        int               `json:"prompt_tokens,omitempty"`
	CompletionTokens    int               `json:"completion_tokens,omitempty"`
	CacheReadTokens     int               `json:"cache_read_tokens,omitempty"`
	CacheWriteTokens    int               `json:"cache_write_tokens,omitempty"`
	FirstResponseMs     int               `json:"first_response_ms,omitempty"`
	UpstreamModel       string            `json:"upstream_model,omitempty"`
	TokenSource         string            `json:"token_source,omitempty"`
	Dispatches          int               `json:"dispatches,omitempty"`
	ProviderDispatched  bool              `json:"provider_dispatched,omitempty"`
	ProviderResultKnown bool              `json:"provider_result_known,omitempty"`
	Written             bool              `json:"written,omitempty"`
	PlanAdvanceAllowed  bool              `json:"plan_advance_allowed,omitempty"`
	ResponseStarted     bool              `json:"response_started,omitempty"`
	HTTPStatus          int               `json:"http_status,omitempty"`
	ErrorType           string            `json:"error_type,omitempty"`
	ReasonCode          string            `json:"reason_code,omitempty"`
	ErrorMessage        string            `json:"error_message,omitempty"`
	Trace               *AttemptTraceWire `json:"trace,omitempty"`
}

func DecodeResult

func DecodeResult(raw string) (AttemptProxyResult, error)

func (AttemptProxyResult) Validate

func (result AttemptProxyResult) Validate() error

type AttemptTraceWire

type AttemptTraceWire struct {
	InboundPath        string `json:"inbound_path,omitempty"`
	OutboundPath       string `json:"outbound_path,omitempty"`
	InboundHeaders     string `json:"inbound_headers,omitempty"`
	OutboundHeaders    string `json:"outbound_headers,omitempty"`
	InboundBody        string `json:"inbound_body,omitempty"`
	OutboundBody       string `json:"outbound_body,omitempty"`
	ResponseHeaders    string `json:"response_headers,omitempty"`
	ResponseBody       string `json:"response_body,omitempty"`
	ClientResponseBody string `json:"client_response_body,omitempty"`
	UpstreamStatus     int    `json:"upstream_status,omitempty"`
	ErrorStage         string `json:"error_stage,omitempty"`
}

type BoundAttempt

type BoundAttempt struct {
	Channel   ChannelRef    `json:"channel"`
	RealModel string        `json:"real_model"`
	Mode      ExecutionMode `json:"mode"`
}

func (BoundAttempt) Validate

func (attempt BoundAttempt) Validate() error

type ChannelRef

type ChannelRef struct {
	Source ChannelSource `json:"source"`
	ID     uint          `json:"id"`
}

func (ChannelRef) Validate

func (ref ChannelRef) Validate() error

type ChannelSource

type ChannelSource string

type ExecutionMode

type ExecutionMode string

type ResultKind

type ResultKind string

Jump to

Keyboard shortcuts

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