store

package
v0.0.0-...-91a168e Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrActionApprovalNotFound = errors.New("action approval not found")
	ErrActionApprovalNotReady = errors.New("action approval is not pending")
)
View Source
var (
	ErrIdentityNotFound = errors.New("identity not found")
	ErrContextNotFound  = errors.New("context not found")
)
View Source
var (
	ErrObjectiveNotFound = errors.New("objective not found")
	ErrObjectiveInvalid  = errors.New("objective input is invalid")
)
View Source
var (
	ErrPairingNotFound        = errors.New("pairing request not found")
	ErrPairingNotPending      = errors.New("pairing request is not pending")
	ErrPairingExpired         = errors.New("pairing request expired")
	ErrIdentityAlreadyLinked  = errors.New("identity is already linked")
	ErrPairingInvalidRole     = errors.New("invalid role")
	ErrPairingUserNotFound    = errors.New("target user not found")
	ErrPairingInvalidToken    = errors.New("invalid token")
	ErrPairingInvalidInput    = errors.New("invalid pairing input")
	ErrPairingInvalidReason   = errors.New("denial reason required")
	ErrPairingInvalidApprover = errors.New("approver user id required")
)
View Source
var ErrTaskNotFound = errors.New("task not found")
View Source
var ErrTaskNotRunningForWorker = errors.New("task not running for worker")
View Source
var ErrTaskRunAlreadyExists = errors.New("task run already exists")

Functions

func ComputeScheduleNextRun

func ComputeScheduleNextRun(cronExpr string, from time.Time) (time.Time, error)

ComputeScheduleNextRun resolves the next run timestamp for schedule objectives.

func ComputeScheduleNextRunForTimezone

func ComputeScheduleNextRunForTimezone(cronExpr, timezone string, from time.Time) (time.Time, error)

ComputeScheduleNextRunForTimezone resolves the next run timestamp in the provided IANA timezone.

Types

type ActionApproval

type ActionApproval struct {
	ID               string
	WorkspaceID      string
	ContextID        string
	Connector        string
	ExternalID       string
	RequesterUserID  string
	ActionType       string
	ActionTarget     string
	ActionSummary    string
	Payload          map[string]any
	Status           string
	ApproverUserID   string
	DeniedReason     string
	ExecutionStatus  string
	ExecutionMessage string
	ExecutorPlugin   string
	ExecutedAt       time.Time
	CreatedAt        time.Time
	UpdatedAt        time.Time
}

type AgentAuditEvent

type AgentAuditEvent struct {
	ID           string
	WorkspaceID  string
	ContextID    string
	Connector    string
	ExternalID   string
	SourceUserID string
	EventType    string
	Stage        string
	ToolName     string
	ToolClass    string
	Blocked      bool
	BlockReason  string
	Message      string
	CreatedAt    time.Time
}

type ApproveActionApprovalInput

type ApproveActionApprovalInput struct {
	ID             string
	ApproverUserID string
}

type ApprovePairingInput

type ApprovePairingInput struct {
	Token          string
	ApproverUserID string
	Role           string
	TargetUserID   string
}

type ApprovePairingResult

type ApprovePairingResult struct {
	PairingRequest PairingRequest
	UserID         string
	IdentityID     string
}

type ContextDelivery

type ContextDelivery struct {
	ContextID   string
	WorkspaceID string
	Connector   string
	ExternalID  string
	IsAdmin     bool
}

type ContextPolicy

type ContextPolicy struct {
	ContextID    string
	WorkspaceID  string
	IsAdmin      bool
	SystemPrompt string
}

type ContextRecord

type ContextRecord struct {
	ID          string
	WorkspaceID string
	IsAdmin     bool
}

type CreateActionApprovalInput

type CreateActionApprovalInput struct {
	WorkspaceID     string
	ContextID       string
	Connector       string
	ExternalID      string
	RequesterUserID string
	ActionType      string
	ActionTarget    string
	ActionSummary   string
	Payload         map[string]any
}

type CreateAgentAuditEventInput

type CreateAgentAuditEventInput struct {
	WorkspaceID  string
	ContextID    string
	Connector    string
	ExternalID   string
	SourceUserID string
	EventType    string
	Stage        string
	ToolName     string
	ToolClass    string
	Blocked      bool
	BlockReason  string
	Message      string
}

type CreateObjectiveInput

type CreateObjectiveInput struct {
	WorkspaceID string
	ContextID   string
	Title       string
	Prompt      string
	TriggerType ObjectiveTriggerType
	EventKey    string
	CronExpr    string
	Timezone    string
	NextRunAt   time.Time
	Active      *bool
}

type CreatePairingRequestInput

type CreatePairingRequestInput struct {
	Connector       string
	ConnectorUserID string
	DisplayName     string
	ExpiresAt       time.Time
}

type CreateTaskInput

type CreateTaskInput struct {
	ID               string
	WorkspaceID      string
	ContextID        string
	Kind             string
	Title            string
	Prompt           string
	RunKey           string
	Status           string
	RouteClass       string
	Priority         string
	DueAt            time.Time
	AssignedLane     string
	SourceConnector  string
	SourceExternalID string
	SourceUserID     string
	SourceText       string
}

type DenyActionApprovalInput

type DenyActionApprovalInput struct {
	ID             string
	ApproverUserID string
	Reason         string
}

type DenyPairingInput

type DenyPairingInput struct {
	Token          string
	ApproverUserID string
	Reason         string
}

type ListAgentAuditEventsInput

type ListAgentAuditEventsInput struct {
	WorkspaceID string
	ContextID   string
	Connector   string
	ExternalID  string
	EventType   string
	BlockedOnly bool
	Limit       int
}

type ListObjectivesInput

type ListObjectivesInput struct {
	WorkspaceID string
	ActiveOnly  bool
	Limit       int
}

type ListTasksInput

type ListTasksInput struct {
	WorkspaceID string
	ContextID   string
	Kind        string
	Status      string
	Limit       int
}

type MarkIMAPIngestionInput

type MarkIMAPIngestionInput struct {
	AccountKey  string
	UID         uint32
	MessageID   string
	WorkspaceID string
	ContextID   string
	FilePath    string
}

type Objective

type Objective struct {
	ID                   string
	WorkspaceID          string
	ContextID            string
	Title                string
	Prompt               string
	TriggerType          ObjectiveTriggerType
	EventKey             string
	CronExpr             string
	Timezone             string
	Active               bool
	NextRunAt            time.Time
	LastRunAt            time.Time
	LastError            string
	RunCount             int
	SuccessCount         int
	FailureCount         int
	ConsecutiveFailures  int
	ConsecutiveSuccesses int
	TotalRunDurationMs   int64
	LastSuccessAt        time.Time
	LastFailureAt        time.Time
	AutoPausedReason     string
	RecentErrors         []ObjectiveRunError
	CreatedAt            time.Time
	UpdatedAt            time.Time
}

type ObjectiveRunError

type ObjectiveRunError struct {
	OccurredAt time.Time `json:"occurred_at"`
	Message    string    `json:"message"`
}

type ObjectiveTriggerType

type ObjectiveTriggerType string
const (
	ObjectiveTriggerSchedule ObjectiveTriggerType = "schedule"
	ObjectiveTriggerEvent    ObjectiveTriggerType = "event"
)

type PairingRequest

