worker

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNeedsDecision = fmt.Errorf("needs manual decision")

ErrNeedsDecision indicates the worker needs manual intervention (exit code 1).

Functions

func CleanupDir

func CleanupDir() (string, error)

CleanupDir returns the path to ~/.ttal/cleanup/ (shared across all teams).

func ExecuteCleanup

func ExecuteCleanup(req CleanupRequest, path string, force bool) error

ExecuteCleanup processes a parsed cleanup request: sets team env, closes the worker, and removes the request file. Returns error for callers that need it (CLI). The force parameter controls whether worker.Close uses force mode.

func Gatekeeper

func Gatekeeper(cfg GatekeeperConfig) int

Gatekeeper runs a child command with deadman's switch behavior: - Reads task file and appends content to child args - Starts child in its own process group - Monitors for parent death (orphaning) - Handles signals (SIGTERM, SIGINT, SIGHUP) by killing child

func HookOnAdd

func HookOnAdd()

HookOnAdd handles the taskwarrior on-add event. Reads one JSON line from stdin, enriches inline if project is set, outputs to stdout.

func HookOnModify

func HookOnModify()

HookOnModify is the main taskwarrior on-modify hook entry point.

func Install

func Install() error

Install sets up the taskwarrior hooks (on-add and on-modify).

func List

func List() error

List queries active worker tasks and prints a table view.

func NotifyTelegram

func NotifyTelegram(message string)

NotifyTelegram sends a message to an agent's Telegram chat via the daemon. Uses From-only routing (daemon's handleFrom → Telegram Bot API). Fire-and-forget: errors are logged but not propagated. No-ops if config cannot be loaded (no guessing).

func PrintResult

func PrintResult(r *CloseResult)

PrintResult outputs the close result in a machine-parseable format matching the Python script's output format.

func RequestCleanup

func RequestCleanup(sessionID, taskUUID string) error

RequestCleanup writes a cleanup request file for the daemon to process. This is fire-and-forget — the file persists even if the daemon is down. All teams share a single cleanup dir (~/.ttal/cleanup/) — requests are globally unique.

func RunCleanup

func RunCleanup(path string, force bool) error

RunCleanup processes a single cleanup request file. Designed for manual invocation via `ttal worker cleanup`.

func RunPendingCleanups

func RunPendingCleanups(force bool) error

RunPendingCleanups processes all .json files in the cleanup directory.

func Spawn

func Spawn(cfg SpawnConfig) error

Spawn creates a new worker: validates task, sets up worktree, launches tmux session, and tracks the worker in taskwarrior.

func Uninstall

func Uninstall() error

Uninstall removes the taskwarrior hooks.

Types

type CleanupRequest

type CleanupRequest struct {
	SessionID string    `json:"session_id"`
	TaskUUID  string    `json:"task_uuid"`
	Team      string    `json:"team,omitempty"`
	CreatedAt time.Time `json:"created_at"`
}

CleanupRequest is written to ~/.ttal/cleanup/<session>.json by workers after merge.

type CloseResult

type CloseResult struct {
	Cleaned   bool
	Forced    bool
	Merged    string // "true", "false", "no_pr"
	Clean     bool
	Status    string
	StateDump string
	Error     bool
}

CloseResult holds the outcome of a close operation.

func Close

func Close(sessionID string, force bool) (*CloseResult, error)

Close handles worker cleanup with smart or force mode.

Exit semantics (reflected in the returned error and CloseResult):

nil error + Cleaned=true  → cleaned up successfully (exit 0)
ErrNeedsDecision          → needs manual decision (exit 1)
other error               → script/worker error (exit 2)

type GatekeeperConfig

type GatekeeperConfig struct {
	TaskFile string
	Command  []string
}

GatekeeperConfig holds configuration for the gatekeeper process.

type SpawnConfig

type SpawnConfig struct {
	Name     string
	Project  string
	TaskUUID string
	Worktree bool
	Force    bool
	Yolo     bool
	Runtime  runtime.Runtime
}

SpawnConfig holds configuration for spawning a worker.

type WorkerInfo

type WorkerInfo struct {
	Task   taskwarrior.Task
	Status WorkerStatus
}

WorkerInfo holds a worker task with its derived status.

type WorkerStatus

type WorkerStatus int

WorkerStatus represents the categorized status of a worker.

const (
	StatusRunning       WorkerStatus = iota // No PR yet
	StatusWithPR                            // PR created, not merged
	StatusCleanupNeeded                     // PR merged, needs cleanup
)

func (WorkerStatus) String

func (s WorkerStatus) String() string

Jump to

Keyboard shortcuts

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