workerstate

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package workerstate records worker lifecycle and readiness state.

Package workerstate persists the local worker heartbeat shown by `codog state`.

Index

Constants

View Source
const FileName = "worker-state.json"

FileName is the workspace-local JSON file used for worker state snapshots.

Variables

This section is empty.

Functions

func Path

func Path(workspace string) string

Path returns the workspace-local path used to persist worker state.

func RenderText

func RenderText(w io.Writer, state State)

RenderText writes a compact human-readable worker state report.

func Save

func Save(workspace string, state State) error

Save writes state atomically to the workspace worker state file.

func SavePath

func SavePath(path string, state State) error

SavePath writes state atomically to an explicit worker state file.

Types

type MissingError

type MissingError struct {
	Path string
}

MissingError reports that a workspace has not written worker state yet.

func (MissingError) Error

func (e MissingError) Error() string

Error returns an actionable message for creating the missing worker state.

type Options

type Options struct {
	WorkerID       string
	Version        string
	Mode           string
	Status         string
	Workspace      string
	SessionID      string
	SessionPath    string
	Model          string
	PermissionMode string
	PID            int
	LastError      string
	Ship           *ship.Report
	Now            time.Time
}

Options contains the runtime facts captured in a worker state snapshot.

type State

type State struct {
	Kind           string       `json:"kind"`
	WorkerID       string       `json:"worker_id"`
	Version        string       `json:"version"`
	Mode           string       `json:"mode"`
	Status         string       `json:"status"`
	Workspace      string       `json:"workspace"`
	SessionID      string       `json:"session_id,omitempty"`
	SessionPath    string       `json:"session_path,omitempty"`
	Model          string       `json:"model,omitempty"`
	PermissionMode string       `json:"permission_mode,omitempty"`
	PID            int          `json:"pid"`
	LastError      string       `json:"last_error,omitempty"`
	Ship           *ship.Report `json:"ship,omitempty"`
	UpdatedAt      time.Time    `json:"updated_at"`
}

State is the stable JSON payload written by prompt and REPL workers.

func Load

func Load(workspace string) (State, error)

Load reads and validates the workspace worker state file.

func LoadPath

func LoadPath(path string) (State, error)

LoadPath reads and validates an explicit worker state file.

func New

func New(opts Options) State

New builds a worker state snapshot, filling process-local defaults when caller-supplied fields are empty.

Jump to

Keyboard shortcuts

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