type PairingRequest struct {
	ID              string
	TokenHint       string
	Connector       string
	ConnectorUserID string
	DisplayName     string
	Status          string
	ExpiresAt       time.Time
	ApprovedUserID  string
	ApproverUserID  string
	DeniedReason    string
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

type PairingRequestWithToken

type PairingRequestWithToken struct {
	PairingRequest
	Token string
}

type Store

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

func New

func New(path string) (*Store, error)

func (*Store) ApproveActionApproval

func (s *Store) ApproveActionApproval(ctx context.Context, input ApproveActionApprovalInput) (ActionApproval, error)

func (*Store) ApprovePairing

func (s *Store) ApprovePairing(ctx context.Context, input ApprovePairingInput) (ApprovePairingResult, error)

func (*Store) AutoMigrate

func (s *Store) AutoMigrate(ctx context.Context) error

func (*Store) Close

func (s *Store) Close() error

func (*Store) CreateActionApproval

func (s *Store) CreateActionApproval(ctx context.Context, input CreateActionApprovalInput) (ActionApproval, error)

func (*Store) CreateAgentAuditEvent

func (s *Store) CreateAgentAuditEvent(ctx context.Context, input CreateAgentAuditEventInput) (AgentAuditEvent, error)

func (*Store) CreateObjective

func (s *Store) CreateObjective(ctx context.Context, input CreateObjectiveInput) (Objective, error)

func (*Store) CreatePairingRequest

func (s *Store) CreatePairingRequest(ctx context.Context, input CreatePairingRequestInput) (PairingRequestWithToken, error)

func (*Store) CreateTask

func (s *Store) CreateTask(ctx context.Context, input CreateTaskInput) error

func (*Store) DeleteObjective

func (s *Store) DeleteObjective(ctx context.Context, id string) error

func (*Store) DenyActionApproval

func (s *Store) DenyActionApproval(ctx context.Context, input DenyActionApprovalInput) (ActionApproval, error)

func (*Store) DenyPairing

func (s *Store) DenyPairing(ctx context.Context, input DenyPairingInput) (PairingRequest, error)

func (*Store) EnsureContextForExternalChannel

func (s *Store) EnsureContextForExternalChannel(ctx context.Context, connector, externalID, displayName string) (ContextRecord, error)

func (*Store) IsIMAPMessageIngested

func (s *Store) IsIMAPMessageIngested(ctx context.Context, accountKey string, uid uint32, messageID string) (bool, error)

func (*Store) ListAdminDeliveries

func (s *Store) ListAdminDeliveries(ctx context.Context, limit int) ([]ContextDelivery, error)

func (*Store) ListAgentAuditEvents

func (s *Store) ListAgentAuditEvents(ctx context.Context, input ListAgentAuditEventsInput) ([]AgentAuditEvent, error)

func (*Store) ListDueObjectives

func (s *Store) ListDueObjectives(ctx context.Context, now time.Time, limit int) ([]Objective, error)

func (*Store) ListEventObjectives

func (s *Store) ListEventObjectives(ctx context.Context, workspaceID, eventKey string, limit int) ([]Objective, error)

func (*Store) ListObjectives

func (s *Store) ListObjectives(ctx context.Context, input ListObjectivesInput) ([]Objective, error)

func (*Store) ListPendingActionApprovals

func (s *Store) ListPendingActionApprovals(ctx context.Context, connector, externalID string, limit int) ([]ActionApproval, error)

func (*Store) ListPendingActionApprovalsGlobal

func (s *Store) ListPendingActionApprovalsGlobal(ctx context.Context, limit int) ([]ActionApproval, error)

func (*Store) ListTasks

func (s *Store) ListTasks(ctx context.Context, input ListTasksInput) ([]TaskRecord, error)

func (*Store) ListWorkspaceAdminDeliveries

func (s *Store) ListWorkspaceAdminDeliveries(ctx context.Context, workspaceID string, limit int) ([]ContextDelivery, error)

func (*Store) LookupActionApproval

func (s *Store) LookupActionApproval(ctx context.Context, id string) (ActionApproval, error)

func (*Store) LookupContextDelivery

func (s *Store) LookupContextDelivery(ctx context.Context, contextID string) (ContextDelivery, error)

func (*Store) LookupContextPolicy

func (s *Store) LookupContextPolicy(ctx context.Context, contextID string) (ContextPolicy, error)

func (*Store) LookupContextPolicyByExternal

func (s *Store) LookupContextPolicyByExternal(ctx context.Context, connector, externalID string) (ContextPolicy, error)

func (*Store) LookupObjective

func (s *Store) LookupObjective(ctx context.Context, id string) (Objective, error)

func (*Store) LookupPairingByToken

func (s *Store) LookupPairingByToken(ctx context.Context, token string) (PairingRequest, error)

func (*Store) LookupTask

func (s *Store) LookupTask(ctx context.Context, id string) (TaskRecord, error)

func (*Store) LookupUserIdentity

func (s *Store) LookupUserIdentity(ctx context.Context, connector, connectorUserID string) (UserIdentity, error)

func (*Store) MarkIMAPMessageIngested

func (s *Store) MarkIMAPMessageIngested(ctx context.Context, input MarkIMAPIngestionInput) error

func (*Store) MarkTaskCompleted

func (s *Store) MarkTaskCompleted(ctx context.Context, id string, finishedAt time.Time, summary, resultPath string) error

func (*Store) MarkTaskCompletedByWorker

func (s *Store) MarkTaskCompletedByWorker(ctx context.Context, id string, workerID int, finishedAt time.Time, summary, resultPath string) error

func (*Store) MarkTaskFailed

func (s *Store) MarkTaskFailed(ctx context.Context, id string, finishedAt time.Time, message string) error

func (*Store) MarkTaskFailedByWorker

func (s *Store) MarkTaskFailedByWorker(ctx context.Context, id string, workerID int, finishedAt time.Time, message string) error

func (*Store) MarkTaskRunning

func (s *Store) MarkTaskRunning(ctx context.Context, id string, workerID int, startedAt time.Time) error

func (*Store) Ping

func (s *Store) Ping(ctx context.Context) error

func (*Store) RequeueTask

func (s *Store) RequeueTask(ctx context.Context, id string) error

func (*Store) SetContextAdminByExternal

func (s *Store) SetContextAdminByExternal(ctx context.Context, connector, externalID string, enabled bool) (ContextRecord, error)

func (*Store) SetContextSystemPromptByExternal

func (s *Store) SetContextSystemPromptByExternal(ctx context.Context, connector, externalID, prompt string) (ContextPolicy, error)

func (*Store) SetObjectiveActive

func (s *Store) SetObjectiveActive(ctx context.Context, id string, active bool) (Objective, error)

func (*Store) UpdateActionExecution

func (s *Store) UpdateActionExecution(ctx context.Context, input UpdateActionExecutionInput) (ActionApproval, error)

func (*Store) UpdateObjective

func (s *Store) UpdateObjective(ctx context.Context, input UpdateObjectiveInput) (Objective, error)

func (*Store) UpdateObjectiveRun

func (s *Store) UpdateObjectiveRun(ctx context.Context, input UpdateObjectiveRunInput) (Objective, error)

func (*Store) UpdateTaskRouting

func (s *Store) UpdateTaskRouting(ctx context.Context, input UpdateTaskRoutingInput) (TaskRecord, error)

type TaskRecord

type TaskRecord struct {
	ID               string
	WorkspaceID      string
	ContextID        string
	Kind             string
	Title            string
	Prompt           string
	Status           string
	RouteClass       string
	Priority         string
	DueAt            time.Time
	AssignedLane     string
	SourceConnector  string
	SourceExternalID string
	SourceUserID     string
	SourceText       string
	Attempts         int
	WorkerID         int
	StartedAt        time.Time
	FinishedAt       time.Time
	ResultSummary    string
	ResultPath       string
	ErrorMessage     string
	CreatedAt        time.Time
	UpdatedAt        time.Time
}

type UpdateActionExecutionInput

type UpdateActionExecutionInput struct {
	ID               string
	ExecutionStatus  string
	ExecutionMessage string
	ExecutorPlugin   string
	ExecutedAt       time.Time
}

type UpdateObjectiveInput

type UpdateObjectiveInput struct {
	ID          string
	Title       *string
	Prompt      *string
	TriggerType *ObjectiveTriggerType
	EventKey    *string
	CronExpr    *string
	Timezone    *string
	NextRunAt   *time.Time
	Active      *bool
}

type UpdateObjectiveRunInput

type UpdateObjectiveRunInput struct {
	ID               string
	LastRunAt        time.Time
	NextRunAt        time.Time
	LastError        string
	RunDuration      time.Duration
	SkipStats        bool
	Active           *bool
	AutoPausedReason *string
}

type UpdateTaskRoutingInput

type UpdateTaskRoutingInput struct {
	ID           string
	RouteClass   string
	Priority     string
	DueAt        time.Time
	AssignedLane string
}

type UserIdentity

type UserIdentity struct {
	UserID      string
	DisplayName string
	Role        string
}

Jump to

Keyboard shortcuts

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