hooks

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DingTalkConfig added in v0.9.0

type DingTalkConfig struct {
	WebhookURL   string        `json:"webhook_url"`
	Secret       string        `json:"secret,omitempty"`
	Timeout      time.Duration `json:"timeout"`
	FilterEvents []EventType   `json:"filter_events"`
}

type DingTalkHook added in v0.9.0

type DingTalkHook struct {
	// contains filtered or unexported fields
}

func NewDingTalkHook added in v0.9.0

func NewDingTalkHook(name string, config DingTalkConfig, logger *slog.Logger) *DingTalkHook

func (*DingTalkHook) Close added in v0.9.0

func (h *DingTalkHook) Close() error

func (*DingTalkHook) Events added in v0.9.0

func (h *DingTalkHook) Events() []EventType

func (*DingTalkHook) Handle added in v0.9.0

func (h *DingTalkHook) Handle(ctx context.Context, event *Event) error

func (*DingTalkHook) Name added in v0.9.0

func (h *DingTalkHook) Name() string

type Event

type Event struct {
	Type      EventType   `json:"type"`
	Timestamp time.Time   `json:"timestamp"`
	Namespace string      `json:"namespace,omitempty"`
	SessionID string      `json:"session_id,omitempty"`
	Data      interface{} `json:"data,omitempty"`
	Error     string      `json:"error,omitempty"`
}

type EventType

type EventType string
const (
	EventSessionStart  EventType = "session.start"
	EventSessionEnd    EventType = "session.end"
	EventSessionError  EventType = "session.error"
	EventToolUse       EventType = "tool.use"
	EventToolResult    EventType = "tool.result"
	EventDangerBlocked EventType = "danger.blocked"
	EventStreamStart   EventType = "stream.start"
	EventStreamEnd     EventType = "stream.end"
	EventTurnStart     EventType = "turn.start"
	EventTurnEnd       EventType = "turn.end"
)

type FeishuConfig added in v0.9.0

type FeishuConfig struct {
	WebhookURL   string        `json:"webhook_url"`
	Secret       string        `json:"secret,omitempty"`
	Timeout      time.Duration `json:"timeout"`
	FilterEvents []EventType   `json:"filter_events"`
}

type FeishuHook added in v0.9.0

type FeishuHook struct {
	// contains filtered or unexported fields
}

func NewFeishuHook added in v0.9.0

func NewFeishuHook(name string, config FeishuConfig, logger *slog.Logger) *FeishuHook

func (*FeishuHook) Close added in v0.9.0

func (h *FeishuHook) Close() error

func (*FeishuHook) Events added in v0.9.0

func (h *FeishuHook) Events() []EventType

func (*FeishuHook) Handle added in v0.9.0

func (h *FeishuHook) Handle(ctx context.Context, event *Event) error

func (*FeishuHook) Name added in v0.9.0

func (h *FeishuHook) Name() string

type Hook

type Hook interface {
	Name() string
	Handle(ctx context.Context, event *Event) error
	Events() []EventType
}

type HookConfig

type HookConfig struct {
	Async   bool          `json:"async"`
	Timeout time.Duration `json:"timeout"`
	Retry   int           `json:"retry"`
	Enabled bool          `json:"enabled"`
}

type HookRegistration

type HookRegistration struct {
	Hook   Hook
	Config HookConfig
}

type LoggingHook

type LoggingHook struct {
	// contains filtered or unexported fields
}

func NewLoggingHook

func NewLoggingHook(name string, logger *slog.Logger, events []EventType) *LoggingHook

func (*LoggingHook) Events

func (h *LoggingHook) Events() []EventType

func (*LoggingHook) Handle

func (h *LoggingHook) Handle(ctx context.Context, event *Event) error

func (*LoggingHook) Name

func (h *LoggingHook) Name() string

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(logger *slog.Logger, bufferSize int) *Manager

func (*Manager) Close

func (m *Manager) Close()

func (*Manager) Emit

func (m *Manager) Emit(event *Event)

func (*Manager) EmitSync

func (m *Manager) EmitSync(ctx context.Context, event *Event)

func (*Manager) Register

func (m *Manager) Register(hook Hook, config HookConfig)

func (*Manager) RegisteredHooks

func (m *Manager) RegisteredHooks() map[string][]EventType

func (*Manager) Unregister

func (m *Manager) Unregister(hookName string)

type SlackConfig added in v0.9.0

type SlackConfig struct {
	WebhookURL   string        `json:"webhook_url"`
	Channel      string        `json:"channel,omitempty"`
	Username     string        `json:"username,omitempty"`
	IconEmoji    string        `json:"icon_emoji,omitempty"`
	Timeout      time.Duration `json:"timeout"`
	FilterEvents []EventType   `json:"filter_events"`
}

type SlackHook added in v0.9.0

type SlackHook struct {
	// contains filtered or unexported fields
}

func NewSlackHook added in v0.9.0

func NewSlackHook(name string, config SlackConfig, logger *slog.Logger) *SlackHook

func (*SlackHook) Close added in v0.9.0

func (h *SlackHook) Close() error

func (*SlackHook) Events added in v0.9.0

func (h *SlackHook) Events() []EventType

func (*SlackHook) Handle added in v0.9.0

func (h *SlackHook) Handle(ctx context.Context, event *Event) error

func (*SlackHook) Name added in v0.9.0

func (h *SlackHook) Name() string

type WebhookConfig

type WebhookConfig struct {
	URL          string            `json:"url"`
	Method       string            `json:"method"`
	Headers      map[string]string `json:"headers"`
	Timeout      time.Duration     `json:"timeout"`
	Secret       string            `json:"secret"`
	FilterEvents []EventType       `json:"filter_events"`
}

type WebhookHook

type WebhookHook struct {
	// contains filtered or unexported fields
}

func NewWebhookHook

func NewWebhookHook(name string, config WebhookConfig, logger *slog.Logger) *WebhookHook

func (*WebhookHook) Close

func (h *WebhookHook) Close() error

func (*WebhookHook) Events

func (h *WebhookHook) Events() []EventType

func (*WebhookHook) Handle

func (h *WebhookHook) Handle(ctx context.Context, event *Event) error

func (*WebhookHook) Name

func (h *WebhookHook) Name() string

type WebhookPayload

type WebhookPayload struct {
	Event     EventType   `json:"event"`
	Timestamp time.Time   `json:"timestamp"`
	Namespace string      `json:"namespace,omitempty"`
	SessionID string      `json:"session_id,omitempty"`
	Data      interface{} `json:"data,omitempty"`
	Error     string      `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL