cron

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 9 Imported by: 1 module, 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 cron implements scheduled (cron) task execution for chats.

Every chat preset may define a list of cron tasks (see config.CronTask). The Scheduler parses each task's 5-field cron expression and, on every tick, enqueues the task for that chat's worker; each worker executes its chat's tasks serially: the task hook runs first (its output must be JSON), the task prompt is rendered with the hook data and sent to the agent as the user message. Cron runs are always non-persistent.

Index

Constants

View Source
const CronSessionID = "cron"

CronSessionID is the dedicated session ID used for cron executions so that cron runs are isolated from interactive sessions.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogHandler

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

LogHandler is a chatbot.Handler that writes cron task output to the log instead of a client connection.

func NewLogHandler

func NewLogHandler(chatName, expr string) *LogHandler

NewLogHandler creates a log handler for cron task output.

func (*LogHandler) SendApprovalRequest

func (h *LogHandler) SendApprovalRequest(targets []chatbot.ApprovalTarget) (chatbot.ApprovalResultMap, error)

func (*LogHandler) SendChunk

func (h *LogHandler) SendChunk(content string, first, last bool, contentType string)

func (*LogHandler) SendComplete

func (h *LogHandler) SendComplete(message string)

func (*LogHandler) SendError

func (h *LogHandler) SendError(err string)

func (*LogHandler) SendMessageCount

func (h *LogHandler) SendMessageCount()

func (*LogHandler) SendThinking

func (h *LogHandler) SendThinking(status bool)

func (*LogHandler) SendToolCall

func (h *LogHandler) SendToolCall(name string, arguments string, id string, streaming bool)

type Scheduler

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

Scheduler runs cron tasks for all chats that define them.

func NewScheduler

func NewScheduler(cfg *config.Config) *Scheduler

NewScheduler creates a scheduler for the given configuration.

func (*Scheduler) Start

func (s *Scheduler) Start()

Start registers every chat's cron tasks and starts the scheduler. Chats with invalid or empty expressions are skipped with a warning.

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop stops the scheduler: it aborts in-flight executions, waits (bounded) for the task workers to finish and closes all cron chat sessions.

Jump to

Keyboard shortcuts

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