Documentation
¶
Overview ¶
Package hooks watches filesystem paths and spawns tasks when things change.
Index ¶
- Constants
- func DecodeToken(stored []byte) (string, error)
- func EncodeToken(raw string) ([]byte, error)
- func NormalizePath(p string) string
- func ParseUint(v any) uint
- func ValidateHookPath(path string) error
- type Engine
- type SeenTracker
- type Service
- func (s *Service) Create(ctx context.Context, wsId uint, memberId, tokenId *uint, ...) (*types.Hook, error)
- func (s *Service) Delete(ctx context.Context, externalId string) error
- func (s *Service) Get(ctx context.Context, externalId string) (*types.Hook, error)
- func (s *Service) List(ctx context.Context, wsId uint) ([]*types.Hook, error)
- func (s *Service) ListRuns(ctx context.Context, hookId uint) ([]*types.RunExecution, error)
- func (s *Service) Update(ctx context.Context, externalId string, prompt *string, active *bool, ...) (*types.Hook, error)
- type SkillReader
- type SourcePoller
- type StorageSkillReader
- type TaskCreator
- type TaskFactory
- type ViewSyncer
Constants ¶
const ( EventFsCreate = "fs.create" EventFsWrite = "fs.write" EventFsDelete = "fs.delete" EventSourceChange = "source.change" )
Variables ¶
This section is empty.
Functions ¶
func DecodeToken ¶
func EncodeToken ¶
func NormalizePath ¶
func ValidateHookPath ¶ added in v0.1.32
ValidateHookPath checks if a path is valid for hook creation. This is a basic sanity check blocking obvious invalid paths. The real validation (checking for external_id) happens on the frontend.
Hooks cannot be attached to:
- System root directories (/tasks, /tools, /skills, /sources)
- Root-level source folders (/sources/gmail, /sources/github)
Hooks CAN be attached to:
- Source view folders under sources (/sources/gmail/my-query)
- Top-level query folders (/my-emails)
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func NewEngine ¶
func NewEngine(store repository.FilesystemStore, creator TaskCreator, backend repository.BackendRepository, skillReader SkillReader) *Engine
func (*Engine) InvalidateCache ¶
type SeenTracker ¶
type SeenTracker struct {
// contains filtered or unexported fields
}
SeenTracker detects new query result IDs by diffing against the previous set. Usage: Compare (read-only) → act on new IDs → Commit (update stored set). This two-phase approach ensures the stored set only advances after the caller has successfully processed the new IDs.
func NewSeenTracker ¶
func NewSeenTracker(rdb *common.RedisClient) *SeenTracker
func (*SeenTracker) Commit ¶
Commit replaces the stored set with current and refreshes the TTL. Call only after the caller has successfully acted on the new IDs from Compare.
func (*SeenTracker) Compare ¶
Compare returns IDs in current that weren't in the previous set at key. Does NOT modify the stored set -- call Commit after successful processing. Returns nil on first call (empty stored set) to seed the baseline without triggering a flood of events for pre-existing results.
type Service ¶
type Service struct {
Store repository.FilesystemStore
Backend repository.BackendRepository
EventBus *common.EventBus
}
Service handles hook CRUD. Shared by HTTP and gRPC handlers.
type SkillReader ¶ added in v0.1.32
type SkillReader interface {
// ReadSkillContent reads the SKILL.md file for a skill path (e.g., /skills/email-triage).
// Returns the full content of the SKILL.md file.
ReadSkillContent(ctx context.Context, workspaceId uint, skillPath string) (string, error)
}
SkillReader reads skill content from workspace storage.
type SourcePoller ¶
type SourcePoller struct {
// contains filtered or unexported fields
}
SourcePoller periodically syncs source views watched by active hooks. Each view is locked via Redis SETNX so only one replica refreshes it per interval.
func NewSourcePoller ¶
func NewSourcePoller(store repository.FilesystemStore, refresher ViewSyncer, rdb *common.RedisClient) *SourcePoller
func (*SourcePoller) Poll ¶
func (p *SourcePoller) Poll(ctx context.Context)
Poll fetches stale watched queries and refreshes them with distributed locking.
func (*SourcePoller) Start ¶
func (p *SourcePoller) Start(ctx context.Context)
Start runs the poll loop. Call as a goroutine.
type StorageSkillReader ¶ added in v0.1.32
type StorageSkillReader struct {
// contains filtered or unexported fields
}
StorageSkillReader reads skill content from S3.
func NewStorageSkillReader ¶ added in v0.1.32
func NewStorageSkillReader(storage *clients.StorageClient, backend repository.BackendRepository) *StorageSkillReader
func (*StorageSkillReader) ReadSkillContent ¶ added in v0.1.32
func (r *StorageSkillReader) ReadSkillContent(ctx context.Context, workspaceId uint, skillPath string) (string, error)
ReadSkillContent reads SKILL.md for a skill path like "/skills/email-triage".
type TaskCreator ¶
type TaskFactory ¶ added in v0.1.47
type TaskFactory struct {
// contains filtered or unexported fields
}
Factory creates tasks, saves to Postgres, and pushes to the queue.
func NewTaskFactory ¶ added in v0.1.47
func NewTaskFactory(backend repository.BackendRepository, queue repository.TaskQueue, defaultImage string) *TaskFactory
type ViewSyncer ¶ added in v0.1.50
type ViewSyncer interface {
RefreshQuery(ctx context.Context, query *types.FilesystemQuery) error
}
ViewSyncer re-executes a source view query and emits change events. Implemented by SourceService in the gateway layer.