todo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package todo provides persistent storage and scheduling for TodoTask workflows. Tasks are stored per-workspace in .agent/todo_tasks.json and survive sidecar restarts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(workspacePath string, t *Task)

Add persists a new task for the workspace.

func CloseLinkedTodoBySession

func CloseLinkedTodoBySession(sessionID string) int

CloseLinkedTodoBySession marks any todo whose step or lead session matches sessionID as failed and persists it. It returns the number of todos updated.

func LoadWorkspace

func LoadWorkspace(workspacePath string)

LoadWorkspace eagerly loads (or no-ops if already loaded) the task store for a workspace. Call this when the client sends register_workspace so the scheduler can find tasks without waiting for the first add/list command.

func PatchMember

func PatchMember(workspacePath, id string, idx int, sessionID, status string)

PatchMember atomically updates a single team member's session ID and/or status at the given index (position in TeamAgentIDs). Slices are grown as needed. Pass an empty string to leave either field unchanged.

func PatchStatus

func PatchStatus(workspacePath, id, status string)

PatchStatus atomically updates just the Status field.

func Remove

func Remove(workspacePath, id string)

Remove deletes a task from the store.

func ResetStaleRunning

func ResetStaleRunning(workspacePath string)

ResetStaleRunning resets tasks that are stuck in "running" after a sidecar crash. Linked todos (mode=="single" with step.sessionId set, or mode=="team" with leadSessionId set) are left alone — the frontend will patch them via patchTodoStatus when their chat session completes. True runner tasks whose steps never got a session ID are reset to "pending" so they can be restarted.

func Update

func Update(workspacePath string, t *Task)

Update replaces the stored task (full replacement).

func Workspaces

func Workspaces() []string

Workspaces returns the loaded workspace paths. It is safe to call concurrently.

Types

type Step

type Step struct {
	ID          string `json:"id"`
	AgentID     string `json:"agentId"`
	Instruction string `json:"instruction,omitempty"`
	OnComplete  string `json:"onComplete"` // "next" | "finish"
	OnFail      string `json:"onFail"`     // "next" | "finish"
	Status      string `json:"status"`     // "pending" | "running" | "done" | "failed" | "skipped"
	SessionID   string `json:"sessionId,omitempty"`
	// Provider/model resolved at task-creation time from agent config.
	Provider string `json:"provider,omitempty"`
	Model    string `json:"model,omitempty"`
}

Step mirrors the Angular TodoStep shape plus resolved execution fields.

type Task

type Task struct {
	ID               string   `json:"id"`
	Name             string   `json:"name"`
	Description      string   `json:"description"`
	Mode             string   `json:"mode"` // "single" | "team"
	Steps            []Step   `json:"steps,omitempty"`
	LeadAgentID      string   `json:"leadAgentId,omitempty"`
	TeamAgentIDs     []string `json:"teamAgentIds,omitempty"`
	Status           string   `json:"status"` // "pending" | "running" | "done" | "failed"
	CurrentStepIndex int      `json:"currentStepIndex"`
	CreatedAt        string   `json:"createdAt"`
	ShellAutoAllow   bool     `json:"shellAutoAllow,omitempty"`
	ScheduleType     string   `json:"scheduleType,omitempty"` // "instant" | "scheduled" | "cron"
	ScheduledAt      string   `json:"scheduledAt,omitempty"`  // RFC3339
	Cron             string   `json:"cron,omitempty"`         // cron expression (5-field)
	WorkspacePath    string   `json:"workspacePath"`
	// Resolved provider/model for team-mode lead agent.
	LeadProvider string `json:"leadProvider,omitempty"`
	LeadModel    string `json:"leadModel,omitempty"`
	// Session ID of the lead agent's execution session (team mode only).
	LeadSessionID string `json:"leadSessionId,omitempty"`
	// MemberSessionIDs tracks the session created for each team member (indexed by
	// position in TeamAgentIDs). Empty string means not yet delegated.
	MemberSessionIDs []string `json:"memberSessionIds,omitempty"`
	// MemberStatuses tracks individual member execution status, same index order as TeamAgentIDs.
	MemberStatuses []string `json:"memberStatuses,omitempty"`
}

Task mirrors the Angular TodoTask shape plus sidecar execution metadata.

func DueTasks

func DueTasks() []*Task

DueTasks returns tasks that are pending+scheduled and past their scheduledAt time. It ranges over every loaded workspace store, so LoadWorkspace must have been called for each workspace that should participate in scheduling.

func FindByLeadSession

func FindByLeadSession(workspacePath, sessionID string) *Task

FindByLeadSession returns the first team-mode task whose LeadSessionID matches sessionID, or nil if none is found. Used by runAgentTask to auto-close a chat-linked todo when the lead session ends.

func FindByStepSession

func FindByStepSession(workspacePath, sessionID string) (*Task, int)

FindByStepSession returns the first task that has a step whose SessionID matches sessionID, along with that step's index. Returns nil if not found. Used by runAgentTask to auto-close a chat-linked single-step todo.

func Get

func Get(workspacePath, id string) (*Task, bool)

Get returns a copy of a single task, and false if not found.

func List

func List(workspacePath string) []*Task

List returns all tasks for the workspace (copies, safe to mutate).

Jump to

Keyboard shortcuts

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