app

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 22 Imported by: 0 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

Overview

Package app implements use cases shared by agentcron's interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddJob

func AddJob(ctx context.Context, opts Options, c clock.Clock, j Job, dry bool) (string, error)

func ApproveJob

func ApproveJob(ctx context.Context, opts Options, c clock.Clock, name string) error

ApproveJob enables firing and resumes an agent-created job; repeated approval is harmless.

func BoundedError

func BoundedError(err error) error

func CancelRun

func CancelRun(ctx context.Context, opts Options, c clock.Clock, id string) error

func CheckMCPWrite

func CheckMCPWrite(opts Options) error

CheckMCPWrite prevents a scheduled agent from recursively changing schedules.

func DefaultMemory

func DefaultMemory(opts Options) (bool, error)

DefaultMemory enables new jobs only when their configured mdkb is present.

func ErrorText

func ErrorText(err error) string

ErrorText bounds displayed diagnostics, including echoed user input. Keep the original error for exit codes and errors.Is/errors.As.

func Init

func Init(ctx context.Context, opts Options) error

Init creates directories, default settings and the ledger, preserving existing settings.

func LogTail

func LogTail(ctx context.Context, opts Options, c clock.Clock, id string, stderr bool) (string, error)

LogTail reads at most 64 KiB from the end of a ledger run's output.

func Logs

func Logs(ctx context.Context, opts Options, c clock.Clock, id string, stderr, follow bool, out io.Writer) error

func Memory

func Memory(ctx context.Context, opts Options, name string) (string, error)

Memory prints an existing job's note, without bootstrapping or modifying the KB.

func PauseJob

func PauseJob(ctx context.Context, opts Options, c clock.Clock, name string, paused bool) error

func QueueMessage

func QueueMessage(opts Options) string

func RemoveJob

func RemoveJob(ctx context.Context, opts Options, c clock.Clock, name string, dry bool) error

func Schedule

func Schedule(ctx context.Context, opts Options, c clock.Clock, loop bool, noWait bool, hup <-chan struct{}, log io.Writer) error

func Service

func Service(ctx context.Context, opts Options, action string, dry bool, target string) (any, error)

Types

type Error

type Error struct {
	Code ExitCode
	Err  error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ExitCode

type ExitCode int
const (
	OK ExitCode = iota
	Runtime
	Usage
	NotInitialized
	Locked
	Refused
	RunUnsuccessful
)

func Code

func Code(err error) ExitCode

type Fire

type Fire struct {
	Name string    `json:"name"`
	At   time.Time `json:"at"`
}

func NextFires

func NextFires(ctx context.Context, opts Options, c clock.Clock, expr, zone string, count int) ([]Fire, error)

type Health

type Health struct {
	Service       service.State `json:"service"`
	DaemonPID     int           `json:"daemon_pid"`
	ConfigDir     bool          `json:"config_dir"`
	DataDir       bool          `json:"data_dir"`
	SchemaVersion int           `json:"schema_version"`
	Git           bool          `json:"git"`
	Claude        bool          `json:"claude"`
	Codex         bool          `json:"codex"`
	MDKB          bool          `json:"mdkb"`
	MDKBVersion   string        `json:"mdkb_version"`
	KBRoot        string        `json:"kb_root"`
	KBInitialised bool          `json:"kb_initialised"`
	Warnings      []string      `json:"warnings,omitempty"`
	ConfigPath    string        `json:"-"`
	DataPath      string        `json:"-"`
}

func Doctor

func Doctor(ctx context.Context, opts Options) (Health, error)

Doctor inspects paths and executable presence without creating a missing ledger.

type Job

type Job = jobs.Job

func NewJob

func NewJob(name string) Job

type JobDetail

type JobDetail struct {
	Status string         `json:"status"`
	Error  string         `json:"error,omitempty"`
	Job    Job            `json:"job"`
	State  store.JobState `json:"state"`
	Next   []time.Time    `json:"next"`
	Runs   []store.Run    `json:"runs"`
}

func CreateMCPJob

func CreateMCPJob(ctx context.Context, opts Options, c clock.Clock, j Job) (JobDetail, error)

func ShowJob

func ShowJob(ctx context.Context, opts Options, c clock.Clock, name string) (JobDetail, error)

type JobView

type JobView struct {
	Status    string          `json:"status"`
	Name      string          `json:"name"`
	Job       *Job            `json:"job,omitempty"`
	State     *store.JobState `json:"state,omitempty"`
	Error     string          `json:"error,omitempty"`
	LastState string          `json:"last_state,omitempty"`
}

func ListJobs

func ListJobs(ctx context.Context, opts Options, c clock.Clock) ([]JobView, error)

type Options

type Options struct {
	ConfigDir string
	DataDir   string
	// ReadOnly evaluates pinned-time previews without changing persisted job state.
	ReadOnly bool
}

type Run

type Run = store.Run

func EnqueueMCPRun

func EnqueueMCPRun(ctx context.Context, opts Options, c clock.Clock, name string) (Run, error)

func Prune

func Prune(ctx context.Context, opts Options, c clock.Clock, dry, force bool) ([]Run, error)

func RunJob

func RunJob(ctx context.Context, opts Options, c clock.Clock, name string, now, wait bool) (Run, error)

func Runs

func Runs(ctx context.Context, opts Options, c clock.Clock, job, state string, limit int) ([]Run, error)

func Worktrees

func Worktrees(ctx context.Context, opts Options, c clock.Clock) ([]Run, error)

type RunOutput

type RunOutput struct {
	ID        string `json:"id"`
	Stream    string `json:"stream"`
	Output    string `json:"output"`
	Truncated bool   `json:"truncated"`
}

func TailOutput

func TailOutput(ctx context.Context, opts Options, c clock.Clock, id, stream string, tailBytes int) (RunOutput, error)

TailOutput reads at most tailBytes bytes, even while a runner appends output.

type TUI

type TUI struct {
	Options Options
	Clock   clock.Clock
}

TUI exposes the interactive use cases without exposing storage or runner internals.

func (TUI) Approve

func (a TUI) Approve(ctx context.Context, name string) error

func (TUI) Cancel

func (a TUI) Cancel(ctx context.Context, id string) error

func (TUI) DaemonRunning

func (a TUI) DaemonRunning(context.Context) (bool, error)

DaemonRunning uses the same lock-holder check as Doctor, without invoking service tools.

func (TUI) Enqueue

func (a TUI) Enqueue(ctx context.Context, name string) error

func (TUI) Jobs

func (a TUI) Jobs(ctx context.Context) ([]JobView, error)

func (TUI) Pause

func (a TUI) Pause(ctx context.Context, name string, paused bool) error

func (TUI) Runs

func (a TUI) Runs(ctx context.Context, name string) ([]Run, error)

func (TUI) Tail

func (a TUI) Tail(ctx context.Context, id string, stderr bool) (string, error)

Jump to

Keyboard shortcuts

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