store

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GlobalSettingsKey  = "app_settings"
	AuthCredentialsKey = "auth_credentials"
)

Variables

This section is empty.

Functions

func ValidatePathReference

func ValidatePathReference(ref model.PathReference) error

func ValidatePathReferences

func ValidatePathReferences(refs []model.PathReference) error

func ValidateSegments

func ValidateSegments(segments []model.Segment) error

Types

type AppError

type AppError struct {
	Kind            ErrorKind
	Message         string
	CurrentRevision int64
}

func NewConflictError

func NewConflictError(msg string, currentRev int64) *AppError

func NewInvalidInputError

func NewInvalidInputError(msg string) *AppError

func NewNotFoundError

func NewNotFoundError(msg string) *AppError

func NewTaskClosedError

func NewTaskClosedError(msg string) *AppError

func (*AppError) Error

func (e *AppError) Error() string

type AuthCredentials

type AuthCredentials struct {
	Username  string    `json:"username"`
	Password  string    `json:"password"`
	UpdatedAt time.Time `json:"updated_at"`
}

type CreateSessionInput

type CreateSessionInput struct {
	SessionID        string `json:"session_id,omitempty"`
	WorkflowID       string `json:"workflow_id,omitempty"`
	HostName         string `json:"host_name,omitempty"`
	ProjectDirectory string `json:"project_directory"`
	Title            string `json:"title,omitempty"`
	Summary          string `json:"summary"`
	UserPresence     string `json:"user_presence,omitempty"`
	TimeoutSeconds   int    `json:"timeout_seconds,omitempty"`
}

type ErrorKind

type ErrorKind string
const (
	ErrNotFound         ErrorKind = "not_found"
	ErrConflict         ErrorKind = "conflict"
	ErrInvalidInput     ErrorKind = "invalid_input"
	ErrClosed           ErrorKind = "task_closed"
	ErrUnauthorized     ErrorKind = "unauthorized"
	ErrOperationFailed  ErrorKind = "operation_failed"
	ErrIdempotencyClash ErrorKind = "idempotency_clash"
)

type GlobalAppSettings

type GlobalAppSettings struct {
	HostName                    string           `json:"hostName"`
	DefaultTimeoutSeconds       int              `json:"defaultTimeoutSeconds"`
	PromptWaitMinutes           int              `json:"promptWaitMinutes"`
	MaxNoFeedbackChecks         int              `json:"maxNoFeedbackChecks"`
	DefaultWaitCountdownMinutes int              `json:"defaultWaitCountdownMinutes"`
	UserPresence                string           `json:"userPresence"`
	Security                    SecuritySettings `json:"security"`
	FlowPrompts                 struct {
		Online struct {
			WaitPollPrompt  string `json:"waitPollPrompt"`
			ExhaustedPrompt string `json:"exhaustedPrompt"`
		} `json:"online"`
		Away struct {
			ImmediatePrompt string `json:"immediatePrompt"`
		} `json:"away"`
		Autopilot struct {
			ImmediatePrompt string `json:"immediatePrompt"`
		} `json:"autopilot"`
	} `json:"flowPrompts"`
}

type QueueFeedbackInput

type QueueFeedbackInput struct {
	WorkflowID       string               `json:"workflow_id"`
	HostName         string               `json:"host_name,omitempty"`
	ProjectDirectory string               `json:"project_directory,omitempty"`
	ResponseText     string               `json:"response_text"`
	UserMessages     []string             `json:"user_messages,omitempty"`
	Images           []model.SessionImage `json:"images,omitempty"`
}

type RevokedFeedbackResult

type RevokedFeedbackResult struct {
	SessionID    string               `json:"session_id,omitempty"`
	WorkflowID   string               `json:"workflow_id,omitempty"`
	QueuedID     uint                 `json:"queued_id,omitempty"`
	ResponseText string               `json:"response_text"`
	UserMessages []string             `json:"user_messages"`
	Images       []model.SessionImage `json:"images"`
}

type SecuritySettings

type SecuritySettings struct {
	BruteForceProtection bool     `json:"bruteForceProtection"` // 是否开启反爆破保护
	MaxFailedAttempts    int      `json:"maxFailedAttempts"`    // 最大连续失败尝试次数 (默认 5)
	LockoutMinutes       int      `json:"lockoutMinutes"`       // 封禁时长 (分钟,默认 15)
	WhitelistIPs         []string `json:"whitelistIps"`         // 白名单 IP 列表
}

type Store

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

func New

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

func (*Store) AckReports

func (s *Store) AckReports(ctx context.Context, projectID, taskID string, throughSequence int64) (*model.AckSummary, error)

func (*Store) AddReport

func (s *Store) AddReport(ctx context.Context, input model.AddReportInput) (*model.ReportResult, error)

func (*Store) ArchiveFeedbackSession

func (s *Store) ArchiveFeedbackSession(ctx context.Context, idOrWorkflow string) (*model.FeedbackSession, error)

func (*Store) CancelFeedbackSession

func (s *Store) CancelFeedbackSession(ctx context.Context, idOrWorkflow string) (*model.FeedbackSession, error)

func (*Store) CheckFeedback

func (s *Store) CheckFeedback(ctx context.Context, input model.CheckFeedbackInput) (*model.CheckFeedbackResult, error)

func (*Store) CloseTask

func (s *Store) CloseTask(ctx context.Context, projectID, taskID string, expectedRevision int64, idempotencyKey string) (*model.MutationResult, error)

func (*Store) CreateFeedbackSession

func (s *Store) CreateFeedbackSession(ctx context.Context, input CreateSessionInput) (*model.FeedbackSession, error)

func (*Store) CreateTask

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

func (*Store) DB

func (s *Store) DB() *gorm.DB

func (*Store) DeleteWorkflowDraft

func (s *Store) DeleteWorkflowDraft(ctx context.Context, workflowID string) error

DeleteWorkflowDraft 删除工作流草稿数据

func (*Store) GetAuthCredentials

func (s *Store) GetAuthCredentials(ctx context.Context) (*AuthCredentials, error)

GetAuthCredentials 获取数据库中持久化的账号密码

func (*Store) GetAuthCredentialsWithDB

func (s *Store) GetAuthCredentialsWithDB(ctx context.Context, db *gorm.DB) (*AuthCredentials, error)

GetAuthCredentialsWithDB 从指定 DB (支持事务) 获取数据库中持久化的账号密码

func (*Store) GetCurrentFeedbackSession

func (s *Store) GetCurrentFeedbackSession(ctx context.Context, projectDir string) (*model.FeedbackSession, error)

func (*Store) GetFeedbackSession

func (s *Store) GetFeedbackSession(ctx context.Context, sessionID string) (*model.FeedbackSession, error)

func (*Store) GetGlobalAppSettings

func (s *Store) GetGlobalAppSettings(ctx context.Context) (*GlobalAppSettings, error)

GetGlobalAppSettings 获取强类型系统全局配置,含完备默认值

func (*Store) GetGlobalAppSettingsWithDB

func (s *Store) GetGlobalAppSettingsWithDB(ctx context.Context, db *gorm.DB) (*GlobalAppSettings, error)

GetGlobalAppSettingsWithDB 从指定 DB (支持事务 tx) 获取强类型系统全局配置

func (*Store) GetLatestWorkflowFeedbackSession

func (s *Store) GetLatestWorkflowFeedbackSession(ctx context.Context, workflowID string) (*model.FeedbackSession, error)

GetLatestWorkflowFeedbackSession 自动查找某工作流下最近的会话(优先 pending 活跃轮次,其次最新轮次)

func (*Store) GetSettings

func (s *Store) GetSettings(ctx context.Context) (map[string]any, error)

GetSettings 从数据库获取全局配置,若不存在返回默认 map

func (*Store) GetSettingsWithDB

func (s *Store) GetSettingsWithDB(ctx context.Context, db *gorm.DB) (map[string]any, error)

GetSettingsWithDB 从指定 DB (支持事务 tx) 获取全局配置

func (*Store) GetTask

func (s *Store) GetTask(ctx context.Context, projectID, taskID string) (*model.Task, error)

func (*Store) GetWorkflowDraft

func (s *Store) GetWorkflowDraft(ctx context.Context, workflowID string) (*model.WorkflowDraft, error)

GetWorkflowDraft 获取工作流对应的草稿数据,若不存在返回 nil, nil

func (*Store) KeepaliveFeedbackSession

func (s *Store) KeepaliveFeedbackSession(ctx context.Context, sessionID string, extendSec int) (*model.FeedbackSession, error)

func (*Store) ListFeedbackSessions

func (s *Store) ListFeedbackSessions(ctx context.Context, projectDir, status string, limit int) ([]model.FeedbackSession, error)

