strategy

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 11 Imported by: ? 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackgroundRunner

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

BackgroundRunner wraps a Strategy with interrupt/checkpoint support for running as a background skill during idle windows of a primary skill.

func NewBackgroundRunner

func NewBackgroundRunner(strategy Strategy, config BackgroundRunnerConfig) *BackgroundRunner

NewBackgroundRunner creates a background runner for the given strategy.

func (*BackgroundRunner) GetCheckpoint

func (b *BackgroundRunner) GetCheckpoint() SkillCheckpoint

GetCheckpoint returns a copy of the current checkpoint.

func (*BackgroundRunner) Interrupt

func (b *BackgroundRunner) Interrupt() *SkillCheckpoint

Interrupt signals the background skill to stop and waits for cleanup.

func (*BackgroundRunner) IsRunning

func (b *BackgroundRunner) IsRunning() bool

IsRunning returns whether the background skill is currently executing.

func (*BackgroundRunner) SetCheckpoint

func (b *BackgroundRunner) SetCheckpoint(cp SkillCheckpoint)

SetCheckpoint updates the stored checkpoint.

func (*BackgroundRunner) Start

func (b *BackgroundRunner) Start(parent context.Context, client game.GameClient, cfg Config)

Start begins executing the background strategy in a goroutine.

func (*BackgroundRunner) Strategy

func (b *BackgroundRunner) Strategy() Strategy

Strategy returns the wrapped strategy.

type BackgroundRunnerConfig

type BackgroundRunnerConfig struct {
	CleanupTimeout time.Duration
	Logger         *log.Logger
}

BackgroundRunnerConfig configures a BackgroundRunner.

type ChainStrategy

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

ChainStrategy runs multiple strategies in sequence.

func NewChainStrategy

func NewChainStrategy(name string, steps ...Strategy) *ChainStrategy

NewChainStrategy creates a chain that runs the given strategies in order.

func (*ChainStrategy) CurrentStatus

func (c *ChainStrategy) CurrentStatus() string

func (*ChainStrategy) Description

func (c *ChainStrategy) Description() string

func (*ChainStrategy) Name

func (c *ChainStrategy) Name() string

func (*ChainStrategy) Run

func (c *ChainStrategy) Run(ctx context.Context, client game.GameClient, cfg Config) error

type CompositeConfig

type CompositeConfig struct {
	CleanupTimeout  time.Duration
	MinIdleDuration time.Duration
	Logger          *log.Logger
}

CompositeConfig configures a CompositeStrategy.

type CompositeStrategy

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

CompositeStrategy orchestrates a primary strategy with a background strategy that runs during the primary's idle windows.

func NewCompositeStrategy

func NewCompositeStrategy(primary, background Strategy, config CompositeConfig) *CompositeStrategy

NewCompositeStrategy creates a composite strategy.

func (*CompositeStrategy) CurrentStatus

func (c *CompositeStrategy) CurrentStatus() string

func (*CompositeStrategy) Description

func (c *CompositeStrategy) Description() string

func (*CompositeStrategy) Name

func (c *CompositeStrategy) Name() string

func (*CompositeStrategy) NotifyIdle

func (c *CompositeStrategy) NotifyIdle(idle bool)

NotifyIdle is called by the primary strategy to signal idle enter/exit. Pass true when entering idle, false when exiting. Drains any pending signal first to ensure the latest state always arrives.

func (*CompositeStrategy) Run

func (c *CompositeStrategy) Run(ctx context.Context, client game.GameClient, cfg Config) error

type Config

type Config struct {
	AgentID        string
	Logger         *log.Logger
	KnowledgeBase  knowledge.Base
	LLMClient      *llm.Client // optional, used by SmartIdleStrategy
	OnStatusUpdate func(status string)
	Parameters     map[string]string // e.g., "station_action": "craft-sell"
}

Config holds configuration passed to a strategy when it runs.

