state

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package state manages resume state for incremental agent execution. It tracks content hashes to detect when inputs change and regeneration is needed.

Index

Constants

View Source
const StateFile = ".pagent/.resume-state.json"

StateFile is the default location for resume state

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentOutput

type AgentOutput struct {
	// OutputPath is the path to the agent's output file
	OutputPath string `json:"output_path"`

	// OutputHash is the hash of the output content
	OutputHash string `json:"output_hash"`

	// InputHashAtGeneration is the input hash when this output was generated
	InputHashAtGeneration string `json:"input_hash_at_generation"`

	// ConfigHashAtGeneration is the config hash when this output was generated
	ConfigHashAtGeneration string `json:"config_hash_at_generation"`

	// DependencyHashes maps dependency agent names to their output hashes when this was generated
	DependencyHashes map[string]string `json:"dependency_hashes"`
}

AgentOutput tracks the output state of a single agent.

type Manager

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

Manager handles resume state operations.

func NewManager

func NewManager(outputDir string) *Manager

NewManager creates a new state manager for the given output directory.

func (*Manager) Clear

func (m *Manager) Clear() error

Clear removes all resume state.

func (*Manager) Load

func (m *Manager) Load() error

Load loads the resume state from disk.

func (*Manager) RecordAgentOutput

func (m *Manager) RecordAgentOutput(agentName, outputPath string, dependencyAgents []string) error

RecordAgentOutput records the output of an agent for future resume checks.

func (*Manager) Save

func (m *Manager) Save() error

Save persists the resume state to disk.

func (*Manager) ShouldRegenerate

func (m *Manager) ShouldRegenerate(agentName, outputPath string, dependencyAgents []string) (bool, string)

ShouldRegenerate determines if an agent needs to be regenerated. Returns true if the agent should run, false if it can be skipped.

func (*Manager) UpdateConfigHash

func (m *Manager) UpdateConfigHash(persona string, stack, preferences interface{}) error

UpdateConfigHash computes and stores a hash of the relevant config.

func (*Manager) UpdateInputHash

func (m *Manager) UpdateInputHash(inputFiles []string) error

UpdateInputHash computes and stores the hash of all input files.

type ResumeState

type ResumeState struct {
	// InputHash is the combined hash of all input files
	InputHash string `json:"input_hash"`

	// ConfigHash is the hash of relevant configuration (persona, preferences, stack)
	ConfigHash string `json:"config_hash"`

	// AgentOutputs maps agent names to their output state
	AgentOutputs map[string]AgentOutput `json:"agent_outputs"`
}

ResumeState tracks the state of previous agent runs for resumability.

Jump to

Keyboard shortcuts

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