- Update DeliveryPayload to use structured types for Content and Preferences, enhancing type safety and readability. - Modify tests to reflect changes in payload structure, ensuring proper serialization and deserialization of delivery content. - Implement a new robotHandler for processing delivery events, streamlining the handling of different delivery channels (email, webhook, process). - Remove the deprecated DeliveryCenter, consolidating delivery logic within the new handler for better maintainability. - Enhance error handling and logging during delivery processing to improve observability and debugging capabilities.
57 lines
2.1 KiB
Go
57 lines
2.1 KiB
Go
package events
|
|
|
|
import robottypes "github.com/yaoapp/yao/agent/robot/types"
|
|
|
|
// Robot event type constants for event.Push integration.
|
|
// Events are fire-and-forget; handlers are registered via event.Register().
|
|
const (
|
|
TaskNeedInput = "robot.task.need_input"
|
|
TaskFailed = "robot.task.failed"
|
|
TaskCompleted = "robot.task.completed"
|
|
ExecWaiting = "robot.exec.waiting"
|
|
ExecResumed = "robot.exec.resumed"
|
|
ExecCompleted = "robot.exec.completed"
|
|
ExecFailed = "robot.exec.failed"
|
|
ExecCancelled = "robot.exec.cancelled"
|
|
Delivery = "robot.delivery"
|
|
)
|
|
|
|
// NeedInputPayload is the event payload for TaskNeedInput / ExecWaiting events.
|
|
type NeedInputPayload struct {
|
|
ExecutionID string `json:"execution_id"`
|
|
MemberID string `json:"member_id"`
|
|
TeamID string `json:"team_id"`
|
|
TaskID string `json:"task_id"`
|
|
Question string `json:"question"`
|
|
ChatID string `json:"chat_id,omitempty"`
|
|
}
|
|
|
|
// ExecPayload is a generic execution event payload.
|
|
type ExecPayload struct {
|
|
ExecutionID string `json:"execution_id"`
|
|
MemberID string `json:"member_id"`
|
|
TeamID string `json:"team_id"`
|
|
Status string `json:"status,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
ChatID string `json:"chat_id,omitempty"`
|
|
}
|
|
|
|
// TaskPayload is the event payload for TaskFailed / TaskCompleted events.
|
|
type TaskPayload struct {
|
|
ExecutionID string `json:"execution_id"`
|
|
MemberID string `json:"member_id"`
|
|
TeamID string `json:"team_id"`
|
|
TaskID string `json:"task_id"`
|
|
Error string `json:"error,omitempty"`
|
|
ChatID string `json:"chat_id,omitempty"`
|
|
}
|
|
|
|
// DeliveryPayload is the event payload for Delivery events.
|
|
type DeliveryPayload struct {
|
|
ExecutionID string `json:"execution_id"`
|
|
MemberID string `json:"member_id"`
|
|
TeamID string `json:"team_id"`
|
|
ChatID string `json:"chat_id,omitempty"`
|
|
Content *robottypes.DeliveryContent `json:"content,omitempty"`
|
|
Preferences *robottypes.DeliveryPreferences `json:"preferences,omitempty"`
|
|
}
|