scheduler

package
v0.182.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBackgroundTaskRegistry

func NewBackgroundTaskRegistry(maxConcurrentShells int, supervisor *jobs.Supervisor) scheddomain.BackgroundTaskRegistry

NewBackgroundTaskRegistry constructs the unified registry. maxConcurrentShells is the per-session cap enforced by the underlying shell tracker. supervisor is the single fan-in that monitors submitted jobs and backs the unified job surface (Submit/Snapshot/Wind).

func ParseCron

func ParseCron(expr string) error

ParseCron is a package-level helper for callers that don't have a Service instance yet (e.g. validation in the Schedule tool's Validate method).

Types

type BackgroundJobManager

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

BackgroundJobManager manages background tasks

func NewBackgroundJobManager

func NewBackgroundJobManager(titleGenerator scheddomain.TitleGenerator, config *config.Config) *BackgroundJobManager

NewBackgroundJobManager creates a new background job manager

func (*BackgroundJobManager) IsRunning

func (m *BackgroundJobManager) IsRunning() bool

IsRunning returns whether the job manager is currently running

func (*BackgroundJobManager) Start

func (m *BackgroundJobManager) Start(ctx context.Context)

Start begins running background jobs

func (*BackgroundJobManager) Stop

func (m *BackgroundJobManager) Stop()

Stop stops all background jobs gracefully

func (*BackgroundJobManager) TriggerTitleGeneration

func (m *BackgroundJobManager) TriggerTitleGeneration(ctx context.Context) error

TriggerTitleGeneration manually triggers title generation for pending conversations

type BackgroundShellService

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

BackgroundShellService is the thin front-end for background bash shells: it detaches a running command (registering it so the bash tools can read its output), submits a shellJob to the supervisor (which monitors it, notifies the agent, and reaps it), and brokers output retrieval and cancellation. The completion monitoring and reaping that used to live here are now the supervisor's job.

func NewBackgroundShellService

func NewBackgroundShellService(
	tracker scheddomain.ShellTracker,
	supervisor *jobs.Supervisor,
	cfg *config.Config,
	eventChannel chan<- agentdomain.ChatEvent,
) *BackgroundShellService

NewBackgroundShellService creates a new background shell service. supervisor monitors and reaps each detached shell.

func (*BackgroundShellService) CancelShell

func (s *BackgroundShellService) CancelShell(shellID string) error

CancelShell cancels a running background shell. It hands the kill to the supervisor (WindStop -> SIGKILL); the shellJob's Run then records the Cancelled state and the supervisor delivers the completion notification, so the process is waited on in exactly one place.

func (*BackgroundShellService) DetachToBackground

func (s *BackgroundShellService) DetachToBackground(
	ctx context.Context,
	cmd *exec.Cmd,
	command string,
	outputBuffer scheddomain.OutputRingBuffer,
	readersDone <-chan struct{},
) (string, error)

DetachToBackground moves a running command to background

func (*BackgroundShellService) GetAllShells

func (s *BackgroundShellService) GetAllShells() []*scheddomain.BackgroundShell

GetAllShells returns all tracked shells

func (*BackgroundShellService) GetShell

GetShell returns a specific shell by ID

func (*BackgroundShellService) GetShellOutput

func (s *BackgroundShellService) GetShellOutput(shellID string, fromOffset int64) (string, int64, scheddomain.ShellState, error)

GetShellOutput retrieves incremental output from a shell

func (*BackgroundShellService) GetShellOutputWithFilter

func (s *BackgroundShellService) GetShellOutputWithFilter(shellID string, fromOffset int64, filterPattern string) (string, int64, scheddomain.ShellState, error)

GetShellOutputWithFilter retrieves output with optional regex filtering

func (*BackgroundShellService) GetStats

func (s *BackgroundShellService) GetStats() map[string]int

GetStats returns statistics about background shells

func (*BackgroundShellService) RemoveShell

func (s *BackgroundShellService) RemoveShell(shellID string) error

RemoveShell removes a shell from tracking

func (*BackgroundShellService) Stop

func (s *BackgroundShellService) Stop()

Stop is retained for the lifecycle contract. The supervisor owns the monitor goroutines and the cleanup ticker now, so there is nothing to stop here.

type BackgroundTaskService

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

BackgroundTaskService handles background task operations (A2A-specific) Only instantiated when A2A tools are enabled

func NewBackgroundTaskService

func NewBackgroundTaskService(taskTracker agentdomain.A2ATaskTracker, jobs a2aJobController) *BackgroundTaskService

NewBackgroundTaskService creates a new background task service. jobs is the job supervisor - the single source of truth for which A2A tasks are running - while taskTracker still resolves the context graph and a task's agent URL for cancel.

