cron

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCronMessage

func BuildCronMessage(jobID, jobName, message, timezone string) string

func ComputeNextRunAtMs

func ComputeNextRunAtMs(schedule Schedule, nowMs int64) *int64

func ExecuteTool

func ExecuteTool(ctx context.Context, args map[string]any, deps ToolExecDeps) (string, error)

func New

func ValidateDeliveryTo

func ValidateDeliveryTo(to string) error

func WrapSafeExternalPrompt

func WrapSafeExternalPrompt(message string) string

Types

type Delivery

type Delivery struct {
	Mode       DeliveryMode `json:"mode"`
	Channel    string       `json:"channel,omitempty"`
	To         string       `json:"to,omitempty"`
	BestEffort *bool        `json:"bestEffort,omitempty"`
}

type DeliveryMode

type DeliveryMode string
const (
	DeliveryNone     DeliveryMode = "none"
	DeliveryAnnounce DeliveryMode = "announce"
)

type DeliveryPatch

type DeliveryPatch struct {
	Mode       *DeliveryMode `json:"mode,omitempty"`
	Channel    *string       `json:"channel,omitempty"`
	To         *string       `json:"to,omitempty"`
	BestEffort *bool         `json:"bestEffort,omitempty"`
}

type DeliveryResolverDeps

type DeliveryResolverDeps struct {
	ResolveLastTarget   func(agentID string) (channel string, target string, ok bool)
	IsStaleTarget       func(roomID string, agentID string) bool
	LastActiveRoomID    func(agentID string) string
	DefaultChatRoomID   func() string
	ResolvePortalByRoom func(roomID string) any
	IsLoggedIn          func() bool
}

type DeliveryTarget

type DeliveryTarget struct {
	Portal  any
	RoomID  string
	Channel string
	Reason  string
}

func ResolveCronDeliveryTarget

func ResolveCronDeliveryTarget(agentID string, delivery *Delivery, deps DeliveryResolverDeps) DeliveryTarget

type Integration

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

func (*Integration) CommandDefinitions

func (*Integration) ExecuteCommand

func (i *Integration) ExecuteCommand(ctx context.Context, call iruntime.CommandCall) (bool, error)

func (*Integration) ExecuteTool

func (i *Integration) ExecuteTool(ctx context.Context, call iruntime.ToolCall) (bool, string, error)

func (*Integration) Name

func (i *Integration) Name() string

func (*Integration) Start

func (i *Integration) Start(context.Context) error

func (*Integration) Stop

func (i *Integration) Stop()

func (*Integration) ToolAvailability

func (i *Integration) ToolAvailability(_ context.Context, _ iruntime.ToolScope, toolName string) (bool, bool, iruntime.SettingSource, string)

func (*Integration) ToolDefinitions

type Job

type Job struct {
	ID             string    `json:"id"`
	AgentID        string    `json:"agentId,omitempty"`
	Name           string    `json:"name"`
	Description    string    `json:"description,omitempty"`
	Enabled        bool      `json:"enabled"`
	DeleteAfterRun bool      `json:"deleteAfterRun,omitempty"`
	CreatedAtMs    int64     `json:"createdAtMs"`
	UpdatedAtMs    int64     `json:"updatedAtMs"`
	Schedule       Schedule  `json:"schedule"`
	Payload        Payload   `json:"payload"`
	Delivery       *Delivery `json:"delivery,omitempty"`
	State          JobState  `json:"state"`
}

type JobCreate

type JobCreate struct {
	AgentID        *string   `json:"agentId,omitempty"`
	Name           string    `json:"name,omitempty"`
	Description    *string   `json:"description,omitempty"`
	Enabled        *bool     `json:"enabled,omitempty"`
	DeleteAfterRun *bool     `json:"deleteAfterRun,omitempty"`
	Schedule       Schedule  `json:"schedule"`
	Payload        Payload   `json:"payload"`
	Delivery       *Delivery `json:"delivery,omitempty"`
	State          *JobState `json:"state,omitempty"`
}