func (*Store) ListPendingQueuedFeedbacks

func (s *Store) ListPendingQueuedFeedbacks(ctx context.Context, workflowID string) ([]model.QueuedFeedback, error)

func (*Store) ListTasks

func (s *Store) ListTasks(ctx context.Context, projectID, state, cursor string, limit int, updatesOnly bool) (*model.TaskPage, error)

func (*Store) MarkSessionConsumedByAI

func (s *Store) MarkSessionConsumedByAI(ctx context.Context, sessionID string) error

func (*Store) QueueWorkflowFeedback

func (s *Store) QueueWorkflowFeedback(ctx context.Context, input QueueFeedbackInput) (*model.QueuedFeedback, error)

func (*Store) ReadReports

func (s *Store) ReadReports(ctx context.Context, projectID, taskID string, afterSequence int64, limit int) (*model.ReportPage, error)

func (*Store) RenameFeedbackSession

func (s *Store) RenameFeedbackSession(ctx context.Context, idOrWorkflow, newTitle string) (*model.FeedbackSession, error)

func (*Store) ResetAuthCredentials

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

ResetAuthCredentials 删除数据库中的账号密码记录,回退为环境变量值

func (*Store) RevokeQueuedFeedback

func (s *Store) RevokeQueuedFeedback(ctx context.Context, queuedID uint) (*RevokedFeedbackResult, error)

func (*Store) RevokeSessionFeedback

func (s *Store) RevokeSessionFeedback(ctx context.Context, sessionID string) (*RevokedFeedbackResult, *model.FeedbackSession, error)

func (*Store) SaveAuthCredentials

func (s *Store) SaveAuthCredentials(ctx context.Context, username, password string) error

SaveAuthCredentials 保存或更新账号密码至数据库

func (*Store) SaveSettings

func (s *Store) SaveSettings(ctx context.Context, settings map[string]any) error

SaveSettings 保存全局配置至数据库

func (*Store) SaveWorkflowDraft

func (s *Store) SaveWorkflowDraft(ctx context.Context, workflowID string, activeIndex int, draftsJSON string) (*model.WorkflowDraft, error)

SaveWorkflowDraft 保存或更新工作流草稿数据

func (*Store) SendFeedback

func (s *Store) SendFeedback(ctx context.Context, input model.SendFeedbackInput) (*model.Feedback, error)

func (*Store) SetWaitPolicy

func (s *Store) SetWaitPolicy(ctx context.Context, input model.SetWaitPolicyInput) (*model.MutationResult, error)

func (*Store) SubmitFeedback

func (s *Store) SubmitFeedback(ctx context.Context, input SubmitFeedbackInput) (*model.FeedbackSession, error)

func (*Store) Sync

func (s *Store) Sync(ctx context.Context, input model.SyncInput) (*model.SyncResult, error)

func (*Store) UnarchiveFeedbackSession

func (s *Store) UnarchiveFeedbackSession(ctx context.Context, idOrWorkflow string) (*model.FeedbackSession, error)

func (*Store) UpdateSessionMaxChecks

func (s *Store) UpdateSessionMaxChecks(ctx context.Context, idOrWorkflow string, maxChecks int) (*model.FeedbackSession, error)

func (*Store) UpdateSessionPromptWait

func (s *Store) UpdateSessionPromptWait(ctx context.Context, idOrWorkflow string, waitMinutes int) (*model.FeedbackSession, error)

func (*Store) UpdateSessionUserPresence

func (s *Store) UpdateSessionUserPresence(ctx context.Context, idOrWorkflow string, presence string) (*model.FeedbackSession, error)

func (*Store) UpdateSessionWaitCountdown

func (s *Store) UpdateSessionWaitCountdown(ctx context.Context, idOrWorkflow string, countdownMinutes int) (*model.FeedbackSession, error)

func (*Store) UpdateTask

func (s *Store) UpdateTask(ctx context.Context, input model.UpdateTaskInput) (*model.MutationResult, error)

func (*Store) WithTx

func (s *Store) WithTx(ctx context.Context, fn func(tx *gorm.DB) error) error

type SubmitFeedbackInput

type SubmitFeedbackInput struct {
	SessionID    string               `json:"session_id"`
	ResponseText string               `json:"response_text"`
	UserMessages []string             `json:"user_messages,omitempty"`
	Images       []model.SessionImage `json:"images,omitempty"`
}

Jump to

Keyboard shortcuts

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