heartbeat

package
v0.153.3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package heartbeat implements a periodic "wake-up" service that spawns the agent on a fixed interval to check for pending work. It is hosted by the channels-manager daemon (peer to the scheduler) and is disabled by default.

Unlike the scheduler, heartbeat does not route output to a channel. Each tick fires `infer agent --heartbeat`, the agent runs to completion using a tailored system prompt, and the agent's stdout is logged. Whatever externally-visible action the agent takes (e.g. posting to Telegram, opening a PR) it does via its own tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Interval     time.Duration
	InitialDelay time.Duration
	Model        string
	Prompt       string
}

Config bundles the runtime knobs the heartbeat service needs. It is derived from config.HeartbeatConfig at startup time so the service stays decoupled from the broader Config type.

type Options

type Options struct {
	Config Config
	// ExecCommand defaults to exec.CommandContext when nil.
	ExecCommand agentrunner.ExecFunc
	// BinaryPath defaults to os.Args[0] when empty.
	BinaryPath string
}

Options bundles dependencies for NewService.

type Service

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

Service drives the heartbeat ticker. Single global instance per daemon; constructed by NewService and lifecycle-managed via Start/Stop.

func NewService

func NewService(opts Options) (*Service, error)

NewService constructs a heartbeat Service. Returns an error if the configured interval is non-positive.

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

Start launches the ticker goroutine. The supplied context's cancellation is propagated to in-flight agent subprocesses on shutdown. Calling Start more than once is a no-op.

func (*Service) Stop

func (s *Service) Stop(ctx context.Context) error

Stop cancels the ticker and waits for any in-flight heartbeat run to terminate. Honours the supplied context as a hard deadline.

Jump to

Keyboard shortcuts

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