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 ¶
- func Add(workspacePath string, t *Task)
- func CloseLinkedTodoBySession(sessionID string) int
- func LoadWorkspace(workspacePath string)
- func PatchMember(workspacePath, id string, idx int, sessionID, status string)
- func PatchStatus(workspacePath, id, status string)
- func Remove(workspacePath, id string)
- func ResetStaleRunning(workspacePath string)
- func Update(workspacePath string, t *Task)
- func Workspaces() []string
- type Step
- type Task
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseLinkedTodoBySession ¶
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 ¶
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 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 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 ¶
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 ¶
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.