Documentation
¶
Overview ¶
Package session identifies the client session a request belongs to, so the gateway can route one conversation consistently and group its audit entries.
Index ¶
Constants ¶
const ( SourceHeader = "header" SourceBody = "body" // TransformSessionUUID extracts a session UUID from Anthropic // metadata.user_id values. Claude Code sends either a JSON object string // with a "session_id" field or the legacy "user_<hash>_…_session_<uuid>" // form; both embed the session UUID this transform returns. TransformSessionUUID = "session-uuid" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector resolves the session id for a request. Explicit header rules win over body rules, which win over content-based auto-detection.
func NewDetector ¶
NewDetector builds a Detector from an ordered rule list. Rules keep their relative order within each source; header rules are always evaluated first.
func NewDetectorFromConfig ¶
func NewDetectorFromConfig(cfg config.SessionConfig) *Detector
NewDetectorFromConfig builds the request session detector from application config. Returns nil when session keeping is disabled, which downstream consumers treat as "no session".
func (*Detector) Detect ¶
func (d *Detector) Detect(snapshot *core.RequestSnapshot, userPath string) string
Detect returns the stable session id for the captured request, or "" when the request carries no session signal. Explicit client-provided ids are scoped by user path so no caller-controlled value can collide across tenants.
type Rule ¶
type Rule struct {
// Source is SourceHeader or SourceBody.
Source string
// Header is the HTTP header name to read (Source == SourceHeader).
Header string
// BodyPath is the gjson path into the JSON request body (Source == SourceBody).
BodyPath string
// Transform optionally post-processes the raw value; an empty result means
// the rule did not match. Empty string uses the value as-is.
Transform string
}
Rule identifies where a client session id lives in a request.