Documentation
¶
Index ¶
- Constants
- Variables
- func MatchesAny(patterns []string, eventType string) bool
- func MatchesEvent(pattern string, eventType string) bool
- func MutableHash(p Preset) string
- func NewTaskEventObserver(service *Service, tasks TaskReader, logger *slog.Logger) taskpkg.EventObserver
- func ValidateEventPattern(pattern string) error
- type BridgeRuntime
- type Config
- type CreateRequest
- type DispatchResult
- type Event
- type Filter
- type Preset
- type Query
- type Service
- func (s *Service) Create(ctx context.Context, req CreateRequest) (Preset, error)
- func (s *Service) Delete(ctx context.Context, name string) error
- func (s *Service) Dispatch(ctx context.Context, event Event) (DispatchResult, error)
- func (s *Service) EnsureBuiltIns(ctx context.Context) error
- func (s *Service) Get(ctx context.Context, name string) (Preset, error)
- func (s *Service) List(ctx context.Context, query Query) ([]Preset, error)
- func (s *Service) Update(ctx context.Context, name string, req UpdateRequest) (Preset, error)
- type Store
- type Target
- type TaskReader
- type UpdateRequest
Constants ¶
View Source
const ( BuiltInDefaultVersion = "1" BuiltInTaskTerminal = "task_terminal" BuiltInSessionUnhealthy = "session_unhealthy" BuiltInProviderFailure = "provider_failure" BuiltInTaskRunPattern = "task.run_*" CursorConsumerPrefix = "preset:" )
Variables ¶
View Source
var ( ErrPresetNotFound = errors.New("notifications: preset not found") ErrInvalidPreset = errors.New("notifications: invalid preset") ErrPresetBuiltIn = errors.New("notifications: built-in preset cannot be deleted") ErrPresetDuplicateName = errors.New("notifications: preset name already exists") )
Functions ¶
func MatchesAny ¶
func MatchesEvent ¶
func MutableHash ¶
func NewTaskEventObserver ¶
func NewTaskEventObserver(service *Service, tasks TaskReader, logger *slog.Logger) taskpkg.EventObserver
func ValidateEventPattern ¶
Types ¶
type BridgeRuntime ¶
type BridgeRuntime interface {
GetBridgeInstance(ctx context.Context, id string) (bridgepkg.BridgeInstance, error)
ResolveBridgeTarget(
ctx context.Context,
bridgeID string,
query string,
) (bridgepkg.ResolveBridgeTargetResult, error)
DeliverBridge(
ctx context.Context,
extensionName string,
req bridgepkg.DeliveryRequest,
) (bridgepkg.DeliveryAck, error)
}
BridgeRuntime is the bridge surface needed for preset fanout.
type Config ¶
type Config struct {
Store Store
Cursors notifications.CursorStore
Bridges BridgeRuntime
Events store.EventSummaryStore
Logger *slog.Logger
Now func() time.Time
Timeout time.Duration
}
Config wires a preset service.
type CreateRequest ¶
type CreateRequest struct {
Name string `json:"name"`
Events []string `json:"events"`
Targets []Target `json:"targets,omitempty"`
Filter string `json:"filter,omitempty"`
Enabled bool `json:"enabled,omitempty"`
}
CreateRequest captures one operator-created preset.
type DispatchResult ¶
type DispatchResult struct {
Matched int `json:"matched"`
Delivered int `json:"delivered"`
Suppressed int `json:"suppressed"`
Skipped int `json:"skipped"`
Failed int `json:"failed"`
}
DispatchResult summarizes one event dispatch pass.
type Event ¶
type Event struct {
ID string `json:"id"`
Type string `json:"type"`
WorkspaceID string `json:"workspace_id,omitempty"`
AgentName string `json:"agent,omitempty"`
Provider string `json:"provider,omitempty"`
TaskID string `json:"task_id,omitempty"`
RunID string `json:"run_id,omitempty"`
Summary string `json:"summary,omitempty"`
Outcome eventspkg.Outcome `json:"outcome"`
Sequence int64 `json:"sequence"`
Payload json.RawMessage `json:"payload,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
Event is the normalized runtime event shape consumed by preset dispatch.
type Preset ¶
type Preset struct {
Name string `json:"name"`
Events []string `json:"events"`
Targets []Target `json:"targets"`
Filter string `json:"filter,omitempty"`
Enabled bool `json:"enabled"`
BuiltIn bool `json:"built_in"`
DefaultVersion string `json:"default_version,omitempty"`
DefaultHash string `json:"default_hash,omitempty"`
UserModified bool `json:"user_modified"`
DefaultUpdateAvailable bool `json:"default_update_available"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Preset is the SQLite-authoritative notification fanout policy.
func ApplyDefaultDrift ¶
func BuiltInPresets ¶
type Query ¶
type Query struct {
Enabled *bool `json:"enabled,omitempty"`
BuiltIn *bool `json:"built_in,omitempty"`
Name string `json:"name,omitempty"`
Limit int `json:"limit,omitempty"`
}
Query filters preset list operations.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service owns preset CRUD and cursor-backed fanout.
func NewService ¶
type Store ¶
type Store interface {
ListPresets(ctx context.Context, query Query) ([]Preset, error)
GetPreset(ctx context.Context, name string) (Preset, error)
CreatePreset(ctx context.Context, preset Preset) (Preset, error)
UpdatePreset(ctx context.Context, name string, req UpdateRequest) (Preset, error)
DeletePreset(ctx context.Context, name string) error
EnsureBuiltInPresets(ctx context.Context, defaults []Preset) error
}
Store persists notification presets.
type Target ¶
type Target struct {
BridgeID string `json:"bridge_id"`
CanonicalRoute string `json:"canonical_route,omitempty"`
DisplayName string `json:"display_name,omitempty"`
DeliveryMode bridgepkg.DeliveryMode `json:"delivery_mode,omitempty"`
}
Target is one bridge destination attached to a notification preset.
func (Target) StableHash ¶
type TaskReader ¶
TaskReader loads task context needed to enrich task-event notifications.
type UpdateRequest ¶
type UpdateRequest struct {
Events *[]string `json:"events,omitempty"`
Targets *[]Target `json:"targets,omitempty"`
Filter *string `json:"filter,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Now time.Time `json:"-"`
}
UpdateRequest captures mutable preset fields.
func (UpdateRequest) HasMutableField ¶
func (r UpdateRequest) HasMutableField() bool
Click to show internal directories.
Click to hide internal directories.