NewTask creates a new task with the given parameters
(agentName, prompt string, scheduleType ScheduleType, scheduleValue string)
| 77 | |
| 78 | // NewTask creates a new task with the given parameters |
| 79 | func NewTask(agentName, prompt string, scheduleType ScheduleType, scheduleValue string) (*Task, error) { |
| 80 | task := &Task{ |
| 81 | ID: uuid.New().String(), |
| 82 | AgentName: agentName, |
| 83 | Prompt: prompt, |
| 84 | ScheduleType: scheduleType, |
| 85 | ScheduleValue: scheduleValue, |
| 86 | Status: TaskStatusActive, |
| 87 | CreatedAt: time.Now(), |
| 88 | UpdatedAt: time.Now(), |
| 89 | ContextMode: "agent", |
| 90 | Metadata: make(map[string]interface{}), |
| 91 | } |
| 92 | |
| 93 | if err := task.CalculateNextRun(); err != nil { |
| 94 | return nil, err |
| 95 | } |
| 96 | |
| 97 | return task, nil |
| 98 | } |
| 99 | |
| 100 | // CalculateNextRun calculates the next run time based on schedule type |
| 101 | func (t *Task) CalculateNextRun() error { |
no test coverage detected
searching dependent graphs…