runtime

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingTaskSource   = errors.New("runtime: task source required")
	ErrMissingTurnExecutor = errors.New("runtime: turn executor required")
)

Functions

This section is empty.

Types

type LoopConfig

type LoopConfig struct {
	PollInterval time.Duration
	ErrorBackoff time.Duration
	MaxBackoff   time.Duration
	MaxTurns     int
	// Concurrency > 1 runs turns concurrently across thread ids (serialized
	// within a thread), bounded by this many simultaneous turns. <= 1 is serial.
	Concurrency int
}

type LoopStats

type LoopStats struct {
	Turns     int `json:"turns"`
	Errors    int `json:"errors"`
	Cancelled int `json:"cancelled"`
}

type Runner

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

func NewRunner

func NewRunner(source TaskSource, executor TurnExecutor) (*Runner, error)

func (*Runner) RunLoop

func (r *Runner) RunLoop(ctx context.Context, cfg LoopConfig) (LoopStats, error)

func (*Runner) RunOnce

func (r *Runner) RunOnce(ctx context.Context) (protocol.ChatMessage, error)

func (*Runner) SetCanceller

func (r *Runner) SetCanceller(c *turncancel.Canceller)

SetCanceller wires a turn canceller so an out-of-band cancel control can abort the in-flight turn (keyed by task id).

func (*Runner) SetSteering added in v0.0.2

func (r *Runner) SetSteering(inbox *steering.Inbox)

SetSteering wires the inbox that delivers a user's mid-turn message into the turn already running on its thread. Without one, such a message simply waits its turn as before.

The rejector is taken from the task source when it implements channel.SteeringRejector, so a transport that can talk back to the sender tells it when an interjection missed its turn. SetSteeringRejector overrides.

func (*Runner) SetSteeringRejector added in v0.0.2

func (r *Runner) SetSteeringRejector(rejector channel.SteeringRejector)

SetSteeringRejector overrides how a missed steering message is reported.

type TaskSource

type TaskSource = channel.Receiver

TaskSource is the ingress half of the transport seam (channel.Receiver).

type TurnExecutor

type TurnExecutor interface {
	Run(ctx context.Context, addr protocol.MessageAddress, user protocol.ChatMessage) (protocol.ChatMessage, error)
}

Jump to

Keyboard shortcuts

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