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
- type LogHandler
- func (h *LogHandler) SendApprovalRequest(targets []chatbot.ApprovalTarget) (chatbot.ApprovalResultMap, error)
- func (h *LogHandler) SendChunk(content string, first, last bool, contentType string)
- func (h *LogHandler) SendComplete(message string)
- func (h *LogHandler) SendError(err string)
- func (h *LogHandler) SendMessageCount()
- func (h *LogHandler) SendThinking(status bool)
- func (h *LogHandler) SendToolCall(name string, arguments string, id string, streaming bool)
- type Scheduler
Constants ¶
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 ¶
NewScheduler creates a scheduler for the given configuration.