heartbeat

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunLoop

func RunLoop(
	ctx context.Context,
	workspaceDir string,
	interval time.Duration,
	maxHeartbeats int,
	nowFn func() time.Time,
) (int, error)

RunLoop executes RunOnce in a ticker loop. If maxHeartbeats is greater than zero, loop exits after maxHeartbeats ticks.

func RunLoopWithLLM

func RunLoopWithLLM(
	ctx context.Context,
	workspaceDir string,
	interval time.Duration,
	maxHeartbeats int,
	nowFn func() time.Time,
	ask AskFunc,
) (int, error)

RunLoopWithLLM executes RunOnceWithLLM in a ticker loop.

func RunLoopWithLLMWithPolicy

func RunLoopWithLLMWithPolicy(
	ctx context.Context,
	workspaceDir string,
	interval time.Duration,
	maxHeartbeats int,
	nowFn func() time.Time,
	ask AskFunc,
	policy Policy,
) (int, error)

func RunOnce

func RunOnce(workspaceDir string, now time.Time) error

RunOnce reads HEARTBEAT.md and appends one heartbeat event to today's daily log.

func RunOnceWithLLM

func RunOnceWithLLM(ctx context.Context, workspaceDir string, now time.Time, ask AskFunc) error

RunOnceWithLLM reads heartbeat context, asks LLM, and appends events to daily log.

func RunOnceWithLLMResult

func RunOnceWithLLMResult(ctx context.Context, workspaceDir string, now time.Time, ask AskFunc) (string, error)

RunOnceWithLLMResult runs one heartbeat turn and returns the raw LLM response text.

Types

type AskFunc

type AskFunc func(ctx context.Context, prompt string) (string, error)

type Policy

type Policy struct {
	AckToken           string
	ActiveHours        string
	Timezone           string
	ShouldRun          func(ctx context.Context, now time.Time) (bool, string)
	LoadSessionContext func(ctx context.Context, now time.Time) (string, error)
	AppendSessionTurn  func(ctx context.Context, turn TurnRecord) error
}

type RunResult

type RunResult struct {
	Response     string
	Skipped      bool
	SkipReason   string
	Logged       bool
	Acknowledged bool
}

func RunOnceWithLLMResultWithPolicy

func RunOnceWithLLMResultWithPolicy(ctx context.Context, workspaceDir string, now time.Time, ask AskFunc, policy Policy) (RunResult, error)

RunOnceWithLLMResultWithPolicy runs one heartbeat turn with optional policy controls.

type TurnRecord

type TurnRecord struct {
	OccurredAt   time.Time
	Prompt       string
	Response     string
	Acknowledged bool
}

Jump to

Keyboard shortcuts

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