Documentation
¶
Index ¶
- Variables
- type CreateRunCmd
- type CreateTaskCmd
- type QuotaChecker
- type QuotaExceededError
- type RetryResult
- type RetryRunCmd
- type Service
- func (s *Service) CreateRun(ctx context.Context, cmd CreateRunCmd) (*model.TaskRun, error)
- func (s *Service) CreateTask(ctx context.Context, cmd CreateTaskCmd) (*model.Task, error)
- func (s *Service) RetryRun(ctx context.Context, cmd RetryRunCmd) (*RetryResult, error)
- func (s *Service) StartBackgroundTask(ctx context.Context, cmd CreateTaskCmd) (*StartBackgroundTaskResult, error)
- type StartBackgroundTaskResult
- type WorkflowStepLookup
Constants ¶
This section is empty.
Variables ¶
var ( ErrInputRequired = apierr.New(apierr.KindInvalid, "input required") ErrAgentsNotConfigured = apierr.New(apierr.KindNotConfigured, "agents not configured") ErrTasksNotConfigured = apierr.New(apierr.KindNotConfigured, "tasks not configured") ErrTaskRunsNotConfigured = apierr.New(apierr.KindNotConfigured, "task runs not configured") ErrAgentNotFound = apierr.New(apierr.KindInvalid, "agent not found") ErrTaskNotFound = apierr.New(apierr.KindNotFound, "task not found") // ErrNoRunToRetry means the task has no finished run to repeat: it has // never run, or its only run is still in flight. ErrNoRunToRetry = apierr.New(apierr.KindConflict, "this task has no finished run to retry") // ErrRetryOfWorkflowStep means the task belongs to a workflow step. The // workflow owns that task's lifecycle — it reacts to the step run's // outcome — so a run started behind its back would mark a settled step // succeeded and dispatch the next step of a workflow run that is already // over. ErrRetryOfWorkflowStep = apierr.New(apierr.KindConflict, "this run belongs to a workflow step and cannot be retried on its own") )
Functions ¶
This section is empty.
Types ¶
type CreateRunCmd ¶
type CreateRunCmd struct {
UserID string
TaskID string
Input string
CreatedByType string
TriggerSource string
// RetryOfTaskRunID names the run this one repeats, when it repeats one.
RetryOfTaskRunID *string
// SourceMessageID names the conversation message that asked for this run.
SourceMessageID *string
}
CreateRunCmd creates a new run on an existing task.
type CreateTaskCmd ¶
type CreateTaskCmd struct {
ConversationID string
UserID string
TeamID string
Input string
AgentID *string
IssueID *string
CreatedByType string
TriggerSource string
// SourceMessageID names the conversation message that asked for this task.
SourceMessageID *string
}
CreateTaskCmd creates a new task and its first run.
type QuotaChecker ¶
type QuotaChecker interface {
Check(ctx context.Context, teamID string, runsToAdd, tokensToAdd int) (allowed bool, reason string)
}
QuotaChecker is the narrow quota surface needed by task workflows.
type QuotaExceededError ¶
type QuotaExceededError struct {
Reason string
}
QuotaExceededError is returned when quota blocks a task operation.
func (*QuotaExceededError) Error ¶
func (e *QuotaExceededError) Error() string
type RetryResult ¶
RetryResult reports the new run and the one it repeats.
type RetryRunCmd ¶
RetryRunCmd repeats a task's most recent run.
type Service ¶
type Service struct {
Agents model.AgentStore
Tasks model.TaskStore
TaskRuns model.TaskRunStore
QuotaChecker QuotaChecker
TitleGenerator llm.TitleGenerator
// WorkflowSteps is only consulted by RetryRun. Callers that never retry
// leave it nil.
WorkflowSteps WorkflowStepLookup
}
Service owns task-related application workflows.
func (*Service) CreateRun ¶
CreateRun enforces basic run creation rules and delegates to TaskRunStore.
func (*Service) CreateTask ¶
CreateTask resolves input, applies title/quota rules, and persists a new task.
func (*Service) RetryRun ¶
func (s *Service) RetryRun(ctx context.Context, cmd RetryRunCmd) (*RetryResult, error)
RetryRun repeats a task's most recent run with the same input.
The input comes from the run rather than the task because a task's later runs can carry follow-up instructions, and retrying means running that again — not running whatever the task was first asked to do.
A run still in flight is not retried: one task holds at most one active run, and the answer to "it is taking too long" is to stop it first.
func (*Service) StartBackgroundTask ¶
func (s *Service) StartBackgroundTask(ctx context.Context, cmd CreateTaskCmd) (*StartBackgroundTaskResult, error)
StartBackgroundTask creates a task and returns its task/run ids.
type StartBackgroundTaskResult ¶
StartBackgroundTaskResult is returned when a background task is created.
type WorkflowStepLookup ¶
type WorkflowStepLookup interface {
GetWorkflowStepRunByTaskID(ctx context.Context, taskID string) (*model.WorkflowStepRun, error)
}
WorkflowStepLookup answers whether a task is a workflow step's task. It is optional: a deployment with no workflow store has no workflow steps, so a nil lookup means nothing to protect rather than an unanswered question.