state

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package state defines the State interface and supporting types for ore's conversation history model.

State is a mutable interface: Append() mutates in place. Turns() returns a defensive copy of the internal slice so providers can safely iterate without synchronization. The in-memory implementation (Buffer) is intentionally not goroutine-safe; concurrency control is a future middleware concern.

Package state defines the State interface and supporting types for ore's conversation history model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer is a simple in-memory implementation of State. It is not safe for concurrent use.

func (*Buffer) Append

func (m *Buffer) Append(role Role, artifacts ...artifact.Artifact)

Append adds a new turn to the in-memory state.

func (*Buffer) Turns

func (m *Buffer) Turns() []Turn

Turns returns a defensive copy of the internal turn slice. Note: this is a shallow copy of the slice itself; the Artifacts slices within each Turn are not deep-copied.

type Role

type Role string

Role represents the role of a participant in a conversation turn.

const (
	RoleSystem    Role = "system"
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
	RoleTool      Role = "tool"
)

type State

type State interface {
	// Turns returns a defensive copy of the turn history.
	Turns() []Turn

	// Append adds a new turn to the state. It mutates in place.
	Append(role Role, artifacts ...artifact.Artifact)
}

State is a mutable conversation state that the core loop appends to.

func NewVirtualTurnState

func NewVirtualTurnState(base State, virtual []Turn) State

NewVirtualTurnState creates a state wrapper that prepends virtual turns before the base state's turns. If virtual is empty, it returns the base state directly as an identity optimization.

type Turn

type Turn struct {
	Role      Role
	Artifacts []artifact.Artifact
}

Turn represents a single turn in the conversation history.

type VirtualTurnState

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

VirtualTurnState wraps a base State, prepending virtual turns to the slice returned by Turns(). Append() delegates to the base state. This enables inference assembly transforms to inject content that appears in the provider's view without mutating the persistent conversation buffer.

func (*VirtualTurnState) Append

func (v *VirtualTurnState) Append(role Role, artifacts ...artifact.Artifact)

Append delegates to the underlying base state.

func (*VirtualTurnState) Turns

func (v *VirtualTurnState) Turns() []Turn

Turns returns a defensive copy of the virtual turns followed by the base state's turns.

Jump to

Keyboard shortcuts

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