func (*BackgroundTaskService) CancelBackgroundTask

func (s *BackgroundTaskService) CancelBackgroundTask(taskID string) error

CancelBackgroundTask cancels a background task by task ID

func (*BackgroundTaskService) GetBackgroundTasks

func (s *BackgroundTaskService) GetBackgroundTasks() []agentdomain.TaskPollingState

GetBackgroundTasks returns the active A2A tasks from the job supervisor - the single source of truth shared with the status-bar indicator - so the /tasks active list and the indicator can no longer diverge.

type Options

type Options struct {
	Store       storage.ScheduledJobStorage
	Runs        storage.ScheduledRunStorage
	OnRunEvent  func(scheddomain.ScheduledJob, scheddomain.RunEvent)
	ExecCommand agentrunner.ExecFunc
	BinaryPath  string
}

Options bundles dependencies and configuration for NewService.

type ScheduleNotifier

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

ScheduleNotifier delivers scheduled-job run output to the job's delivery channel. It subscribes to the scheduler's run events (Options.OnRunEvent); jobs without a delivery target are record-only, so their events are ignored here and their output lives in storage.

func NewScheduleNotifier

func NewScheduleNotifier(lookup func(name string) channels.Channel) *ScheduleNotifier

NewScheduleNotifier constructs a notifier resolving channels through lookup (typically ChannelManagerService.GetChannel).

func (*ScheduleNotifier) Notify

Notify implements the scheduler's OnRunEvent hook.

type Service

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

Service runs scheduled jobs inside the `infer daemon` process. Jobs are loaded from the configured ScheduledJobStorage, registered with a robfig/cron scheduler, and hot-reloaded by polling the storage and diffing (reconcile).

On fire, a fresh `infer headless --session-id <uuid>` subprocess is spawned - every fire gets a brand-new session, so no context carries between runs. A RunRecord is persisted per fire (keyed by that session ID, so the run's conversation is discoverable from storage), and progress is emitted through the optional OnRunEvent hook. The scheduler knows nothing about channels - delivery is a subscriber concern (see services.ScheduleNotifier).

func NewService

func NewService(opts Options) (*Service, error)

NewService constructs a Service. Returns an error if required deps are missing.

func (*Service) JobIDs

func (s *Service) JobIDs() []string

JobIDs returns the set of currently-registered job IDs (test helper).

func (*Service) ParseCron

func (s *Service) ParseCron(expr string) error

ParseCron exposes the same parser the service uses, so the Schedule tool can validate cron expressions identically before persisting them.

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

Start initialises the cron scheduler, loads all jobs from storage, and begins polling storage for changes.

func (*Service) Stop

func (s *Service) Stop(ctx context.Context) error

Stop halts the watcher and waits for in-flight cron entries to finish (up to the deadline embedded in ctx, if any).

type TaskRetentionService

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

TaskRetentionService manages in-memory retention of completed/terminal A2A tasks

func NewTaskRetentionService

func NewTaskRetentionService(maxRetention int) *TaskRetentionService

NewTaskRetentionService creates a new task retention service

func (*TaskRetentionService) AddTask

func (t *TaskRetentionService) AddTask(task scheddomain.TaskInfo)

AddTask adds a terminal task (completed, failed, canceled, etc.) to retention

func (*TaskRetentionService) Clear

func (t *TaskRetentionService) Clear()

Clear removes all retained tasks

func (*TaskRetentionService) GetMaxRetention

func (t *TaskRetentionService) GetMaxRetention() int

GetMaxRetention returns the current maximum retention count

func (*TaskRetentionService) GetTasks

func (t *TaskRetentionService) GetTasks() []scheddomain.TaskInfo

GetTasks returns all retained tasks

func (*TaskRetentionService) SetMaxRetention

func (t *TaskRetentionService) SetMaxRetention(maxRetention int)

SetMaxRetention updates the maximum retention count

Directories

Path Synopsis
Package githubscheduler implements the "github" scheduling backend: each scheduled job is materialized as a GitHub Actions scheduled workflow in a user-configured repository, deployed via pull requests.
Package githubscheduler implements the "github" scheduling backend: each scheduled job is materialized as a GitHub Actions scheduled workflow in a user-configured repository, deployed via pull requests.
Package heartbeat implements a periodic "wake-up" service that spawns the agent on a fixed interval to check for pending work.
Package heartbeat implements a periodic "wake-up" service that spawns the agent on a fixed interval to check for pending work.
Package jobs provides the Supervisor: the single, long-lived owner of every background-work monitor goroutine in an agent session.
Package jobs provides the Supervisor: the single, long-lived owner of every background-work monitor goroutine in an agent session.

Jump to

Keyboard shortcuts

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