narrator

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNarratorTimeout = errors.New("narrator llm runner timed out")

ErrNarratorTimeout indicates the LLM runner exceeded the per-call budget. Callers typically treat it as a silent skip.

Functions

func SetLLMTimeout

func SetLLMTimeout(d time.Duration)

SetLLMTimeout replaces the package-level LLM timeout used by runLLMRunner when no ctx-scoped override is present. Typically called once at application bootstrap from the workspace-config applier. Passing a non-positive value means "no timeout" (runner ctx used as-is).

func StartNarration

func StartNarration(ctx context.Context, cfg *asynccfg.Config, rec *asynccfg.OperationRecord) (string, error)

func UpdateNarration

func UpdateNarration(ctx context.Context, cfg *asynccfg.Config, ev asynccfg.ChangeEvent) (string, error)

func WithLLMRunner

func WithLLMRunner(ctx context.Context, runner LLMRunner) context.Context

func WithLLMTimeout

func WithLLMTimeout(ctx context.Context, d time.Duration) context.Context

WithLLMTimeout attaches a per-call timeout override to ctx. Used by request-scoped code paths that need a different bound than the package-level SetLLMTimeout value (e.g. admin flows, tests). A non-positive duration is ignored.

Types

type Debouncer

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

Debouncer collapses a stream of text updates into one emission per window. Safe for concurrent use by multiple goroutines — all state mutations are guarded by mu so callers do not need external synchronization.

Typical use from a single goroutine (e.g. the barrier's select loop) is still the common case, but the internal mutex means `go test -race` cannot report a false positive if the caller accidentally invokes Push / Flush / Channel from more than one goroutine.

func NewDebouncer

func NewDebouncer(window time.Duration) *Debouncer

func (*Debouncer) Channel

func (d *Debouncer) Channel() <-chan time.Time

Channel returns the debounce timer's channel, or nil when no window is currently active. Safe to call concurrently with Push / Flush.

The returned channel is the *timer's* channel; receiving on it is safe even if Flush races in parallel and stops the timer. A stopped timer's channel simply never fires again. Callers typically re-read Channel() on each select iteration so they pick up the current state.

func (*Debouncer) Flush

func (d *Debouncer) Flush() string

Flush returns the pending value (if any) and clears debouncer state. Stops and drains the internal timer. Safe to call at any time; a Flush with no pending value returns "".

func (*Debouncer) Push

func (d *Debouncer) Push(text string) string

Push records a new pending value. When the debounce window is zero, the input is passed through immediately (synchronous emission). Otherwise the first Push starts the window and returns ""; subsequent Push calls within the window replace `pending` and also return "". Callers drain via Channel() + Flush() when the timer fires.

type LLMInput

type LLMInput struct {
	OperationID string
	UserAsk     string
	Intent      string
	Summary     string
	Message     string
	Status      string
	Tool        string
}

type LLMRunner

type LLMRunner func(context.Context, LLMInput) (string, error)

type Session

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

func NewSession

func NewSession(window time.Duration, sink Sink) *Session

func (*Session) Channel

func (s *Session) Channel() <-chan time.Time

func (*Session) Flush

func (s *Session) Flush() error

func (*Session) Push

func (s *Session) Push(text string) error

func (*Session) Start

func (s *Session) Start(text string) error

type Sink

type Sink func(text string) error

Jump to

Keyboard shortcuts

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