hooks

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 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 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