Documentation
¶
Overview ¶
Package core folds Responses events without owning credentials or transports. Event folding and continuation rules derive from CPA CodexReflow/CodexComp.
Index ¶
- Constants
- func ContinuationTrigger(usage, summed Object, maxTier, minimum int) string
- func ContinueReplay(tail []any, reasoning []Object, marker string) []any
- func Eligible(body Object) bool
- func InContinueWindow(n *int, maxTier int) bool
- func ReasoningTokens(usage Object) *int
- func SumUsage(acc, usage Object)
- func TierN(tokens *int) *int
- func ToFloat(value any) float64
- type BufferedItem
- type Config
- type ContinuationDecision
- type ContinuationPolicy
- type Decision
- type Decoder
- type EventDecoder
- type EventPolicy
- type FoldState
- func (f *FoldState) DecideContinuation(policy ContinuationPolicy) ContinuationDecision
- func (f *FoldState) Flush(emit func(Object) error, normalizeID bool) error
- func (f *FoldState) HasEncryptedContent() bool
- func (f *FoldState) Process(ev Object, policy EventPolicy, emit func(Object) error) error
- func (f *FoldState) RecordRound(terminal, usage Object, includeTier bool)
- func (f *FoldState) ResetRound()
- func (f *FoldState) Stamp(ev Object, normalizeID bool) Object
- type Object
- func AgentUsage(first, summed, final Object, flushed bool) Object
- func Clone(in Object) (Object, error)
- func CloneUsage(usage Object) Object
- func CommentaryNudge(marker string) Object
- func FailedEvent(status int, detail string) Object
- func NextRoundBody(base Object, input []any) Object
- func TerminalEvent(upstream, base Object, output []Object, usage Object, rounds []Object, ...) Object
- type Reader
- type Result
- type Session
Constants ¶
const EncryptedReasoningInclude = encInclude
const MaxStreamBufferSize = maxStreamBufferSize
Variables ¶
This section is empty.
Functions ¶
func ContinuationTrigger ¶
func Eligible ¶
Eligible is a conservative text-model naming rule; it does not claim a model's actual capabilities. Runtime decisions also require usable reasoning state.
func InContinueWindow ¶
func ReasoningTokens ¶
These operations are also used by host adapters whose stream lifecycle is controlled externally. They share Session's algorithms without host SDKs.
Types ¶
type BufferedItem ¶
type Config ¶
type Config struct {
MaxContinue int `json:"max_continue"`
MaxTierN int `json:"max_tier_n"`
MaxBufferedBytes int `json:"max_buffered_bytes"`
MarkerText string `json:"marker_text"`
}
func DefaultConfig ¶
func DefaultConfig() Config
type ContinuationDecision ¶
type ContinuationPolicy ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder accepts arbitrary chunks without owning or buffering a transport. It has the same bounded framing rules as Reader.
type EventDecoder ¶
type EventDecoder struct {
// contains filtered or unexported fields
}
eventDecoder accepts the host's raw WebSocket JSON events and SSE data: payloads (with or without trailing newlines). JSON boundaries, not searching for "data:" within arbitrary bytes, delimit events. Its incremental scanner avoids rescanning a large JSON string after every fragmented host read.
func (*EventDecoder) BufferedBytes ¶
func (d *EventDecoder) BufferedBytes() int
BufferedBytes reports resource use, never the buffered payload.
func (*EventDecoder) Feed ¶
func (d *EventDecoder) Feed(payload []byte) error
func (*EventDecoder) Finish ¶
func (d *EventDecoder) Finish() error
type EventPolicy ¶
EventPolicy selects protocol-boundary behavior, not a transport or host SDK. Strict callers own cloned events and normalize response IDs. Legacy hosts may retain their existing event ownership and permissive framing contract.
type FoldState ¶
type FoldState struct {
RoundNo int
OutputIndex int
Sequence int
BaseResponse Object
FinalOutput []Object
RoundReasoning []Object
Kinds map[int]string
Indexes map[int]int
Buffered []BufferedItem
BufferedBytes int
Terminal Object
Usage Object
SummedUsage Object
FirstUsage Object
RoundsInfo []Object
}
FoldState is the transport-independent accumulator shared by Session and host adapters. A single request owns it; callers must serialize access. State can contain private input/output and must never be logged wholesale.
func (*FoldState) DecideContinuation ¶
func (f *FoldState) DecideContinuation(policy ContinuationPolicy) ContinuationDecision
func (*FoldState) HasEncryptedContent ¶
func (*FoldState) Process ¶
Process forwards reasoning and buffers final text/client tools until a continuation decision is known. The emitter must not retain mutable events.
func (*FoldState) RecordRound ¶
func (*FoldState) ResetRound ¶
func (f *FoldState) ResetRound()
type Object ¶
func AgentUsage ¶
func CloneUsage ¶
func CommentaryNudge ¶
func FailedEvent ¶
func NextRoundBody ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader incrementally decodes SSE or raw JSON frames. It owns no transport.
type Session ¶
type Session struct {
FoldState
// contains filtered or unexported fields
}
func New ¶
New starts one client request. replayBase is the complete effective request, when an adapter has resolved previous_response_id from its scoped cache. An unresolved parent is passed through without an unsafe partial replay.
func (*Session) Abort ¶
Abort emits an incomplete result. Reasons are fixed codes, not upstream bodies.