灵隙(synapse) v1.0.0 版本
This commit is contained in:
624
pkg/types/types.go
Normal file
624
pkg/types/types.go
Normal file
@@ -0,0 +1,624 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// =============================================================================
|
||||
// Message ID and Task ID generators
|
||||
// =============================================================================
|
||||
|
||||
// GenerateMessageID generates a unique message ID
|
||||
func GenerateMessageID() string {
|
||||
return fmt.Sprintf("msg-%d-%d", time.Now().UnixNano(), time.Now().UnixMilli()%1000)
|
||||
}
|
||||
|
||||
// GenerateTaskID generates a unique task ID
|
||||
func GenerateTaskID() string {
|
||||
return fmt.Sprintf("task-%d-%d", time.Now().UnixNano(), time.Now().UnixMilli()%1000)
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// P2P Message Types
|
||||
// =============================================================================
|
||||
|
||||
// P2PMessageType defines all point-to-point message types
|
||||
type P2PMessageType string
|
||||
|
||||
const (
|
||||
// Task lifecycle
|
||||
P2PTaskRequest P2PMessageType = "p2p:task_request"
|
||||
P2PTaskConfirm P2PMessageType = "p2p:task_confirm"
|
||||
P2PTaskReject P2PMessageType = "p2p:task_reject"
|
||||
P2PTaskNeedInfo P2PMessageType = "p2p:task_need_info"
|
||||
P2PTaskInfoProvided P2PMessageType = "p2p:task_info_provided"
|
||||
P2PTaskStatusUpdate P2PMessageType = "p2p:task_status_update"
|
||||
P2PTaskComplete P2PMessageType = "p2p:task_complete"
|
||||
P2PTaskFailed P2PMessageType = "p2p:task_failed"
|
||||
P2PTaskCancel P2PMessageType = "p2p:task_cancel"
|
||||
P2PTaskAck P2PMessageType = "p2p:task_ack"
|
||||
|
||||
// Communication
|
||||
P2PAck P2PMessageType = "p2p:ack"
|
||||
P2PNack P2PMessageType = "p2p:nack"
|
||||
P2PHeartbeat P2PMessageType = "p2p:heartbeat"
|
||||
P2PCapabilityQuery P2PMessageType = "p2p:capability_query"
|
||||
P2PCapabilityResponse P2PMessageType = "p2p:capability_response"
|
||||
|
||||
// Human-in-the-Loop
|
||||
P2PTaskNeedHuman P2PMessageType = "p2p:task_need_human"
|
||||
P2PHumanDecision P2PMessageType = "p2p:human_decision"
|
||||
)
|
||||
|
||||
// =============================================================================
|
||||
// Group Message Types
|
||||
// =============================================================================
|
||||
|
||||
// GroupMessageType defines all group message types
|
||||
type GroupMessageType string
|
||||
|
||||
const (
|
||||
// Group management
|
||||
GroupCreate GroupMessageType = "group:create"
|
||||
GroupDisband GroupMessageType = "group:disband"
|
||||
GroupJoin GroupMessageType = "group:join"
|
||||
GroupLeave GroupMessageType = "group:leave"
|
||||
GroupInvite GroupMessageType = "group:invite"
|
||||
GroupAcceptInvite GroupMessageType = "group:accept_invite"
|
||||
GroupRejectInvite GroupMessageType = "group:reject_invite"
|
||||
GroupMemberUpdate GroupMessageType = "group:member_update"
|
||||
GroupRoleChange GroupMessageType = "group:role_change"
|
||||
|
||||
// Group communication
|
||||
GroupBroadcast GroupMessageType = "group:broadcast"
|
||||
GroupMulticast GroupMessageType = "group:multicast"
|
||||
GroupDirect GroupMessageType = "group:direct"
|
||||
GroupRelay GroupMessageType = "group:relay"
|
||||
|
||||
// Task collaboration
|
||||
GroupTaskSplit GroupMessageType = "group:task_split"
|
||||
GroupTaskAssign GroupMessageType = "group:task_assign"
|
||||
GroupTaskMerge GroupMessageType = "group:task_merge"
|
||||
GroupTaskProgress GroupMessageType = "group:task_progress"
|
||||
|
||||
// Consensus
|
||||
GroupVote GroupMessageType = "group:vote"
|
||||
GroupVoteSubmit GroupMessageType = "group:vote_submit"
|
||||
GroupConsensus GroupMessageType = "group:consensus"
|
||||
|
||||
// Human-in-the-Loop
|
||||
GroupConsensusEscalate GroupMessageType = "group:consensus_escalate"
|
||||
GroupSubtaskEscalate GroupMessageType = "group:subtask_escalate"
|
||||
GroupHumanDecision GroupMessageType = "group:human_decision"
|
||||
InterGroupEscalate GroupMessageType = "inter_group:escalate"
|
||||
)
|
||||
|
||||
// =============================================================================
|
||||
// Agent Endpoint
|
||||
// =============================================================================
|
||||
|
||||
// AgentEndpoint represents an agent's network endpoint
|
||||
type AgentEndpoint struct {
|
||||
AgentID string `json:"agent_id"`
|
||||
AgentName string `json:"agent_name,omitempty"`
|
||||
SystemID string `json:"system_id"`
|
||||
SystemName string `json:"system_name,omitempty"`
|
||||
Endpoint string `json:"endpoint"`
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// P2P Task Status
|
||||
// =============================================================================
|
||||
|
||||
// P2PTaskStatus defines task status for P2P operations
|
||||
type P2PTaskStatus string
|
||||
|
||||
const (
|
||||
// Basic states
|
||||
P2PStatusIdle P2PTaskStatus = "idle"
|
||||
P2PStatusPending P2PTaskStatus = "pending"
|
||||
P2PStatusConfirmed P2PTaskStatus = "confirmed"
|
||||
P2PStatusExecuting P2PTaskStatus = "executing"
|
||||
|
||||
// Information exchange
|
||||
P2PStatusInfoNeeded P2PTaskStatus = "info_needed"
|
||||
P2PStatusInfoProvided P2PTaskStatus = "info_provided"
|
||||
|
||||
// Human-in-the-Loop
|
||||
P2PStatusNeedHuman P2PTaskStatus = "need_human"
|
||||
P2PStatusHumanDeciding P2PTaskStatus = "human_deciding"
|
||||
P2PStatusHumanApproved P2PTaskStatus = "human_approved"
|
||||
P2PStatusHumanRejected P2PTaskStatus = "human_rejected"
|
||||
|
||||
// Terminal states
|
||||
P2PStatusCompleted P2PTaskStatus = "completed"
|
||||
P2PStatusFailed P2PTaskStatus = "failed"
|
||||
P2PStatusCancelled P2PTaskStatus = "cancelled"
|
||||
P2PStatusRejected P2PTaskStatus = "rejected"
|
||||
)
|
||||
|
||||
// =============================================================================
|
||||
// Group Status
|
||||
// =============================================================================
|
||||
|
||||
// GroupStatus defines group state
|
||||
type GroupStatus string
|
||||
|
||||
const (
|
||||
GroupStatusNone GroupStatus = "none"
|
||||
GroupStatusCreating GroupStatus = "creating"
|
||||
GroupStatusActive GroupStatus = "active"
|
||||
GroupStatusFrozen GroupStatus = "frozen"
|
||||
GroupStatusDisbanded GroupStatus = "disbanded"
|
||||
)
|
||||
|
||||
// GroupMemberStatus defines member state within a group
|
||||
type GroupMemberStatus string
|
||||
|
||||
const (
|
||||
GroupMemberActive GroupMemberStatus = "active"
|
||||
GroupMemberAway GroupMemberStatus = "away"
|
||||
GroupMemberBusy GroupMemberStatus = "busy"
|
||||
)
|
||||
|
||||
// =============================================================================
|
||||
// Signature Algorithm
|
||||
// =============================================================================
|
||||
|
||||
// SignatureAlgorithm defines supported signature algorithms
|
||||
type SignatureAlgorithm string
|
||||
|
||||
const (
|
||||
AlgHMACSHA256 SignatureAlgorithm = "HMAC-SHA256" // 默认
|
||||
AlgHMACSHA512 SignatureAlgorithm = "HMAC-SHA512"
|
||||
)
|
||||
|
||||
// =============================================================================
|
||||
// Priority
|
||||
// =============================================================================
|
||||
|
||||
// Priority defines message priority
|
||||
type Priority string
|
||||
|
||||
const (
|
||||
PriorityHigh Priority = "high"
|
||||
PriorityNormal Priority = "normal"
|
||||
PriorityLow Priority = "low"
|
||||
PriorityUrgent Priority = "urgent"
|
||||
)
|
||||
|
||||
// =============================================================================
|
||||
// Unified Synapse Message
|
||||
// =============================================================================
|
||||
|
||||
// UnifiedSynapseMessage is the base message format for all Synapse communications
|
||||
type UnifiedSynapseMessage struct {
|
||||
// Message identification
|
||||
ID string `json:"id"`
|
||||
Version string `json:"version"`
|
||||
Type string `json:"type"`
|
||||
|
||||
// Sender
|
||||
Sender AgentEndpoint `json:"sender"`
|
||||
|
||||
// Receiver (for P2P)
|
||||
Receiver *AgentEndpoint `json:"receiver,omitempty"`
|
||||
|
||||
// Group context (for Group)
|
||||
GroupID string `json:"group_id,omitempty"`
|
||||
TargetType string `json:"target_type,omitempty"` // "all", "role", "specific"
|
||||
TargetIDs []string `json:"target_ids,omitempty"`
|
||||
|
||||
// Protocol control
|
||||
CorrelationID string `json:"correlation_id,omitempty"`
|
||||
ReplyTo string `json:"reply_to,omitempty"`
|
||||
ConversationID string `json:"conversation_id,omitempty"`
|
||||
|
||||
// Payload
|
||||
Payload json.RawMessage `json:"payload"`
|
||||
|
||||
// Transport control
|
||||
TTL int `json:"ttl,omitempty"`
|
||||
Priority Priority `json:"priority,omitempty"`
|
||||
Broadcast bool `json:"broadcast,omitempty"`
|
||||
|
||||
// Security
|
||||
Signature string `json:"signature,omitempty"`
|
||||
SignatureAlgorithm string `json:"signature_algorithm,omitempty"`
|
||||
Encrypt bool `json:"encrypt,omitempty"`
|
||||
|
||||
// Timestamps
|
||||
Timestamp Timestamp `json:"timestamp"`
|
||||
ExpiresAt Timestamp `json:"expires_at,omitempty"`
|
||||
}
|
||||
|
||||
// Timestamp is an ISO 8601 formatted timestamp
|
||||
type Timestamp string
|
||||
|
||||
func (t Timestamp) Time() (time.Time, error) {
|
||||
return time.Parse(time.RFC3339, string(t))
|
||||
}
|
||||
|
||||
func NowTimestamp() Timestamp {
|
||||
return Timestamp(time.Now().UTC().Format(time.RFC3339))
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// P2P Payloads
|
||||
// =============================================================================
|
||||
|
||||
// TaskRequestPayload is the payload for TASK_REQUEST
|
||||
type TaskRequestPayload struct {
|
||||
Task struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Priority Priority `json:"priority"`
|
||||
Deadline *Timestamp `json:"deadline,omitempty"`
|
||||
Payload map[string]interface{} `json:"payload"`
|
||||
} `json:"task"`
|
||||
Context *struct {
|
||||
SessionID string `json:"session_id,omitempty"`
|
||||
ParentTaskID string `json:"parent_task_id,omitempty"`
|
||||
CorrelationID string `json:"correlation_id,omitempty"`
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
||||
} `json:"context,omitempty"`
|
||||
}
|
||||
|
||||
// TaskConfirmPayload is the payload for TASK_CONFIRM
|
||||
type TaskConfirmPayload struct {
|
||||
TaskID string `json:"task_id"`
|
||||
Confirmed bool `json:"confirmed"`
|
||||
EstimatedDuration int `json:"estimated_duration"` // seconds
|
||||
ExpectedCompletion Timestamp `json:"expected_completion"`
|
||||
CapabilitiesUsed []string `json:"capabilities_used"`
|
||||
Constraints *struct {
|
||||
MaxRetries int `json:"max_retries"`
|
||||
FallbackEnabled bool `json:"fallback_enabled"`
|
||||
} `json:"constraints,omitempty"`
|
||||
}
|
||||
|
||||
// TaskRejectPayload is the payload for TASK_REJECT
|
||||
type TaskRejectPayload struct {
|
||||
TaskID string `json:"task_id"`
|
||||
Reason struct {
|
||||
Code string `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Details any `json:"details,omitempty"`
|
||||
} `json:"reason"`
|
||||
Alternatives *struct {
|
||||
SuggestedAgentID string `json:"suggested_agent_id,omitempty"`
|
||||
RetryAfter int `json:"retry_after,omitempty"`
|
||||
PartialSupport bool `json:"partial_support,omitempty"`
|
||||
} `json:"alternatives,omitempty"`
|
||||
}
|
||||
|
||||
// MissingField describes a missing information field
|
||||
type MissingField struct {
|
||||
Field string `json:"field"`
|
||||
Reason string `json:"reason"`
|
||||
SuggestedValue any `json:"suggested_value,omitempty"`
|
||||
Alternatives []any `json:"alternatives,omitempty"`
|
||||
}
|
||||
|
||||
// TaskNeedInfoPayload is the payload for TASK_NEED_INFO
|
||||
type TaskNeedInfoPayload struct {
|
||||
TaskID string `json:"task_id"`
|
||||
MissingFields []MissingField `json:"missing_fields"`
|
||||
Question string `json:"question,omitempty"`
|
||||
RequiredBy *Timestamp `json:"required_by,omitempty"`
|
||||
}
|
||||
|
||||
// TaskInfoProvidedPayload is the payload for TASK_INFO_PROVIDED
|
||||
type TaskInfoProvidedPayload struct {
|
||||
TaskID string `json:"task_id"`
|
||||
ReplyTo string `json:"reply_to"`
|
||||
ProvidedInfo map[string]interface{} `json:"provided_info"`
|
||||
AdditionalContext string `json:"additional_context,omitempty"`
|
||||
}
|
||||
|
||||
// TaskStatusUpdatePayload is the payload for TASK_STATUS_UPDATE
|
||||
type TaskStatusUpdatePayload struct {
|
||||
TaskID string `json:"task_id"`
|
||||
Status string `json:"status"`
|
||||
Progress int `json:"progress"` // 0-100
|
||||
Message string `json:"message,omitempty"`
|
||||
IntermediateResult any `json:"intermediate_result,omitempty"`
|
||||
}
|
||||
|
||||
// TaskCompletePayload is the payload for TASK_COMPLETE
|
||||
type TaskCompletePayload struct {
|
||||
TaskID string `json:"task_id"`
|
||||
Result struct {
|
||||
OutputType string `json:"output_type"`
|
||||
Output any `json:"output"`
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
||||
} `json:"result"`
|
||||
Summary string `json:"summary,omitempty"`
|
||||
}
|
||||
|
||||
// TaskFailedPayload is the payload for TASK_FAILED
|
||||
type TaskFailedPayload struct {
|
||||
TaskID string `json:"task_id"`
|
||||
Error struct {
|
||||
Code string `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Recoverable bool `json:"recoverable"`
|
||||
Details any `json:"details,omitempty"`
|
||||
} `json:"error"`
|
||||
PartialResult any `json:"partial_result,omitempty"`
|
||||
}
|
||||
|
||||
// TaskCancelPayload is the payload for TASK_CANCEL
|
||||
type TaskCancelPayload struct {
|
||||
TaskID string `json:"task_id"`
|
||||
Reason string `json:"reason"`
|
||||
CancelledBy string `json:"cancelled_by,omitempty"`
|
||||
}
|
||||
|
||||
// TaskNeedHumanPayload is the payload for TASK_NEED_HUMAN
|
||||
type TaskNeedHumanPayload struct {
|
||||
TaskID string `json:"task_id"`
|
||||
Reason struct {
|
||||
Code string `json:"code"`
|
||||
Message string `json:"message"`
|
||||
} `json:"reason"`
|
||||
Context struct {
|
||||
TaskSummary string `json:"task_summary"`
|
||||
CurrentProgress int `json:"current_progress"`
|
||||
BlockedReason string `json:"blocked_reason"`
|
||||
RelevantHistory []any `json:"relevant_history,omitempty"`
|
||||
} `json:"context"`
|
||||
Options []struct {
|
||||
Field string `json:"field"`
|
||||
Value any `json:"value"`
|
||||
ProsCons string `json:"pros_cons,omitempty"`
|
||||
Confidence int `json:"confidence,omitempty"`
|
||||
} `json:"options,omitempty"`
|
||||
SuggestedValue any `json:"suggested_value,omitempty"`
|
||||
EscalationLevel int `json:"escalation_level"`
|
||||
Deadline *Timestamp `json:"deadline,omitempty"`
|
||||
}
|
||||
|
||||
// HumanDecisionPayload is the payload for HUMAN_DECISION
|
||||
type HumanDecisionPayload struct {
|
||||
TaskID string `json:"task_id"`
|
||||
DecisionID string `json:"decision_id"`
|
||||
ReplyTo string `json:"reply_to"`
|
||||
DecidedBy struct {
|
||||
UserID string `json:"user_id"`
|
||||
UserName string `json:"user_name"`
|
||||
Role string `json:"role"`
|
||||
} `json:"decided_by"`
|
||||
Decision struct {
|
||||
Action string `json:"action"` // approve, reject, modify, select
|
||||
ApprovedFields map[string]interface{} `json:"approved_fields,omitempty"`
|
||||
ModifiedFields map[string]interface{} `json:"modified_fields,omitempty"`
|
||||
SelectedOption any `json:"selected_option,omitempty"`
|
||||
RejectionReason string `json:"rejection_reason,omitempty"`
|
||||
} `json:"decision"`
|
||||
Notes string `json:"notes,omitempty"`
|
||||
Timestamp Timestamp `json:"timestamp"`
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Group Payloads
|
||||
// =============================================================================
|
||||
|
||||
// GroupTopology defines group topology types
|
||||
type GroupTopology string
|
||||
|
||||
const (
|
||||
GroupTopologyStar GroupTopology = "star"
|
||||
GroupTopologyMesh GroupTopology = "mesh"
|
||||
GroupTopologyChain GroupTopology = "chain"
|
||||
GroupTopologyHierarchical GroupTopology = "hierarchical"
|
||||
GroupTopologyFullMesh GroupTopology = "fullmesh"
|
||||
)
|
||||
|
||||
// GroupRole defines a group role
|
||||
type GroupRole struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Permissions []string `json:"permissions"`
|
||||
MaxTasks int `json:"max_tasks"`
|
||||
}
|
||||
|
||||
// GroupMember represents a member in a group
|
||||
type GroupMember struct {
|
||||
AgentID string `json:"agent_id"`
|
||||
AgentName string `json:"agent_name"`
|
||||
Role string `json:"role"`
|
||||
JoinedAt Timestamp `json:"joined_at"`
|
||||
Status GroupMemberStatus `json:"status"`
|
||||
Capabilities []string `json:"capabilities"`
|
||||
LoadFactor float64 `json:"load_factor"` // 0-1, for task assignment
|
||||
}
|
||||
|
||||
// AgentGroup represents a group of agents
|
||||
type AgentGroup struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Topology GroupTopology `json:"topology"`
|
||||
CreatedBy string `json:"created_by"`
|
||||
CreatedAt Timestamp `json:"created_at"`
|
||||
Config GroupConfig `json:"config"`
|
||||
Members []GroupMember `json:"members"`
|
||||
Roles []GroupRole `json:"roles"`
|
||||
Status GroupStatus `json:"status"`
|
||||
}
|
||||
|
||||
// GroupConfig defines group configuration
|
||||
type GroupConfig struct {
|
||||
AllowSelfLeave bool `json:"allow_self_leave"`
|
||||
RequiresApproval bool `json:"requires_approval"`
|
||||
ConsensusRequired bool `json:"consensus_required"`
|
||||
ConsensusThreshold float64 `json:"consensus_threshold"` // 0-1
|
||||
BroadcastMode string `json:"broadcast_mode"` // "all" or "smart"
|
||||
}
|
||||
|
||||
// GroupCreatePayload is the payload for GROUP_CREATE
|
||||
type GroupCreatePayload struct {
|
||||
Group struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Topology GroupTopology `json:"topology"`
|
||||
Config GroupConfig `json:"config"`
|
||||
InitialMembers []AgentEndpoint `json:"initial_members,omitempty"`
|
||||
Roles []GroupRole `json:"roles,omitempty"`
|
||||
} `json:"group"`
|
||||
}
|
||||
|
||||
// GroupInvitePayload is the payload for GROUP_INVITE
|
||||
type GroupInvitePayload struct {
|
||||
GroupID string `json:"group_id"`
|
||||
Invitee AgentEndpoint `json:"invitee"`
|
||||
Inviter AgentEndpoint `json:"inviter"`
|
||||
Message string `json:"message,omitempty"`
|
||||
RequiresApproval bool `json:"requires_approval"`
|
||||
}
|
||||
|
||||
// Subtask describes a subtask in task splitting
|
||||
type Subtask struct {
|
||||
ID string `json:"id"`
|
||||
Description string `json:"description"`
|
||||
AssignedTo string `json:"assigned_to"`
|
||||
Dependencies []string `json:"dependencies"`
|
||||
EstimatedDuration int `json:"estimated_duration"` // seconds
|
||||
Priority int `json:"priority"`
|
||||
}
|
||||
|
||||
// MergeStrategy defines how subtask results are merged
|
||||
type MergeStrategy string
|
||||
|
||||
const (
|
||||
MergeAllSuccess MergeStrategy = "all_success"
|
||||
MergeMajority MergeStrategy = "majority"
|
||||
MergeAnyComplete MergeStrategy = "any_complete"
|
||||
MergePriority MergeStrategy = "priority"
|
||||
)
|
||||
|
||||
// GroupTaskSplitPayload is the payload for GROUP_TASK_SPLIT
|
||||
type GroupTaskSplitPayload struct {
|
||||
OriginalTask struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Requirements map[string]interface{} `json:"requirements"`
|
||||
Deadline *Timestamp `json:"deadline,omitempty"`
|
||||
} `json:"original_task"`
|
||||
Subtasks []Subtask `json:"subtasks"`
|
||||
MergeStrategy MergeStrategy `json:"merge_strategy"`
|
||||
}
|
||||
|
||||
// SubtaskResult describes a single subtask result
|
||||
type SubtaskResult struct {
|
||||
SubtaskID string `json:"subtask_id"`
|
||||
AssignedTo string `json:"assigned_to"`
|
||||
Status string `json:"status"` // success, failed, partial
|
||||
Result any `json:"result,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
CompletedAt *Timestamp `json:"completed_at,omitempty"`
|
||||
}
|
||||
|
||||
// GroupTaskMergePayload is the payload for GROUP_TASK_MERGE
|
||||
type GroupTaskMergePayload struct {
|
||||
OriginalTaskID string `json:"original_task_id"`
|
||||
SubtaskResults []SubtaskResult `json:"subtask_results"`
|
||||
MergeStrategyUsed string `json:"merge_strategy_used"`
|
||||
MergedResult any `json:"merged_result"`
|
||||
ConsensusAchieved bool `json:"consensus_achieved"`
|
||||
}
|
||||
|
||||
// GroupVoteOption describes a vote option
|
||||
type GroupVoteOption struct {
|
||||
VoterID string `json:"voter_id"`
|
||||
Option string `json:"option"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
Timestamp Timestamp `json:"timestamp"`
|
||||
}
|
||||
|
||||
// GroupVotePayload is the payload for GROUP_VOTE
|
||||
type GroupVotePayload struct {
|
||||
VoteID string `json:"vote_id"`
|
||||
Question string `json:"question"`
|
||||
Options []string `json:"options"`
|
||||
Voters []string `json:"voters"`
|
||||
Deadline Timestamp `json:"deadline"`
|
||||
Threshold float64 `json:"threshold"` // 0-1
|
||||
Status string `json:"status"` // open, closed
|
||||
Votes []GroupVoteOption `json:"votes,omitempty"`
|
||||
}
|
||||
|
||||
// GroupConsensusEscalatePayload is the payload for GROUP_CONSENSUS_ESCALATE
|
||||
type GroupConsensusEscalatePayload struct {
|
||||
VoteID string `json:"vote_id"`
|
||||
EscalationID string `json:"escalation_id"`
|
||||
Question string `json:"question"`
|
||||
Votes []struct {
|
||||
VoterID string `json:"voter_id"`
|
||||
VoterRole string `json:"voter_role"`
|
||||
Option string `json:"option"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
} `json:"votes"`
|
||||
ConsensusStatus struct {
|
||||
RequiredThreshold float64 `json:"required_threshold"`
|
||||
ActualThreshold float64 `json:"actual_threshold"`
|
||||
LeadingOption string `json:"leading_option,omitempty"`
|
||||
OptionsTied bool `json:"options_tied"`
|
||||
} `json:"consensus_status"`
|
||||
EscalateReason struct {
|
||||
Code string `json:"code"`
|
||||
Message string `json:"message"`
|
||||
} `json:"escalate_reason"`
|
||||
EscalationLevel int `json:"escalation_level"`
|
||||
DecisionOptions []struct {
|
||||
Option string `json:"option"`
|
||||
SupportCount int `json:"support_count"`
|
||||
SupportAgents []string `json:"support_agents"`
|
||||
} `json:"decision_options"`
|
||||
Deadline Timestamp `json:"deadline"`
|
||||
Context struct {
|
||||
TaskID string `json:"task_id"`
|
||||
OriginalTaskRequirements map[string]interface{} `json:"original_task_requirements"`
|
||||
AgentRecommendations []struct {
|
||||
AgentID string `json:"agent_id"`
|
||||
SuggestedOption string `json:"suggested_option"`
|
||||
} `json:"agent_recommendations"`
|
||||
} `json:"context"`
|
||||
}
|
||||
|
||||
// GroupSubtaskEscalatePayload is the payload for GROUP_SUBTASK_ESCALATE
|
||||
type GroupSubtaskEscalatePayload struct {
|
||||
OriginalTask struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Description string `json:"description"`
|
||||
} `json:"original_task"`
|
||||
Subtask struct {
|
||||
ID string `json:"id"`
|
||||
Description string `json:"description"`
|
||||
AssignedTo string `json:"assigned_to"`
|
||||
BlockedAt string `json:"blocked_at"`
|
||||
BlockedReason struct {
|
||||
Code string `json:"code"`
|
||||
Message string `json:"message"`
|
||||
} `json:"blocked_reason"`
|
||||
AttemptedSolutions []string `json:"attempted_solutions"`
|
||||
} `json:"subtask"`
|
||||
RequiredDecision struct {
|
||||
FieldsNeeded []struct {
|
||||
Field string `json:"field"`
|
||||
CurrentValue any `json:"current_value,omitempty"`
|
||||
SuggestedValue any `json:"suggested_value,omitempty"`
|
||||
Alternatives []any `json:"alternatives,omitempty"`
|
||||
ValidationRules string `json:"validation_rules,omitempty"`
|
||||
} `json:"fields_needed"`
|
||||
DecisionType string `json:"decision_type"` // approve, select, provide_info
|
||||
AffectsOtherSubtasks bool `json:"affects_other_subtasks"`
|
||||
RollbackPossible bool `json:"rollback_possible"`
|
||||
} `json:"required_decision"`
|
||||
EscalationLevel int `json:"escalation_level"`
|
||||
Deadline *Timestamp `json:"deadline,omitempty"`
|
||||
}
|
||||
Reference in New Issue
Block a user