workspaceevents

package
v1.0.0-rc.16 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SourceHuman    = "human"
	SourceAgent    = "agent"
	SourceSchedule = "schedule"
	SourceEditor   = "editor"
	SourceWatcher  = "watcher"
	SourceTool     = "tool"
	SourceTerminal = "terminal"
	SourceApproval = "approval"
	SourceTrigger  = "trigger"
)
View Source
const (
	TypeEventFired = "event.fired"
	TypeFSCreated  = "fs.created"
	TypeFSModified = "fs.modified"
	TypeFSDeleted  = "fs.deleted"
	TypeFSMoved    = "fs.moved"
	TypeFSRescan   = "fs.rescan"

	TypeEditorOpened    = "editor.opened"
	TypeEditorClosed    = "editor.closed"
	TypeEditorSaved     = "editor.saved"
	TypeEditorDirty     = "editor.dirty"
	TypeEditorClean     = "editor.clean"
	TypeEditorSelection = "editor.selection"

	TypeTerminalStarted = "terminal.started"
	TypeTerminalExited  = "terminal.exited"

	TypeToolWrote = "tool.wrote"
	TypeToolRan   = "tool.ran"

	TypeApprovalDecided = "approval.decided"

	TypeTriggerStarted = "trigger.started"
	TypeTriggerSettled = "trigger.settled"
)
View Source
const (
	MaxDataBytes    = 4096
	MaxSubjectBytes = 1024
)
View Source
const DefaultRetentionSweep = 6 * time.Hour

Variables

View Source
var (
	ErrUnknownType    = errors.New("workspaceevents: unknown event type")
	ErrSourceMismatch = errors.New("workspaceevents: event type does not belong to this source")
	ErrInvalidSubject = errors.New("workspaceevents: invalid subject")
	ErrInvalidData    = errors.New("workspaceevents: data must be a JSON object")
	ErrDataTooLarge   = errors.New("workspaceevents: data exceeds the size limit")
	ErrRootNotGranted = errors.New("workspaceevents: root is not a granted workspace root")
)
View Source
var ErrDirectoryLimit = errors.New("workspaceevents: directory watch limit reached; deeper changes are not reported")
View Source
var ErrSchedule = errors.New("invalid schedule")

Functions

func ApprovalObserver

func ApprovalObserver(events Service, lookup SessionLookup) func(ctx context.Context, approval runtimetypes.HITLApproval, approved bool)

func LeaseFileName

func LeaseFileName(workspaceID, root string) string

func ParseScheduleInterval

func ParseScheduleInterval(value string) (time.Duration, error)

func RelativePath

func RelativePath(root, candidate string) (string, error)

func Scope

func Scope(workspaceID, root string) string

func StartRetention

func StartRetention(ctx context.Context, log PartitionPruner, setting RetentionSetting, every time.Duration, tracker libtracker.ActivityTracker) func()

func Subject

func Subject(workspaceID, root string) string

func SweepRetention

func SweepRetention(ctx context.Context, log PartitionPruner, setting RetentionSetting, now time.Time, tracker libtracker.ActivityTracker) ([]string, error)

func TopicRecord

func TopicRecord(scope, topic, source string, payload json.RawMessage, at time.Time) (runtimetypes.Event, error)

func ValidTopic

func ValidTopic(name string) bool

Types

type Event

type Event struct {
	ReplayedFrom int64           `json:"replayedFrom,omitempty"`
	NID          int64           `json:"nid"`
	Type         string          `json:"type"`
	Source       string          `json:"source"`
	Subject      string          `json:"subject,omitempty"`
	Time         time.Time       `json:"time"`
	Data         json.RawMessage `json:"data"`
	Hop          int             `json:"hop,omitempty"`
}

type Input

type Input struct {
	ReplayedFrom int64
	Type         string
	Source       string
	Subject      string
	Data         json.RawMessage
}

type PartitionPruner

type PartitionPruner interface {
	PrunePartitionsBefore(ctx context.Context, t time.Time) ([]string, error)
}

type RetentionSetting

type RetentionSetting func(ctx context.Context) (keep time.Duration, enabled bool, err error)

type Roots

type Roots interface {
	Roots() []string
	Resolve(root string) (string, error)
}

type Schedule

type Schedule struct {
	CreatedBy string          `json:"createdBy,omitempty"`
	ID        string          `json:"id"`
	Topic     string          `json:"topic"`
	Payload   json.RawMessage `json:"payload,omitempty"`
	At        *time.Time      `json:"at,omitempty"`
	Every     string          `json:"every,omitempty"`
	Cron      string          `json:"cron,omitempty"`
	Timezone  string          `json:"timezone,omitempty"`
	Next      time.Time       `json:"next"`
	Enabled   bool            `json:"enabled"`
}

type Schedules

type Schedules struct{ DB libdb.DBManager }

func (Schedules) Change

func (s Schedules) Change(ctx context.Context, scope, id string, enabled *bool) error

func (Schedules) Create

func (s Schedules) Create(ctx context.Context, scope string, req Schedule, now time.Time) (Schedule, error)

func (Schedules) Drain

func (s Schedules) Drain(ctx context.Context, scope string, now time.Time) ([]Event, error)

func (Schedules) List

func (s Schedules) List(ctx context.Context, scope string) ([]Schedule, error)

func (Schedules) Page

func (s Schedules) Page(ctx context.Context, scope, cursor string, limit int) ([]Schedule, string, error)

type Service

type Service interface {
	AnnounceCommitted(context.Context, string, Event)
	GrantedRoot(candidate string) (string, error)
	Append(ctx context.Context, root string, in Input) (Event, error)
	AppendBatch(ctx context.Context, root string, ins []Input) ([]Event, error)
	Since(ctx context.Context, root string, afterNID int64, limit int) ([]Event, error)
	Recent(ctx context.Context, root string, beforeNID int64, limit int, filter ...runtimetypes.EventQuery) ([]Event, error)
	Latest(ctx context.Context, root string) (int64, error)
	Subscribe(ctx context.Context, root string, ch chan<- []byte) (libbus.Subscription, error)
}

func New

func New(workspaceID string, log eventlog.Service, bus libbus.Messenger, roots Roots, tracker libtracker.ActivityTracker) Service

type SessionLookup

type SessionLookup func(ctx context.Context, internalSessionID string) (session, cwd string)

type SessionResolver

type SessionResolver func(ctx context.Context) (session, cwd string)

type SkipFunc

type SkipFunc func(root, rel string, isDir bool) bool

type TaskEventBridge

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

func NewTaskEventBridge

func NewTaskEventBridge(inner taskengine.TaskEventSink, events Service, session SessionResolver) *TaskEventBridge

func (*TaskEventBridge) PublishTaskEvent

func (b *TaskEventBridge) PublishTaskEvent(ctx context.Context, event taskengine.TaskEvent) error

func (*TaskEventBridge) Wants

type Watcher

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

func NewWatcher

func NewWatcher(events Service, roots Roots, cfg WatcherConfig) *Watcher

func (*Watcher) Start

func (w *Watcher) Start(ctx context.Context)

func (*Watcher) Stop

func (w *Watcher) Stop()

func (*Watcher) Watching

func (w *Watcher) Watching() []string

type WatcherConfig

type WatcherConfig struct {
	WorkspaceID string
	Owner       string
	LeaseDir    string
	Tracker     libtracker.ActivityTracker
	Skip        SkipFunc
	Transient   func(rel string) bool
	Reconcile   time.Duration
	LeaseTTL    time.Duration
	Debounce    time.Duration
	MaxDelay    time.Duration
	MaxDirs     int
}

Jump to

Keyboard shortcuts

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