cron

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package cron hosts the recurring-schedule prompt tools: cron_create, cron_list, cron_delete. They share the alarm package's Scheduler — a cron job is an alarm.Alarm with a non-empty CronExpr — so cron jobs and one-shot alarms coexist in one timer set, one durable store, and one fire path (WakeupQueue enqueue + idle-wake) the agent already wires for alarms.

remote_trigger lives here for parity with the reference source but is an unrelated HTTP-client feature and remains a stub.

Index

Constants

This section is empty.

Variables

View Source
var Trigger tools.Tool = tools.NewStub(
	tools.REMOTE_TRIGGER,
	"Call the remote-trigger API. Use this instead of curl — the OAuth token is added automatically in-process and never exposed. "+
		"Actions: list (GET all), get (GET one), create (POST new — requires body), "+
		"update (POST partial update — requires body), run (POST /run — optional body). "+
		"Returns raw JSON from the API.",
	`{
		"type":"object",
		"additionalProperties":false,
		"required":["action"],
		"properties":{
			"action":{"type":"string","enum":["list","get","create","update","run"],"description":"API operation to perform."},
			"trigger_id":{"type":"string","pattern":"^[\\w-]+$","description":"Required for get, update, and run."},
			"body":{"type":"object","additionalProperties":{},"propertyNames":{"type":"string"},"description":"Required for create and update; optional for run."}
		}
	}`,
)

Trigger remains a stub — remote_trigger is an unrelated remote-API client, out of scope for cron scheduling (PRD §5.6/§6).

Functions

func Names

func Names() []tools.ToolName

Names lists every tool name this package contributes.

func Next added in v1.8.0

func Next(expr string, after time.Time) (time.Time, error)

Next returns the first activation strictly after `after` for a 5-field cron expression. It is the adapter the toolset wires into the alarm scheduler's CronNext seam, keeping the scheduler itself free of any cron-engine import.

Types

type CreateTool added in v1.8.0

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

CreateTool implements CRON_CREATE. Execute is non-blocking: it arms a recurring (or one-shot) timer on the shared alarm Scheduler and returns.

func NewCreate added in v1.8.0

func NewCreate(s *alarm.Scheduler) *CreateTool

NewCreate constructs a CRON_CREATE tool bound to the shared scheduler — the same instance whose fire callback Enqueues the prompt and wakes the loop.

func (*CreateTool) Description added in v1.8.0

func (t *CreateTool) Description() string

func (*CreateTool) Execute added in v1.8.0

func (t *CreateTool) Execute(_ context.Context, logger *slog.Logger, input json.RawMessage) (tools.Result, error)

func (*CreateTool) Name added in v1.8.0

func (t *CreateTool) Name() string

func (*CreateTool) Schema added in v1.8.0

func (t *CreateTool) Schema() json.RawMessage

type DeleteTool added in v1.8.0

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

DeleteTool implements CRON_DELETE.

func NewDelete added in v1.8.0

func NewDelete(s *alarm.Scheduler) *DeleteTool

NewDelete constructs a CRON_DELETE tool bound to the shared scheduler.

func (*DeleteTool) Description added in v1.8.0

func (t *DeleteTool) Description() string

func (*DeleteTool) Execute added in v1.8.0

func (t *DeleteTool) Execute(_ context.Context, logger *slog.Logger, input json.RawMessage) (tools.Result, error)

func (*DeleteTool) Name added in v1.8.0

func (t *DeleteTool) Name() string

func (*DeleteTool) Schema added in v1.8.0

func (t *DeleteTool) Schema() json.RawMessage

type Expr added in v1.8.0

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

Expr is a parsed 5-field cron expression (minute hour day-of-month month day-of-week). It is a plain comparable value safe for concurrent use.

The parser supports *, */n, n, a-b, a-b/n, and comma lists. Day-of-month and day-of-week follow standard cron OR semantics (when both are restricted, a day matches if EITHER matches). No external dependency — the engine is self-contained.

func ParseExpr added in v1.8.0

func ParseExpr(spec string) (Expr, error)

ParseExpr parses a standard 5-field cron expression. Returns an error for unsupported syntax (@-aliases, TZ= prefix, 6-field, L/W/#/? specials).

func (Expr) NextAfter added in v1.8.0

func (c Expr) NextAfter(after time.Time) (time.Time, error)

NextAfter returns the first activation strictly after `after`, in Local time. Steps minute-by-minute, bounded to ~5 years so an impossible spec (e.g. Feb 30) returns an error instead of looping forever.

type ListTool added in v1.8.0

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

ListTool implements CRON_LIST.

func NewList added in v1.8.0

func NewList(s *alarm.Scheduler) *ListTool

NewList constructs a CRON_LIST tool bound to the shared scheduler.

func (*ListTool) Description added in v1.8.0

func (t *ListTool) Description() string

func (*ListTool) Execute added in v1.8.0

func (t *ListTool) Execute(_ context.Context, _ *slog.Logger, _ json.RawMessage) (tools.Result, error)

func (*ListTool) Name added in v1.8.0

func (t *ListTool) Name() string

func (*ListTool) Schema added in v1.8.0

func (t *ListTool) Schema() json.RawMessage

Jump to

Keyboard shortcuts

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