type ExplorerStrategy

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

ExplorerStrategy implements galaxy exploration using a DFS traversal. It discovers systems, collects POI data, and stores findings in the knowledge base.

func (*ExplorerStrategy) CurrentStatus

func (s *ExplorerStrategy) CurrentStatus() string

func (*ExplorerStrategy) Description

func (s *ExplorerStrategy) Description() string

func (*ExplorerStrategy) Name

func (s *ExplorerStrategy) Name() string

func (*ExplorerStrategy) Run

func (s *ExplorerStrategy) Run(ctx context.Context, client game.GameClient, cfg Config) error

Run executes the exploration loop. The full DFS exploration logic from cmd/auto-explorer will be extracted here in a future refactor. For now, this provides a simplified exploration cycle using the game client API.

type FighterStrategy

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

FighterStrategy implements autonomous combat operations. TODO: Extract full combat loop from cmd/auto-fighter when stabilized.

func (*FighterStrategy) CurrentStatus

func (s *FighterStrategy) CurrentStatus() string

func (*FighterStrategy) Description

func (s *FighterStrategy) Description() string

func (*FighterStrategy) Name

func (s *FighterStrategy) Name() string

func (*FighterStrategy) Run

func (s *FighterStrategy) Run(ctx context.Context, client game.GameClient, cfg Config) error

Run executes the fighter strategy loop. This is currently a stub that monitors state and reports status. The full combat loop from cmd/auto-fighter will be integrated when stabilized.

type Info

type Info struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

Info is a summary of a registered strategy.

type MiningStrategy

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

MiningStrategy wraps game.MiningLoop as a reusable strategy.

func (*MiningStrategy) CurrentStatus

func (s *MiningStrategy) CurrentStatus() string

func (*MiningStrategy) Description

func (s *MiningStrategy) Description() string

func (*MiningStrategy) Name

func (s *MiningStrategy) Name() string

func (*MiningStrategy) Run

func (s *MiningStrategy) Run(ctx context.Context, client game.GameClient, cfg Config) error

type Registry

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

Registry holds all available strategies.

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry creates a registry pre-loaded with all built-in strategies.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty strategy registry.

func (*Registry) Get

func (r *Registry) Get(name string) Strategy

Get returns a strategy by name, or nil if not found.

func (*Registry) List

func (r *Registry) List() []Info

List returns all registered strategy names and descriptions.

func (*Registry) Register

func (r *Registry) Register(s Strategy)

Register adds a strategy to the registry. Panics on duplicate names.

type SkillCheckpoint

type SkillCheckpoint struct {
	// SkillName is the name of the interrupted skill (e.g. "mine").
	SkillName string

	// CurrentStep is the step ID where execution was interrupted.
	CurrentStep string

	// StepState holds skill-specific state at the time of interruption.
	StepState map[string]any

	// Interrupted is true if the skill was interrupted (vs. completing naturally).
	Interrupted bool

	// CleanupDone is true if the interrupt cleanup sequence completed successfully.
	CleanupDone bool
}

SkillCheckpoint captures the state of a background skill that was interrupted, allowing it to resume from where it left off.

func (*SkillCheckpoint) Clear

func (c *SkillCheckpoint) Clear()

Clear resets the checkpoint to empty state.

func (*SkillCheckpoint) IsEmpty

func (c *SkillCheckpoint) IsEmpty() bool

IsEmpty returns true if no checkpoint data is stored.

type SkillStrategy

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

SkillStrategy adapts a YAML skill into the Strategy interface. It wraps a skills.Executor to run a named skill from the YAML skill registry.

func NewSkillStrategy

func NewSkillStrategy(cfg SkillStrategyConfig) *SkillStrategy

NewSkillStrategy creates a Strategy that runs a YAML skill.

func (*SkillStrategy) CurrentStatus

func (s *SkillStrategy) CurrentStatus() string

