Documentation
¶
Index ¶
- type AlertUsecases
- type ApiUsecases
- type ChatNotifierdeprecated
- type ChatResponder
- type ChatSession
- type ChatSessionID
- type ChatSource
- type Clients
- type CommandExecutor
- type EmbeddingClient
- type LLMClient
- type LLMSession
- type Notifier
- type Option
- type PolicyClient
- type PromptService
- type Repository
- type SlackClient
- type SlackEventUsecases
- type SlackInteractionUsecases
- type SlackThreadService
- type StorageClient
- type Tool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertUsecases ¶
type ApiUsecases ¶ added in v0.1.0
type ApiUsecases interface {
// User related handlers
GetUserIcon(ctx context.Context, userID string) ([]byte, string, error)
GetUserProfile(ctx context.Context, userID string) (string, error)
// Ticket related handlers
GenerateTicketAlertsJSONL(ctx context.Context, ticketID types.TicketID) ([]byte, error)
}
type ChatNotifier
deprecated
added in
v0.1.0
type ChatNotifier interface {
// NotifyMessage sends a message to a chat room/channel
NotifyMessage(ctx context.Context, ticketID types.TicketID, message string) error
// NotifyTrace sends a trace message (debug/info level) to a chat room/channel
NotifyTrace(ctx context.Context, ticketID types.TicketID, message string) error
}
Deprecated: ChatNotifier is no longer used in the new design Use ChatResponder for targeted responses to specific chat sessions ChatNotifier provides an abstraction for chat notification services
type ChatResponder ¶ added in v0.1.0
type ChatResponder interface {
// SendMessage sends a message to the specific chat session
SendMessage(ctx context.Context, message string) error
// SendTrace sends a trace message to the specific chat session
SendTrace(ctx context.Context, message string) error
// GetSession returns the chat session information
GetSession() *ChatSession
}
ChatResponder provides response capabilities for a specific chat session Deprecated: Use msg.With to setup context-based message routing instead
type ChatSession ¶ added in v0.1.0
type ChatSession struct {
ID ChatSessionID
Source ChatSource
TicketID types.TicketID
UserID string
// For WebSocket: specific connection ID
// For Slack: thread information
Metadata map[string]interface{}
}
ChatSession represents a specific chat session context Deprecated: Use msg.With to setup context-based message routing
type ChatSessionID ¶ added in v0.1.0
type ChatSessionID string
ChatSessionID represents a unique chat session identifier
type ChatSource ¶ added in v0.1.0
type ChatSource string
ChatSource represents the type of chat source
const ( ChatSourceSlack ChatSource = "slack" ChatSourceWebSocket ChatSource = "websocket" )
type Clients ¶
type Clients struct {
// contains filtered or unexported fields
}
func NewClients ¶
func (*Clients) Repository ¶
func (c *Clients) Repository() Repository
func (*Clients) Storage ¶
func (c *Clients) Storage() StorageClient
type CommandExecutor ¶ added in v0.1.0
type CommandExecutor interface {
Execute(ctx context.Context, slackMsg *slack.Message, thread slack.Thread, command string) error
}
CommandExecutor defines the interface for executing Slack commands
type EmbeddingClient ¶
type LLMSession ¶
type Notifier ¶ added in v0.5.0
type Notifier interface {
// NotifyAlertPolicyResult is called when alert policy evaluation completes
NotifyAlertPolicyResult(ctx context.Context, ev *event.AlertPolicyResultEvent)
// NotifyEnrichPolicyResult is called when enrich policy evaluation completes
NotifyEnrichPolicyResult(ctx context.Context, ev *event.EnrichPolicyResultEvent)
// NotifyCommitPolicyResult is called when commit policy evaluation completes
NotifyCommitPolicyResult(ctx context.Context, ev *event.CommitPolicyResultEvent)
// NotifyEnrichTaskPrompt is called when an enrichment task prompt is about to be sent to LLM
NotifyEnrichTaskPrompt(ctx context.Context, ev *event.EnrichTaskPromptEvent)
// NotifyEnrichTaskResponse is called when an enrichment task response is received from LLM
NotifyEnrichTaskResponse(ctx context.Context, ev *event.EnrichTaskResponseEvent)
// NotifyError is called when an error occurs during pipeline processing
NotifyError(ctx context.Context, ev *event.ErrorEvent)
}
Notifier is an interface for handling notification events from the alert processing pipeline. Each event type has a dedicated method for type-safe event handling. Implementations can output events to console, Slack, or other notification channels.
type Option ¶
type Option func(*Clients)
func WithLLMClient ¶
func WithRepository ¶
func WithRepository(repo Repository) Option
func WithStorageClient ¶
func WithStorageClient(storage StorageClient) Option
type PolicyClient ¶
type PromptService ¶ added in v0.4.0
type PromptService interface {
// GeneratePrompt generates a prompt from template name and alert data
GeneratePrompt(ctx context.Context, templateName string, alert *alert.Alert) (string, error)
// ReadPromptFile reads a prompt file without template rendering
ReadPromptFile(ctx context.Context, templateName string) (string, error)
}
PromptService handles prompt template management and generation
type Repository ¶
type Repository interface {
GetTicket(ctx context.Context, ticketID types.TicketID) (*ticket.Ticket, error)
BatchGetTickets(ctx context.Context, ticketIDs []types.TicketID) ([]*ticket.Ticket, error)
PutTicket(ctx context.Context, ticket ticket.Ticket) error
BatchUpdateTicketsStatus(ctx context.Context, ticketIDs []types.TicketID, status types.TicketStatus) error
GetTicketByThread(ctx context.Context, thread slack.Thread) (*ticket.Ticket, error)
FindNearestTickets(ctx context.Context, embedding []float32, limit int) ([]*ticket.Ticket, error)
FindNearestTicketsWithSpan(ctx context.Context, embedding []float32, begin, end time.Time, limit int) ([]*ticket.Ticket, error)
GetTicketsByStatus(ctx context.Context, statuses []types.TicketStatus, offset, limit int) ([]*ticket.Ticket, error)
CountTicketsByStatus(ctx context.Context, statuses []types.TicketStatus) (int, error)
GetTicketsBySpan(ctx context.Context, begin, end time.Time) ([]*ticket.Ticket, error)
GetTicketsByStatusAndSpan(ctx context.Context, status types.TicketStatus, begin, end time.Time) ([]*ticket.Ticket, error)
// For comment management
PutTicketComment(ctx context.Context, comment ticket.Comment) error
GetTicketComments(ctx context.Context, ticketID types.TicketID) ([]ticket.Comment, error)
GetTicketCommentsPaginated(ctx context.Context, ticketID types.TicketID, offset, limit int) ([]ticket.Comment, error)
CountTicketComments(ctx context.Context, ticketID types.TicketID) (int, error)
GetTicketUnpromptedComments(ctx context.Context, ticketID types.TicketID) ([]ticket.Comment, error)
PutTicketCommentsPrompted(ctx context.Context, ticketID types.TicketID, commentIDs []types.CommentID) error
BindAlertsToTicket(ctx context.Context, alertIDs []types.AlertID, ticketID types.TicketID) error
UnbindAlertFromTicket(ctx context.Context, alertID types.AlertID) error
PutAlert(ctx context.Context, alert alert.Alert) error
BatchPutAlerts(ctx context.Context, alerts alert.Alerts) error
GetAlert(ctx context.Context, alertID types.AlertID) (*alert.Alert, error)
GetLatestAlertByThread(ctx context.Context, thread slack.Thread) (*alert.Alert, error)
GetAlertsByThread(ctx context.Context, thread slack.Thread) (alert.Alerts, error)
SearchAlerts(ctx context.Context, path, op string, value any, limit int) (alert.Alerts, error)
GetAlertWithoutTicket(ctx context.Context, offset, limit int) (alert.Alerts, error)
CountAlertsWithoutTicket(ctx context.Context) (int, error)
GetAlertsBySpan(ctx context.Context, begin, end time.Time) (alert.Alerts, error)
BatchGetAlerts(ctx context.Context, alertIDs []types.AlertID) (alert.Alerts, error)
FindNearestAlerts(ctx context.Context, embedding []float32, limit int) (alert.Alerts, error)
GetLatestHistory(ctx context.Context, ticketID types.TicketID) (*ticket.History, error)
PutHistory(ctx context.Context, ticketID types.TicketID, history *ticket.History) error
// For list management
GetAlertList(ctx context.Context, listID types.AlertListID) (*alert.List, error)
PutAlertList(ctx context.Context, list *alert.List) error
GetAlertListByThread(ctx context.Context, thread slack.Thread) (*alert.List, error)
GetLatestAlertListInThread(ctx context.Context, thread slack.Thread) (*alert.List, error)
GetAlertListsInThread(ctx context.Context, thread slack.Thread) ([]*alert.List, error)
GetAlertWithoutEmbedding(ctx context.Context) (alert.Alerts, error)
GetAlertsWithInvalidEmbedding(ctx context.Context) (alert.Alerts, error)
GetTicketsWithInvalidEmbedding(ctx context.Context) ([]*ticket.Ticket, error)
// For authentication management
PutToken(ctx context.Context, token *auth.Token) error
GetToken(ctx context.Context, tokenID auth.TokenID) (*auth.Token, error)
DeleteToken(ctx context.Context, tokenID auth.TokenID) error
// For activity management
PutActivity(ctx context.Context, activity *activity.Activity) error
GetActivities(ctx context.Context, offset, limit int) ([]*activity.Activity, error)
CountActivities(ctx context.Context) (int, error)
// For tag management (legacy - deprecated, kept for external compatibility)
RemoveTagFromAllAlerts(ctx context.Context, name string) error
RemoveTagFromAllTickets(ctx context.Context, name string) error
// For new tag management (ID-based)
GetTagByID(ctx context.Context, tagID string) (*tag.Tag, error)
GetTagsByIDs(ctx context.Context, tagIDs []string) ([]*tag.Tag, error)
ListAllTags(ctx context.Context) ([]*tag.Tag, error)
CreateTagWithID(ctx context.Context, tag *tag.Tag) error
UpdateTag(ctx context.Context, tag *tag.Tag) error
DeleteTagByID(ctx context.Context, tagID string) error
RemoveTagIDFromAllAlerts(ctx context.Context, tagID string) error
RemoveTagIDFromAllTickets(ctx context.Context, tagID string) error
// For tag name lookup (compatibility)
GetTagByName(ctx context.Context, name string) (*tag.Tag, error)
IsTagNameExists(ctx context.Context, name string) (bool, error)
GetOrCreateTagByName(ctx context.Context, name, description, color, createdBy string) (*tag.Tag, error)
// For notice management
CreateNotice(ctx context.Context, notice *notice.Notice) error
GetNotice(ctx context.Context, id types.NoticeID) (*notice.Notice, error)
UpdateNotice(ctx context.Context, notice *notice.Notice) error
// For memory management
GetExecutionMemory(ctx context.Context, schemaID types.AlertSchema) (*memory.ExecutionMemory, error)
PutExecutionMemory(ctx context.Context, mem *memory.ExecutionMemory) error
SearchExecutionMemoriesByEmbedding(ctx context.Context, schemaID types.AlertSchema, embedding []float32, limit int) ([]*memory.ExecutionMemory, error)
GetTicketMemory(ctx context.Context, schemaID types.AlertSchema) (*memory.TicketMemory, error)
PutTicketMemory(ctx context.Context, mem *memory.TicketMemory) error
// For agent memory management
// Note: Agent memories are stored in subcollection: agents/{agentID}/memories/{memoryID}
SaveAgentMemory(ctx context.Context, mem *memory.AgentMemory) error
GetAgentMemory(ctx context.Context, agentID string, id types.AgentMemoryID) (*memory.AgentMemory, error)
SearchMemoriesByEmbedding(ctx context.Context, agentID string, embedding []float32, limit int) ([]*memory.AgentMemory, error)
// Memory scoring methods
// UpdateMemoryScoreBatch updates quality scores and last used timestamps for multiple agent memories
UpdateMemoryScoreBatch(ctx context.Context, agentID string, updates map[types.AgentMemoryID]struct {
Score float64
LastUsedAt time.Time
}) error
// DeleteAgentMemoriesBatch deletes multiple agent memories in a batch
// Returns the number of successfully deleted memories
DeleteAgentMemoriesBatch(ctx context.Context, agentID string, memoryIDs []types.AgentMemoryID) (int, error)
// ListAgentMemories lists all memories for an agent (for pruning)
// Results are ordered by Timestamp DESC
ListAgentMemories(ctx context.Context, agentID string) ([]*memory.AgentMemory, error)
}
type SlackClient ¶
type SlackClient interface {
PostMessageContext(ctx context.Context, channelID string, options ...slackSDK.MsgOption) (string, string, error)
UpdateMessageContext(ctx context.Context, channelID, timestamp string, options ...slackSDK.MsgOption) (string, string, string, error)
DeleteMessageContext(ctx context.Context, channelID, timestamp string) (string, string, error)
AuthTest() (*slackSDK.AuthTestResponse, error)
GetTeamInfo() (*slackSDK.TeamInfo, error)
OpenView(triggerID string, view slackSDK.ModalViewRequest) (*slackSDK.ViewResponse, error)
UpdateView(view slackSDK.ModalViewRequest, externalID, hash, viewID string) (*slackSDK.ViewResponse, error)
UploadFileV2Context(ctx context.Context, params slackSDK.UploadFileV2Parameters) (*slackSDK.FileSummary, error)
GetUserInfo(userID string) (*slackSDK.User, error)
GetUsersInfo(users ...string) (*[]slackSDK.User, error)
GetConversationInfo(input *slackSDK.GetConversationInfoInput) (*slackSDK.Channel, error)
GetUserGroups(options ...slackSDK.GetUserGroupsOption) ([]slackSDK.UserGroup, error)
GetBotInfoContext(ctx context.Context, parameters slackSDK.GetBotInfoParameters) (*slackSDK.Bot, error)
GetConversationHistoryContext(ctx context.Context, params *slackSDK.GetConversationHistoryParameters) (*slackSDK.GetConversationHistoryResponse, error)
GetConversationRepliesContext(ctx context.Context, params *slackSDK.GetConversationRepliesParameters) ([]slackSDK.Message, bool, string, error)
}
type SlackEventUsecases ¶
type SlackInteractionUsecases ¶
type SlackInteractionUsecases interface {
// Slack interaction handlers
HandleSlackInteractionViewSubmission(ctx context.Context, user slack.User, callbackID slack.CallbackID, metadata string, values slack.StateValue) error
HandleSlackInteractionBlockActions(ctx context.Context, user slack.User, slackThread slack.Thread, actionID slack.ActionID, value, triggerID string) error
HandleSalvageRefresh(ctx context.Context, user slack.User, metadata string, values slack.StateValue, viewID string) error
}
type SlackThreadService ¶
type SlackThreadService interface {
// Thread information
ChannelID() string
ThreadID() string
Entity() *slack.Thread
// Posting operations
PostAlert(ctx context.Context, alert *alert.Alert) error
PostComment(ctx context.Context, comment string) error
PostCommentWithMessageID(ctx context.Context, comment string) (string, error)
PostContextBlock(ctx context.Context, text string) error
PostTicket(ctx context.Context, ticket *ticket.Ticket, alerts alert.Alerts) (string, error)
PostLinkToTicket(ctx context.Context, ticketURL, ticketTitle string) error
PostFinding(ctx context.Context, finding *ticket.Finding) error
// Update operations
UpdateAlert(ctx context.Context, alert alert.Alert) error
UpdateAlertList(ctx context.Context, list *alert.List, status string) error
// List operations
PostAlerts(ctx context.Context, alerts alert.Alerts) error
PostAlertList(ctx context.Context, list *alert.List) (string, error)
PostAlertLists(ctx context.Context, clusters []*alert.List) error
PostTicketList(ctx context.Context, tickets []*ticket.Ticket) error
// Interactive operations
Reply(ctx context.Context, message string)
NewStateFunc(ctx context.Context, message string) func(ctx context.Context, msg string)
NewUpdatableMessage(ctx context.Context, initialMessage string) func(ctx context.Context, newMsg string)
NewTraceMessage(ctx context.Context, initialMessage string) func(ctx context.Context, traceMsg string)
// File operations
AttachFile(ctx context.Context, title, fileName string, data []byte) error
}