Documentation
¶
Index ¶
- 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 CoreAdapter
- func (a *CoreAdapter) CoreTaskToTask(coreTask *core.Task) interface{}
- func (a *CoreAdapter) CreateLog(taskID, message, level string) *core.Log
- func (a *CoreAdapter) CreateStep(taskID, description, stepType string, orderIndex int) *core.Step
- func (a *CoreAdapter) CreateTaskFromDetails(name, description, userID string, metadata map[string]interface{}) *core.Task
- func (a *CoreAdapter) CreateTaskRequestToCore(req interface{}) core.CreateTaskRequest
- func (a *CoreAdapter) UpdateTaskStatusFromStep(task *core.Task)
- type CoreBridgeAdapter
- func (a *CoreBridgeAdapter) AddTaskLog(ctx context.Context, taskID string, message string, level string) error
- func (a *CoreBridgeAdapter) ApproveTaskPlan(ctx context.Context, taskID string, req task.ApproveTaskPlanRequest) (*task.Task, error)
- func (a *CoreBridgeAdapter) CreateTask(ctx context.Context, req task.CreateTaskRequest) (*task.Task, error)
- func (a *CoreBridgeAdapter) GetTask(ctx context.Context, taskID string) (*task.Task, error)
- func (a *CoreBridgeAdapter) ListTasks(ctx context.Context, filter task.TaskFilter) ([]*task.Task, error)
- func (a *CoreBridgeAdapter) UpdateTask(ctx context.Context, taskID string, updates []task.TaskUpdate) (*task.Task, error)
- type DefaultApproveRequest
- type DefaultCreateRequest
- type DefaultStep
- type DefaultTask
- type DefaultTaskAdapter
- func (a *DefaultTaskAdapter) ConvertApproveRequest(req DefaultApproveRequest) task.ApproveTaskPlanRequest
- func (a *DefaultTaskAdapter) ConvertCreateRequest(req DefaultCreateRequest) task.CreateTaskRequest
- func (a *DefaultTaskAdapter) ConvertTask(sdkTask *task.Task) *DefaultTask
- func (a *DefaultTaskAdapter) ConvertTaskUpdates(updates []DefaultTaskUpdate) []task.TaskUpdate
- func (a *DefaultTaskAdapter) ConvertTasks(sdkTasks []*task.Task) []*DefaultTask
- type DefaultTaskUpdate
- type Service
- type TaskAdapter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 interfaces.TaskService, 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 in the agent-specific format.
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 in the agent-specific format.
type CoreAdapter ¶
type CoreAdapter struct {
// contains filtered or unexported fields
}
CoreAdapter is responsible for adapting between the SDK task model and the core model
func NewCoreAdapter ¶
func NewCoreAdapter(logger logging.Logger) *CoreAdapter
NewCoreAdapter creates a new adapter for the core model
func (*CoreAdapter) CoreTaskToTask ¶
func (a *CoreAdapter) CoreTaskToTask(coreTask *core.Task) interface{}
CoreTaskToTask converts a core.Task to the SDK task model
func (*CoreAdapter) CreateLog ¶
func (a *CoreAdapter) CreateLog(taskID, message, level string) *core.Log
CreateLog creates a new log entry for a task
func (*CoreAdapter) CreateStep ¶
func (a *CoreAdapter) CreateStep(taskID, description, stepType string, orderIndex int) *core.Step
CreateStep creates a new step for a task
func (*CoreAdapter) CreateTaskFromDetails ¶
func (a *CoreAdapter) CreateTaskFromDetails(name, description, userID string, metadata map[string]interface{}) *core.Task
CreateTaskFromDetails creates a new task with provided details This is a utility function for creating tasks directly
func (*CoreAdapter) CreateTaskRequestToCore ¶
func (a *CoreAdapter) CreateTaskRequestToCore(req interface{}) core.CreateTaskRequest
CreateTaskRequestToCore converts a CreateTaskRequest to the core.CreateTaskRequest
func (*CoreAdapter) UpdateTaskStatusFromStep ¶
func (a *CoreAdapter) UpdateTaskStatusFromStep(task *core.Task)
UpdateTaskStatusFromStep updates a task's status based on its steps
type CoreBridgeAdapter ¶
type CoreBridgeAdapter struct {
// contains filtered or unexported fields
}
CoreBridgeAdapter provides a bridge between the old task.Service interface and the new interfaces.TaskService This allows migrating to the new core interfaces without breaking existing code
func (*CoreBridgeAdapter) AddTaskLog ¶
func (a *CoreBridgeAdapter) AddTaskLog(ctx context.Context, taskID string, message string, level string) error
AddTaskLog adds a log entry to a task
func (*CoreBridgeAdapter) ApproveTaskPlan ¶
func (a *CoreBridgeAdapter) ApproveTaskPlan(ctx context.Context, taskID string, req task.ApproveTaskPlanRequest) (*task.Task, error)
ApproveTaskPlan approves or rejects a task plan
func (*CoreBridgeAdapter) CreateTask ¶
func (a *CoreBridgeAdapter) CreateTask(ctx context.Context, req task.CreateTaskRequest) (*task.Task, error)
CreateTask creates a new task
func (*CoreBridgeAdapter) ListTasks ¶
func (a *CoreBridgeAdapter) ListTasks(ctx context.Context, filter task.TaskFilter) ([]*task.Task, error)
ListTasks returns tasks filtered by the provided criteria
func (*CoreBridgeAdapter) UpdateTask ¶
func (a *CoreBridgeAdapter) UpdateTask(ctx context.Context, taskID string, updates []task.TaskUpdate) (*task.Task, error)
UpdateTask updates an existing task with new steps or modifications
type DefaultApproveRequest ¶
type DefaultApproveRequest struct {
Approved bool `json:"approved"`
Feedback string `json:"feedback,omitempty"`
}
DefaultApproveRequest is a default implementation of a task approval request
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 is a default implementation of a task creation request
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 is a default implementation of a task step
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 is a default implementation of an agent task
type DefaultTaskAdapter ¶
type DefaultTaskAdapter struct {
// contains filtered or unexported fields
}
DefaultTaskAdapter is a default implementation of the TaskAdapter interface
func (*DefaultTaskAdapter) ConvertApproveRequest ¶
func (a *DefaultTaskAdapter) ConvertApproveRequest(req DefaultApproveRequest) task.ApproveTaskPlanRequest
ConvertApproveRequest converts a default approve request to an SDK approve request
func (*DefaultTaskAdapter) ConvertCreateRequest ¶
func (a *DefaultTaskAdapter) ConvertCreateRequest(req DefaultCreateRequest) task.CreateTaskRequest
ConvertCreateRequest converts a default create request to an SDK create request
func (*DefaultTaskAdapter) ConvertTask ¶
func (a *DefaultTaskAdapter) ConvertTask(sdkTask *task.Task) *DefaultTask
ConvertTask converts an SDK task to a default task
func (*DefaultTaskAdapter) ConvertTaskUpdates ¶
func (a *DefaultTaskAdapter) ConvertTaskUpdates(updates []DefaultTaskUpdate) []task.TaskUpdate
ConvertTaskUpdates converts default task updates to SDK task updates
func (*DefaultTaskAdapter) ConvertTasks ¶
func (a *DefaultTaskAdapter) ConvertTasks(sdkTasks []*task.Task) []*DefaultTask
ConvertTasks converts SDK tasks to 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 is a default implementation of a task update
type Service ¶
type Service interface {
// CreateTask creates a new task
CreateTask(ctx context.Context, req task.CreateTaskRequest) (*task.Task, error)
// GetTask gets a task by ID
GetTask(ctx context.Context, taskID string) (*task.Task, error)
// ListTasks returns tasks filtered by the provided criteria
ListTasks(ctx context.Context, filter task.TaskFilter) ([]*task.Task, error)
// ApproveTaskPlan approves or rejects a task plan
ApproveTaskPlan(ctx context.Context, taskID string, req task.ApproveTaskPlanRequest) (*task.Task, error)
// UpdateTask updates an existing task with new steps or modifications
UpdateTask(ctx context.Context, taskID string, updates []task.TaskUpdate) (*task.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 from the task package This is defined here to avoid import cycles
func NewCoreBridgeAdapter ¶
func NewCoreBridgeAdapter(coreService interfaces.TaskService, logger logging.Logger) Service
NewCoreBridgeAdapter creates a new bridge adapter
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) task.CreateTaskRequest // ConvertApproveRequest converts an agent-specific approve request to an SDK approve request ConvertApproveRequest(req AgentApprovalRequest) task.ApproveTaskPlanRequest // ConvertTaskUpdates converts agent-specific task updates to SDK task updates ConvertTaskUpdates(updates []AgentTaskUpdate) []task.TaskUpdate // ConvertTask converts an SDK task to an agent-specific task ConvertTask(sdkTask *task.Task) AgentTask // ConvertTasks converts a slice of SDK tasks to a slice of agent-specific tasks ConvertTasks(sdkTasks []*task.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