func (*SkillStrategy) Description

func (s *SkillStrategy) Description() string

func (*SkillStrategy) Name

func (s *SkillStrategy) Name() string

func (*SkillStrategy) Run

type SkillStrategyConfig

type SkillStrategyConfig struct {
	SkillName   string
	Description string
	Registry    *skills.Registry
	Dispatcher  skills.ActionDispatcher
	Logger      *log.Logger
	Params      map[string]string
}

SkillStrategyConfig holds the configuration for creating a SkillStrategy.

type SmartIdleStrategy

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

SmartIdleStrategy asks the LLM at longer intervals what the agent should do given their personality and current state. This is the fallback when no explicit strategy is assigned.

func (*SmartIdleStrategy) CurrentStatus

func (s *SmartIdleStrategy) CurrentStatus() string

func (*SmartIdleStrategy) Description

func (s *SmartIdleStrategy) Description() string

func (*SmartIdleStrategy) Name

func (s *SmartIdleStrategy) Name() string

func (*SmartIdleStrategy) Run

func (s *SmartIdleStrategy) Run(ctx context.Context, client game.GameClient, cfg Config) error

Run executes the idle strategy loop.

type Strategy

type Strategy interface {
	// Name returns the strategy's unique identifier.
	Name() string

	// Description returns a human-readable description.
	Description() string

	// Run executes the strategy loop. It should block until ctx is canceled
	// or the strategy completes. It returns nil on graceful shutdown.
	Run(ctx context.Context, client game.GameClient, cfg Config) error

	// CurrentStatus returns a short human-readable status string.
	CurrentStatus() string
}

Strategy defines a reusable game behavior loop that can be assigned to agents.

type StrategyFactory

type StrategyFactory func() Strategy

StrategyFactory creates a new Strategy instance.

type TraderStrategy

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

TraderStrategy implements autonomous trading operations. TODO: Extract full trade route logic from cmd/auto-trader when stabilized.

func (*TraderStrategy) CurrentStatus

func (s *TraderStrategy) CurrentStatus() string

func (*TraderStrategy) Description

func (s *TraderStrategy) Description() string

func (*TraderStrategy) Name

func (s *TraderStrategy) Name() string

func (*TraderStrategy) Run

func (s *TraderStrategy) Run(ctx context.Context, client game.GameClient, cfg Config) error

Run executes the trader strategy loop. This is currently a stub that monitors state and reports status. The full trade route logic from cmd/auto-trader will be integrated when stabilized.

type UnifiedRegistry

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

UnifiedRegistry resolves skill/strategy names to runnable Strategy instances. It checks Go strategy factories first, then falls back to YAML skills.

func NewUnifiedRegistry

func NewUnifiedRegistry(yamlRegistry *skills.Registry) *UnifiedRegistry

NewUnifiedRegistry creates a registry. Pass nil for yamlRegistry if not using YAML skills.

func (*UnifiedRegistry) Has

func (r *UnifiedRegistry) Has(name string) bool

Has returns true if the name can be resolved (Go or YAML).

func (*UnifiedRegistry) IsGoStrategy

func (r *UnifiedRegistry) IsGoStrategy(name string) bool

IsGoStrategy returns true if the name is a registered Go strategy.

func (*UnifiedRegistry) Names

func (r *UnifiedRegistry) Names() []string

Names returns all available strategy and skill names, sorted.

func (*UnifiedRegistry) RegisterGoStrategy

func (r *UnifiedRegistry) RegisterGoStrategy(name string, factory StrategyFactory)

RegisterGoStrategy adds a Go strategy factory.

func (*UnifiedRegistry) Resolve

func (r *UnifiedRegistry) Resolve(name string) (Strategy, error)

Resolve returns a Strategy for the given name. Priority: Go strategies first, then YAML skills. For YAML skills, returns an error indicating the caller should use ResolveSkill.

Jump to

Keyboard shortcuts

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