lifecycle

package
v0.9.39 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package lifecycle defines the dependency-free lifecycle domain shared by chat and terminal-host integrations.

Index

Constants

View Source
const (
	// SchemaVersion is the current JSON lifecycle event schema.
	SchemaVersion = 1
)

Variables

This section is empty.

Functions

func ValidState

func ValidState(state State) bool

ValidState reports whether state belongs to the public lifecycle vocabulary.

Types

type Event

type Event struct {
	SchemaVersion int      `json:"schema_version"`
	Producer      string   `json:"producer"`
	Kind          Kind     `json:"kind"`
	Sequence      int64    `json:"sequence"`
	Timestamp     string   `json:"timestamp"`
	State         State    `json:"state"`
	Message       string   `json:"message"`
	SessionID     string   `json:"session_id"`
	Title         string   `json:"-"`
	PID           int      `json:"pid"`
	CWD           string   `json:"cwd"`
	ResumeArgv    []string `json:"resume_argv,omitempty"`
}

Event is the stable version 1 JSON contract consumed by generic command sinks. Field order is intentional so encoded events remain byte-compatible.

func NewEvent

func NewEvent(kind Kind, sequence int64, timestamp time.Time, metadata Metadata, snapshot Snapshot) Event

NewEvent constructs a normalized version 1 event. Release events retain the last session and resume context when available but never claim a live state.

type Kind

type Kind string

Kind identifies whether an event publishes state or relinquishes authority.

const (
	KindState   Kind = "state"
	KindRelease Kind = "release"
)

type Metadata

type Metadata struct {
	Producer   string
	PID        int
	CWD        string
	ResumeArgv []string
}

Metadata identifies the term-llm process producing lifecycle events.

func NormalizeMetadata

func NormalizeMetadata(metadata Metadata) Metadata

NormalizeMetadata sanitizes and bounds process metadata and resume arguments.

type Snapshot

type Snapshot struct {
	State     State
	SessionID string
	Title     string
	Message   string
	CWD       string
}

Snapshot is a side-effect-free view of the currently visible chat. Title is optional presentation metadata for first-party terminal hosts. It is intentionally not part of the versioned JSON event schema sent to command sinks. Message is an optional, stable detail suitable for display by a terminal host. CWD is the visible session's effective working directory when available; the manager uses the producer process working directory as its event fallback.

func NormalizeSnapshot

func NormalizeSnapshot(snapshot Snapshot) Snapshot

NormalizeSnapshot removes controls, normalizes whitespace, and bounds values before they can reach a terminal host or external command.

type State

type State string

State is the coarse foreground lifecycle state.

const (
	Idle    State = "idle"
	Working State = "working"
	Blocked State = "blocked"
)

Jump to

Keyboard shortcuts

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