This repository has been archived on 2026-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
go-agentic/submit.go
Snider 8d2c3708b0
All checks were successful
Security Scan / security (push) Successful in 15s
Test / test (push) Successful in 6m47s
refactor: swap pkg/{io,log,i18n} imports to go-io/go-log/go-i18n
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-06 12:35:42 +00:00

35 lines
849 B
Go

package agentic
import (
"context"
"time"
"forge.lthn.ai/core/go-log"
)
// SubmitTask creates a new task with the given parameters via the API client.
// It validates that title is non-empty, sets CreatedAt to the current time,
// and delegates creation to client.CreateTask.
func SubmitTask(ctx context.Context, client *Client, title, description string, labels []string, priority TaskPriority) (*Task, error) {
const op = "agentic.SubmitTask"
if title == "" {
return nil, log.E(op, "title is required", nil)
}
task := Task{
Title: title,
Description: description,
Labels: labels,
Priority: priority,
Status: StatusPending,
CreatedAt: time.Now().UTC(),
}
created, err := client.CreateTask(ctx, task)
if err != nil {
return nil, log.E(op, "failed to create task", err)
}
return created, nil
}