Documentation
¶
Overview ¶
Package task provides task management functionality.
Index ¶
- type APIClient
- func (c *APIClient) Delete(ctx context.Context, path string, headers map[string]string) (*APIResponse, error)
- func (c *APIClient) Get(ctx context.Context, path string, query map[string]string, ...) (*APIResponse, error)
- func (c *APIClient) Post(ctx context.Context, path string, body interface{}, headers map[string]string) (*APIResponse, error)
- func (c *APIClient) Put(ctx context.Context, path string, body interface{}, headers map[string]string) (*APIResponse, error)
- func (c *APIClient) Request(ctx context.Context, req APIRequest) (*APIResponse, error)
- func (c *APIClient) SetHeader(key, value string)
- func (c *APIClient) SetHeaders(headers map[string]string)
- type APIRequest
- type APIResponse
- type AdapterOption
- type AdapterOptions
- type AdapterService
- func (s *AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) AddTaskLog(ctx context.Context, taskID string, message string, level string) error
- func (s *AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) ApproveTaskPlan(ctx context.Context, taskID string, req AgentApprovalRequest) (AgentTask, error)
- func (s *AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) CreateTask(ctx context.Context, req AgentCreateRequest) (AgentTask, error)
- func (s *AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) GetTask(ctx context.Context, taskID string) (AgentTask, error)
- func (s *AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) ListTasks(ctx context.Context, userID string) ([]AgentTask, error)
- func (s *AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) UpdateTask(ctx context.Context, taskID string, conversationID string, ...) (AgentTask, error)
- type AgentTaskService
- func (s *AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) AddTaskLog(ctx context.Context, taskID string, message string, level string) error
- func (s *AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) ApproveTaskPlan(ctx context.Context, taskID string, req AgentApproveRequest) (AgentTask, error)
- func (s *AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) CreateTask(ctx context.Context, req AgentCreateRequest) (AgentTask, error)
- func (s *AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) GetTask(ctx context.Context, taskID string) (AgentTask, error)
- func (s *AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) ListTasks(ctx context.Context, userID string) ([]AgentTask, error)
- func (s *AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) UpdateTask(ctx context.Context, taskID string, conversationID string, ...) (AgentTask, error)
- type AgentTaskServiceInterface
- type ApproveTaskPlanRequest
- type CreateTaskRequest
- type DefaultApproveRequest
- type DefaultCreateRequest
- type DefaultStep
- type DefaultTask
- type DefaultTaskAdapter
- func (a *DefaultTaskAdapter) ConvertApproveRequest(req DefaultApproveRequest) ApproveTaskPlanRequest
- func (a *DefaultTaskAdapter) ConvertCreateRequest(req DefaultCreateRequest) CreateTaskRequest
- func (a *DefaultTaskAdapter) ConvertTask(sdkTask *Task) *DefaultTask
- func (a *DefaultTaskAdapter) ConvertTaskUpdates(updates []DefaultTaskUpdate) []TaskUpdate
- func (a *DefaultTaskAdapter) ConvertTasks(sdkTasks []*Task) []*DefaultTask
- type DefaultTaskUpdate
- type Executor
- func (e *Executor) CancelTask(ctx context.Context, taskID string) error
- func (e *Executor) ExecuteAsync(ctx context.Context, taskName string, params interface{}, ...) (<-chan *interfaces.TaskResult, error)
- func (e *Executor) ExecuteSync(ctx context.Context, taskName string, params interface{}, ...) (*interfaces.TaskResult, error)
- func (e *Executor) ExecuteWorkflow(ctx context.Context, workflowName string, params interface{}, ...) (*interfaces.TaskResult, error)
- func (e *Executor) ExecuteWorkflowAsync(ctx context.Context, workflowName string, params interface{}, ...) (<-chan *interfaces.TaskResult, error)
- func (e *Executor) GetTaskStatus(ctx context.Context, taskID string) (string, error)
- func (e *Executor) RegisterTask(name string, taskFunc TaskFunc)
- type InMemoryTaskService
- func (s *InMemoryTaskService) AddTaskLog(ctx context.Context, taskID string, message string, level string) error
- func (s *InMemoryTaskService) ApproveTaskPlan(ctx context.Context, taskID string, req ApproveTaskPlanRequest) (*Task, error)
- func (s *InMemoryTaskService) CreateTask(ctx context.Context, req CreateTaskRequest) (*Task, error)
- func (s *InMemoryTaskService) GetTask(ctx context.Context, taskID string) (*Task, error)
- func (s *InMemoryTaskService) ListTasks(ctx context.Context, filter TaskFilter) ([]*Task, error)
- func (s *InMemoryTaskService) UpdateTask(ctx context.Context, taskID string, updates []TaskUpdate) (*Task, error)
- type LogEntry
- type Plan
- type Service
- type Status
- type Step
- type Task
- type TaskAdapter
- type TaskExecutor
- type TaskFilter
- type TaskFunc
- type TaskPlanner
- type TaskUpdate
- type TemporalClient
- type TemporalConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
APIClient is a client for making API calls
func NewAPIClient ¶
NewAPIClient creates a new API client
func (*APIClient) Delete ¶
func (c *APIClient) Delete(ctx context.Context, path string, headers map[string]string) (*APIResponse, error)
Delete makes a DELETE request
func (*APIClient) Get ¶
func (c *APIClient) Get(ctx context.Context, path string, query map[string]string, headers map[string]string) (*APIResponse, error)
Get makes a GET request
func (*APIClient) Post ¶
func (c *APIClient) Post(ctx context.Context, path string, body interface{}, headers map[string]string) (*APIResponse, error)
Post makes a POST request
func (*APIClient) Put ¶
func (c *APIClient) Put(ctx context.Context, path string, body interface{}, headers map[string]string) (*APIResponse, error)
Put makes a PUT request
func (*APIClient) Request ¶
func (c *APIClient) Request(ctx context.Context, req APIRequest) (*APIResponse, error)
Request makes an API request
func (*APIClient) SetHeaders ¶
SetHeaders sets multiple headers for all requests
type APIRequest ¶
type APIRequest struct {
Method string
Path string
Body interface{}
Headers map[string]string
Query map[string]string
}
APIRequest represents an API request
type APIResponse ¶
APIResponse represents an API response
type AdapterOption ¶
type AdapterOption func(*AdapterOptions)
AdapterOption is a function that configures AdapterOptions
func WithDefaultUserID ¶
func WithDefaultUserID(userID string) AdapterOption
WithDefaultUserID sets a default user ID for task creation
func WithMetadata ¶
func WithMetadata(include bool) AdapterOption
WithMetadata configures the adapter to include SDK metadata in conversions
type AdapterOptions ¶
type AdapterOptions struct {
// Additional options can be added here as needed
IncludeMetadata bool
DefaultUserID string
}
AdapterOptions contains optional parameters for creating a task adapter
type AdapterService ¶
type AdapterService[AgentTask any, AgentCreateRequest any, AgentApprovalRequest any, AgentTaskUpdate any] struct { // contains filtered or unexported fields }
AdapterService provides a generic service for adapting between SDK tasks and agent-specific tasks. It wraps the SDK's task service and provides methods for working with agent-specific task models.
func NewAdapterService ¶
func NewAdapterService[AgentTask any, AgentCreateRequest any, AgentApprovalRequest any, AgentTaskUpdate any]( logger logging.Logger, sdkService Service, adapter TaskAdapter[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate], ) *AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]
NewAdapterService creates a new adapter service for adapting between SDK and agent-specific task models. It provides a simple way for agents to work with their own task models while leveraging the SDK's task service.
func (*AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) AddTaskLog ¶
func (s *AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) AddTaskLog( ctx context.Context, taskID string, message string, level string, ) error
AddTaskLog adds a log entry to a task.
func (*AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) ApproveTaskPlan ¶
func (s *AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) ApproveTaskPlan( ctx context.Context, taskID string, req AgentApprovalRequest, ) (AgentTask, error)
ApproveTaskPlan approves or rejects a task plan using the agent-specific approval model.
func (*AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) CreateTask ¶
func (s *AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) CreateTask( ctx context.Context, req AgentCreateRequest, ) (AgentTask, error)
CreateTask creates a new task using the agent-specific task model.
func (*AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) GetTask ¶
func (s *AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) GetTask( ctx context.Context, taskID string, ) (AgentTask, error)
GetTask retrieves a task by ID and returns it in the agent-specific format.
func (*AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) ListTasks ¶
func (s *AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) ListTasks( ctx context.Context, userID string, ) ([]AgentTask, error)
ListTasks returns all tasks for a user in the agent-specific format.
func (*AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) UpdateTask ¶
func (s *AdapterService[AgentTask, AgentCreateRequest, AgentApprovalRequest, AgentTaskUpdate]) UpdateTask( ctx context.Context, taskID string, conversationID string, updates []AgentTaskUpdate, ) (AgentTask, error)
UpdateTask updates an existing task using agent-specific task updates.
type AgentTaskService ¶
type AgentTaskService[AgentTask any, AgentCreateRequest any, AgentApproveRequest any, AgentTaskUpdate any] struct { // contains filtered or unexported fields }
AgentTaskService provides a complete implementation of AgentTaskServiceInterface Agents can use this directly without writing their own wrapper around AdapterService
func NewAgentTaskService ¶
func NewAgentTaskService[AgentTask any, AgentCreateRequest any, AgentApproveRequest any, AgentTaskUpdate any]( logger logging.Logger, sdkService Service, adapter TaskAdapter[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate], ) *AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]
NewAgentTaskService creates a new service that agents can use with their own models
func (*AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) AddTaskLog ¶
func (s *AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) AddTaskLog( ctx context.Context, taskID string, message string, level string, ) error
AddTaskLog adds a log entry to a task
func (*AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) ApproveTaskPlan ¶
func (s *AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) ApproveTaskPlan( ctx context.Context, taskID string, req AgentApproveRequest, ) (AgentTask, error)
ApproveTaskPlan approves or rejects a task plan
func (*AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) CreateTask ¶
func (s *AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) CreateTask( ctx context.Context, req AgentCreateRequest, ) (AgentTask, error)
CreateTask creates a new task
func (*AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) GetTask ¶
func (s *AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) GetTask( ctx context.Context, taskID string, ) (AgentTask, error)
GetTask retrieves a task by ID
func (*AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) ListTasks ¶
func (s *AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) ListTasks( ctx context.Context, userID string, ) ([]AgentTask, error)
ListTasks returns all tasks for a user
func (*AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) UpdateTask ¶
func (s *AgentTaskService[AgentTask, AgentCreateRequest, AgentApproveRequest, AgentTaskUpdate]) UpdateTask( ctx context.Context, taskID string, conversationID string, updates []AgentTaskUpdate, ) (AgentTask, error)
UpdateTask updates an existing task
type AgentTaskServiceInterface ¶
type AgentTaskServiceInterface[AgentTask any, AgentCreateRequest any, AgentApproveRequest any, AgentTaskUpdate any] interface { // CreateTask creates a new task CreateTask(ctx context.Context, req AgentCreateRequest) (AgentTask, error) // GetTask gets a task by ID GetTask(ctx context.Context, taskID string) (AgentTask, error) // ListTasks returns all tasks for a user ListTasks(ctx context.Context, userID string) ([]AgentTask, error) // ApproveTaskPlan approves or rejects a task plan ApproveTaskPlan(ctx context.Context, taskID string, req AgentApproveRequest) (AgentTask, error) // UpdateTask updates an existing task with new steps or modifications UpdateTask(ctx context.Context, taskID string, conversationID string, updates []AgentTaskUpdate) (AgentTask, error) // AddTaskLog adds a log entry to a task AddTaskLog(ctx context.Context, taskID string, message string, level string) error }
AgentTaskServiceInterface defines a standard interface that agents can implement This provides a clear pattern for agents to follow and ensures consistency
type ApproveTaskPlanRequest ¶
type ApproveTaskPlanRequest struct {
Approved bool `json:"approved"`
Feedback string `json:"feedback,omitempty"`
}
ApproveTaskPlanRequest represents the request to approve a task plan
type CreateTaskRequest ¶
type CreateTaskRequest struct {
Description string `json:"description"`
UserID string `json:"user_id"`
Title string `json:"title,omitempty"`
TaskKind string `json:"task_kind,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
CreateTaskRequest represents the request to create a new task
type DefaultApproveRequest ¶
type DefaultApproveRequest struct {
Approved bool `json:"approved"`
Feedback string `json:"feedback,omitempty"`
}
DefaultApproveRequest provides a standard approve request model
type DefaultCreateRequest ¶
type DefaultCreateRequest struct {
Description string `json:"description"`
UserID string `json:"user_id"`
Title string `json:"title,omitempty"`
TaskKind string `json:"task_kind,omitempty"`
}
DefaultCreateRequest provides a standard create request model
type DefaultStep ¶
type DefaultStep struct {
ID string `json:"id"`
Description string `json:"description"`
Status string `json:"status"`
StartTime *time.Time `json:"start_time,omitempty"`
EndTime *time.Time `json:"end_time,omitempty"`
Error string `json:"error,omitempty"`
Output string `json:"output,omitempty"`
}
DefaultStep represents a task step in the default model
type DefaultTask ¶
type DefaultTask struct {
ID string `json:"id"`
Description string `json:"description"`
Status string `json:"status"`
Title string `json:"title,omitempty"`
TaskKind string `json:"task_kind,omitempty"`
ConversationID string `json:"conversation_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
UserID string `json:"user_id"`
Steps []DefaultStep `json:"steps,omitempty"`
Requirements interface{} `json:"requirements,omitempty"`
Feedback string `json:"feedback,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
DefaultTask provides a standard agent task model that can be embedded or used directly
type DefaultTaskAdapter ¶
type DefaultTaskAdapter struct {
// contains filtered or unexported fields
}
DefaultTaskAdapter provides a standard implementation of TaskAdapter Agents can use this directly or embed it in their own adapter
func (*DefaultTaskAdapter) ConvertApproveRequest ¶
func (a *DefaultTaskAdapter) ConvertApproveRequest(req DefaultApproveRequest) ApproveTaskPlanRequest
ConvertApproveRequest converts a default approve request to an SDK approve request
func (*DefaultTaskAdapter) ConvertCreateRequest ¶
func (a *DefaultTaskAdapter) ConvertCreateRequest(req DefaultCreateRequest) CreateTaskRequest
ConvertCreateRequest converts a default create request to an SDK create request
func (*DefaultTaskAdapter) ConvertTask ¶
func (a *DefaultTaskAdapter) ConvertTask(sdkTask *Task) *DefaultTask
ConvertTask converts an SDK task to a default task
func (*DefaultTaskAdapter) ConvertTaskUpdates ¶
func (a *DefaultTaskAdapter) ConvertTaskUpdates(updates []DefaultTaskUpdate) []TaskUpdate
ConvertTaskUpdates converts default task updates to SDK task updates
func (*DefaultTaskAdapter) ConvertTasks ¶
func (a *DefaultTaskAdapter) ConvertTasks(sdkTasks []*Task) []*DefaultTask
ConvertTasks converts a slice of SDK tasks to a slice of default tasks
type DefaultTaskUpdate ¶
type DefaultTaskUpdate struct {
Type string `json:"type"`
StepID string `json:"step_id,omitempty"`
Description string `json:"description,omitempty"`
Status string `json:"status,omitempty"`
}
DefaultTaskUpdate provides a standard task update model
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor implements the TaskExecutor interface
func (*Executor) CancelTask ¶
CancelTask cancels a running task
func (*Executor) ExecuteAsync ¶
func (e *Executor) ExecuteAsync(ctx context.Context, taskName string, params interface{}, opts *interfaces.TaskOptions) (<-chan *interfaces.TaskResult, error)
ExecuteAsync executes a task asynchronously
func (*Executor) ExecuteSync ¶
func (e *Executor) ExecuteSync(ctx context.Context, taskName string, params interface{}, opts *interfaces.TaskOptions) (*interfaces.TaskResult, error)
ExecuteSync executes a task synchronously
func (*Executor) ExecuteWorkflow ¶
func (e *Executor) ExecuteWorkflow(ctx context.Context, workflowName string, params interface{}, opts *interfaces.TaskOptions) (*interfaces.TaskResult, error)
ExecuteWorkflow initiates a temporal workflow
func (*Executor) ExecuteWorkflowAsync ¶
func (e *Executor) ExecuteWorkflowAsync(ctx context.Context, workflowName string, params interface{}, opts *interfaces.TaskOptions) (<-chan *interfaces.TaskResult, error)
ExecuteWorkflowAsync initiates a temporal workflow asynchronously
func (*Executor) GetTaskStatus ¶
GetTaskStatus gets the status of a task
func (*Executor) RegisterTask ¶
RegisterTask registers a task function with the executor
type InMemoryTaskService ¶
type InMemoryTaskService struct {
// contains filtered or unexported fields
}
InMemoryTaskService implements the Service interface with an in-memory storage
func NewInMemoryTaskService ¶
func NewInMemoryTaskService(logger logging.Logger, planner TaskPlanner, executor TaskExecutor) *InMemoryTaskService
NewInMemoryTaskService creates a new in-memory task service
func (*InMemoryTaskService) AddTaskLog ¶
func (s *InMemoryTaskService) AddTaskLog(ctx context.Context, taskID string, message string, level string) error
AddTaskLog adds a log entry to a task
func (*InMemoryTaskService) ApproveTaskPlan ¶
func (s *InMemoryTaskService) ApproveTaskPlan(ctx context.Context, taskID string, req ApproveTaskPlanRequest) (*Task, error)
ApproveTaskPlan approves or rejects a task plan
func (*InMemoryTaskService) CreateTask ¶
func (s *InMemoryTaskService) CreateTask(ctx context.Context, req CreateTaskRequest) (*Task, error)
CreateTask creates a new task
func (*InMemoryTaskService) ListTasks ¶
func (s *InMemoryTaskService) ListTasks(ctx context.Context, filter TaskFilter) ([]*Task, error)
ListTasks returns tasks filtered by the provided criteria
func (*InMemoryTaskService) UpdateTask ¶
func (s *InMemoryTaskService) UpdateTask(ctx context.Context, taskID string, updates []TaskUpdate) (*Task, error)
UpdateTask updates an existing task with new steps or modifications
type LogEntry ¶
type LogEntry struct {
ID string `json:"id"`
TaskID string `json:"task_id"`
StepID string `json:"step_id,omitempty"` // Optional reference to a specific step
Message string `json:"message"`
Level string `json:"level"` // info, warning, error
Timestamp time.Time `json:"timestamp"`
}
LogEntry represents a log entry for a task
type Plan ¶
type Plan struct {
ID string `json:"id"`
TaskID string `json:"task_id"`
Steps []Step `json:"steps"`
CreatedAt time.Time `json:"created_at"`
ApprovedAt *time.Time `json:"approved_at,omitempty"`
IsApproved bool `json:"is_approved"`
}
Plan represents the execution plan for a task
type Service ¶
type Service interface {
// CreateTask creates a new task
CreateTask(ctx context.Context, req CreateTaskRequest) (*Task, error)
// GetTask gets a task by ID
GetTask(ctx context.Context, taskID string) (*Task, error)
// ListTasks returns tasks filtered by the provided criteria
ListTasks(ctx context.Context, filter TaskFilter) ([]*Task, error)
// ApproveTaskPlan approves or rejects a task plan
ApproveTaskPlan(ctx context.Context, taskID string, req ApproveTaskPlanRequest) (*Task, error)
// UpdateTask updates an existing task with new steps or modifications
UpdateTask(ctx context.Context, taskID string, updates []TaskUpdate) (*Task, error)
// AddTaskLog adds a log entry to a task
AddTaskLog(ctx context.Context, taskID string, message string, level string) error
}
Service defines the interface for task management
type Status ¶
type Status string
Status represents the current status of a task or step
type Step ¶
type Step struct {
ID string `json:"id"`
PlanID string `json:"plan_id"`
Description string `json:"description"`
Status Status `json:"status"`
Order int `json:"order"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
Error string `json:"error,omitempty"`
Output string `json:"output,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
Step represents a single step in an execution plan
type Task ¶
type Task struct {
ID string `json:"id"`
Description string `json:"description"`
Status Status `json:"status"`
Title string `json:"title,omitempty"`
TaskKind string `json:"task_kind,omitempty"`
ConversationID string `json:"conversation_id,omitempty"`
Plan *Plan `json:"plan,omitempty"`
Steps []Step `json:"steps,omitempty"` // Direct access to steps
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
UserID string `json:"user_id"`
Logs []LogEntry `json:"logs,omitempty"`
Requirements interface{} `json:"requirements,omitempty"` // JSON of TaskRequirements
Feedback string `json:"feedback,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"` // For extensibility
}
Task represents an infrastructure task to be executed
type TaskAdapter ¶
type TaskAdapter[AgentTask any, AgentCreateRequest any, AgentApprovalRequest any, AgentTaskUpdate any] interface { // ConvertCreateRequest converts an agent-specific create request to an SDK create request ConvertCreateRequest(req AgentCreateRequest) CreateTaskRequest // ConvertApproveRequest converts an agent-specific approve request to an SDK approve request ConvertApproveRequest(req AgentApprovalRequest) ApproveTaskPlanRequest // ConvertTaskUpdates converts agent-specific task updates to SDK task updates ConvertTaskUpdates(updates []AgentTaskUpdate) []TaskUpdate // ConvertTask converts an SDK task to an agent-specific task ConvertTask(sdkTask *Task) AgentTask // ConvertTasks converts a slice of SDK tasks to a slice of agent-specific tasks ConvertTasks(sdkTasks []*Task) []AgentTask }
TaskAdapter defines a generic interface for adapting SDK task models to agent-specific models and vice versa. This pattern helps separate the concerns of the SDK from agent-specific implementations.
Implementing this interface allows agents to use their own domain models while still leveraging the SDK's task management capabilities.
func NewDefaultTaskAdapter ¶
func NewDefaultTaskAdapter(logger logging.Logger) TaskAdapter[*DefaultTask, DefaultCreateRequest, DefaultApproveRequest, DefaultTaskUpdate]
NewDefaultTaskAdapter creates a new default task adapter
type TaskExecutor ¶
type TaskExecutor interface {
// ExecuteStep executes a single step in a task's plan
ExecuteStep(ctx context.Context, task *Task, step *Step) error
// ExecuteTask executes all steps in a task's plan
ExecuteTask(ctx context.Context, task *Task) error
}
TaskExecutor defines the interface for executing a task's plan
type TaskFilter ¶
type TaskFilter struct {
UserID string `json:"user_id,omitempty"`
ConversationID string `json:"conversation_id,omitempty"`
Status []Status `json:"status,omitempty"`
TaskKind string `json:"task_kind,omitempty"`
CreatedAfter *time.Time `json:"created_after,omitempty"`
CreatedBefore *time.Time `json:"created_before,omitempty"`
}
TaskFilter represents filters for querying tasks
type TaskFunc ¶
TaskFunc is a function that executes a task
func APITask ¶
func APITask(client *APIClient, req APIRequest) TaskFunc
APITask creates a task function for making an API request
func TemporalWorkflowAsyncTask ¶
func TemporalWorkflowAsyncTask(client *TemporalClient, workflowName string) TaskFunc
TemporalWorkflowAsyncTask creates a task function for executing a Temporal workflow asynchronously
func TemporalWorkflowTask ¶
func TemporalWorkflowTask(client *TemporalClient, workflowName string) TaskFunc
TemporalWorkflowTask creates a task function for executing a Temporal workflow
type TaskPlanner ¶
type TaskPlanner interface {
// CreatePlan creates a plan for a task
CreatePlan(ctx context.Context, task *Task) (string, error)
}
TaskPlanner defines the interface for planning a task
type TaskUpdate ¶
type TaskUpdate struct {
Type string `json:"type"` // add_step, modify_step, remove_step, add_comment, update_status
StepID string `json:"step_id,omitempty"`
Description string `json:"description,omitempty"`
Status string `json:"status,omitempty"`
}
TaskUpdate represents an update to a task
type TemporalClient ¶
type TemporalClient struct {
// contains filtered or unexported fields
}
TemporalClient is a client for Temporal
func NewTemporalClient ¶
func NewTemporalClient(config TemporalConfig) *TemporalClient
NewTemporalClient creates a new Temporal client
func (*TemporalClient) ExecuteWorkflow ¶
func (c *TemporalClient) ExecuteWorkflow(ctx context.Context, workflowName string, params interface{}) (*interfaces.TaskResult, error)
ExecuteWorkflow executes a Temporal workflow
func (*TemporalClient) ExecuteWorkflowAsync ¶
func (c *TemporalClient) ExecuteWorkflowAsync(ctx context.Context, workflowName string, params interface{}) (<-chan *interfaces.TaskResult, error)
ExecuteWorkflowAsync executes a Temporal workflow asynchronously
type TemporalConfig ¶
type TemporalConfig struct {
// HostPort is the host:port of the Temporal server
HostPort string
// Namespace is the Temporal namespace
Namespace string
// TaskQueue is the Temporal task queue
TaskQueue string
// WorkflowIDPrefix is the prefix for workflow IDs
WorkflowIDPrefix string
// WorkflowExecutionTimeout is the timeout for workflow execution
WorkflowExecutionTimeout time.Duration
// WorkflowRunTimeout is the timeout for workflow run
WorkflowRunTimeout time.Duration
// WorkflowTaskTimeout is the timeout for workflow task
WorkflowTaskTimeout time.Duration
}
TemporalConfig represents configuration for Temporal