stream

package
v0.1.57 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package stream is the daemon's per-run event hub: the runner publishes unified events for a run; the SSE endpoint replays the buffer to a late subscriber and then streams live events until the run completes (or the client disconnects).

A finished run's topic is reaped after a short grace window so memory doesn't grow without bound across the daemon's lifetime, and a subscriber that can't keep up is evicted (its channel closed) rather than silently losing events — the client reconnects and replays the full retained buffer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hub

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

func New

func New() *Hub

func (*Hub) Close

func (h *Hub) Close(id string)

Close marks the run finished, closes all live subscriber channels, and schedules the topic (and its buffer) to be freed after a grace window for late replay subscribers.

func (*Hub) Publish

func (h *Hub) Publish(id string, ev agent.Event)

Publish appends an event to the run's buffer and fans it out to live subscribers.

func (*Hub) Snapshot

func (h *Hub) Snapshot(id string) (Snapshot, bool)

Snapshot reads the components and cursor under the same lock as Publish. Looking up a completed/reaped run must not create a new, empty live topic.

func (*Hub) Subscribe

func (h *Hub) Subscribe(id string) (replay []agent.Event, ch <-chan agent.Event, done bool, cancel func())

Subscribe atomically snapshots the replay buffer and (if the run is still live) registers a channel for subsequent events. `done` is true when the run already finished — the caller just sends the replay and stops. Always call cancel().

func (*Hub) SubscribeAfter

func (h *Hub) SubscribeAfter(id string, after int64) (replay []agent.Event, ch <-chan agent.Event, done bool, cancel func())

SubscribeAfter atomically replays events newer than after and subscribes to live updates. Sequence numbers survive reconnects for the lifetime of the run topic.

func (*Hub) SubscribeRetainedAfter

func (h *Hub) SubscribeRetainedAfter(id string, after int64) (replay []agent.Event, ch <-chan agent.Event, done bool, cancel func())

SubscribeRetainedAfter subscribes without creating a topic. Completed runs can outlive their replay buffer (or a daemon restart); they must not acquire an empty live channel that no producer will ever close.

type Snapshot

type Snapshot struct {
	Sequence      int64             `json:"sequence"`
	Parts         []agent.Part      `json:"parts"`
	Result        *agent.ResultInfo `json:"result,omitempty"`
	Error         string            `json:"error,omitempty"`
	StatusMessage string            `json:"statusMessage,omitempty"`
}

Snapshot is a materialized turn at an event cursor. Reading it and then subscribing after Sequence restores a turn without replaying its animation or losing new events.

type Transcript

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

Transcript is the shared event reducer for persistence and live snapshots, for every harness. Callers serialize access. Parts and tool values are copied before mutation so a previously returned snapshot remains stable while the next event is applied.

func (*Transcript) Apply

func (t *Transcript) Apply(ev agent.Event)

func (*Transcript) Snapshot

func (t *Transcript) Snapshot(final bool) Snapshot

Jump to

Keyboard shortcuts

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