func NormalizeJobCreate

func NormalizeJobCreate(input JobCreate) JobCreate

func NormalizeJobCreateRaw

func NormalizeJobCreateRaw(raw any) (JobCreate, error)

type JobPatch

type JobPatch struct {
	AgentID        *string        `json:"agentId,omitempty"`
	Name           *string        `json:"name,omitempty"`
	Description    *string        `json:"description,omitempty"`
	Enabled        *bool          `json:"enabled,omitempty"`
	DeleteAfterRun *bool          `json:"deleteAfterRun,omitempty"`
	Schedule       *Schedule      `json:"schedule,omitempty"`
	Payload        *PayloadPatch  `json:"payload,omitempty"`
	Delivery       *DeliveryPatch `json:"delivery,omitempty"`
	State          *JobState      `json:"state,omitempty"`
}

func NormalizeJobPatchRaw

func NormalizeJobPatchRaw(raw any) (JobPatch, error)

type JobState

type JobState struct {
	NextRunAtMs    *int64 `json:"nextRunAtMs,omitempty"`
	RunningAtMs    *int64 `json:"runningAtMs,omitempty"`
	LastRunAtMs    *int64 `json:"lastRunAtMs,omitempty"`
	LastStatus     string `json:"lastStatus,omitempty"`
	LastError      string `json:"lastError,omitempty"`
	LastDurationMs *int64 `json:"lastDurationMs,omitempty"`
}

type Payload

type Payload struct {
	Kind                string `json:"kind"`
	Message             string `json:"message,omitempty"`
	Model               string `json:"model,omitempty"`
	Thinking            string `json:"thinking,omitempty"`
	TimeoutSeconds      *int   `json:"timeoutSeconds,omitempty"`
	AllowUnsafeExternal *bool  `json:"allowUnsafeExternalContent,omitempty"`
}

type PayloadPatch

type PayloadPatch struct {
	Kind                string  `json:"kind"`
	Message             *string `json:"message,omitempty"`
	Model               *string `json:"model,omitempty"`
	Thinking            *string `json:"thinking,omitempty"`
	TimeoutSeconds      *int    `json:"timeoutSeconds,omitempty"`
	AllowUnsafeExternal *bool   `json:"allowUnsafeExternalContent,omitempty"`
}

type ReminderContextLine

type ReminderContextLine struct {
	Role string
	Text string
}

type Schedule

type Schedule struct {
	Kind     string `json:"kind"`
	At       string `json:"at,omitempty"`
	EveryMs  int64  `json:"everyMs,omitempty"`
	AnchorMs *int64 `json:"anchorMs,omitempty"`
	Expr     string `json:"expr,omitempty"`
	TZ       string `json:"tz,omitempty"`
}

type TimestampValidationResult

type TimestampValidationResult struct {
	Ok      bool
	Message string
}

func ValidateSchedule

func ValidateSchedule(schedule Schedule) TimestampValidationResult

func ValidateScheduleTimestamp

func ValidateScheduleTimestamp(schedule Schedule, nowMs int64) TimestampValidationResult

type ToolCreateContext

type ToolCreateContext struct {
	AgentID        string
	SourceInternal bool
	SourceRoomID   string
}

type ToolExecDeps

type ToolExecDeps struct {
	Status func() (enabled bool, backend string, jobCount int, nextRun *int64, err error)
	List   func(includeDisabled bool) ([]Job, error)
	Add    func(input JobCreate) (Job, error)
	Update func(id string, patch JobPatch) (Job, error)
	Remove func(id string) (bool, error)
	Run    func(id string) (bool, string, error)

	NowMs                func() int64
	ResolveCreateContext func() ToolCreateContext
	ResolveReminderLines func(count int) []ReminderContextLine
	ValidateDeliveryTo   func(to string) error
}

Jump to

Keyboard shortcuts

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