model

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxSegmentBytes           = 32 * 1024
	MaxWorkOrderBytes         = 48 * 1024
	MaxTaskContentBytes       = 128 * 1024
	MaxReportingGuideBytes    = 12 * 1024
	MaxReportingExampleBytes  = 16 * 1024
	MaxMessageBytes           = 32 * 1024
	MaxPathReferences         = 50
	MaxSegments               = 64
	MaxPageSize               = 100
	MaxCommunicationPageBytes = 160 * 1024
)

Variables

This section is empty.

Functions

func BuildSessionImageRelativeURL added in v1.6.0

func BuildSessionImageRelativeURL(sessionID string, index int, hash string) string

BuildSessionImageRelativeURL 统一定义图片标准相对访问路径(带不可变内容哈希)

Types

type AckSummary

type AckSummary struct {
	TaskID                     string `json:"task_id"`
	AcknowledgedReportSequence int64  `json:"acknowledged_report_sequence"`
	UnreadReportCount          int64  `json:"unread_report_count"`
}

type AddReportInput

type AddReportInput struct {
	ProjectID                    string          `json:"project_id"`
	TaskID                       string          `json:"task_id"`
	AcknowledgedTaskRevision     int64           `json:"acknowledged_task_revision"`
	AcknowledgedFeedbackSequence int64           `json:"acknowledged_feedback_sequence"`
	Kind                         string          `json:"kind"`
	Body                         string          `json:"body"`
	References                   []PathReference `json:"references,omitempty"`
	IdempotencyKey               string          `json:"idempotency_key,omitempty"`
}

type CheckFeedbackInput

type CheckFeedbackInput struct {
	ProjectID                    string `json:"project_id"`
	TaskID                       string `json:"task_id"`
	AfterFeedbackSequence        int64  `json:"after_feedback_sequence"`
	AcknowledgedTaskRevision     int64  `json:"acknowledged_task_revision"`
	AcknowledgedFeedbackSequence int64  `json:"acknowledged_feedback_sequence"`
	IdempotencyKey               string `json:"idempotency_key,omitempty"`
}

type CheckFeedbackResult

type CheckFeedbackResult struct {
	Feedback []Feedback `json:"feedback,omitempty"`
	Wait     WaitStatus `json:"wait"`
}

type CheckpointBasis added in v1.1.0

type CheckpointBasis struct {
	TaskRevision     int    `json:"task_revision,omitempty"`
	ReportSequence   int    `json:"report_sequence,omitempty"`
	FeedbackSequence int    `json:"feedback_sequence,omitempty"`
	GitCommit        string `json:"git_commit,omitempty"`
}

type CheckpointClaim added in v1.1.0

type CheckpointClaim struct {
	Claim    string   `json:"claim"`
	Evidence []string `json:"evidence,omitempty"`
}

type CheckpointContent added in v1.1.0

type CheckpointContent struct {
	Basis              CheckpointBasis      `json:"basis"`
	Objective          string               `json:"objective"`
	AcceptanceCriteria []string             `json:"acceptance_criteria,omitempty"`
	CurrentStage       *CheckpointStage     `json:"current_stage,omitempty"`
	Completed          []CheckpointClaim    `json:"completed,omitempty"`
	Decisions          []CheckpointDecision `json:"decisions,omitempty"`
	InProgress         []string             `json:"in_progress,omitempty"`
	NextActions        []string             `json:"next_actions,omitempty"`
	Blockers           []string             `json:"blockers,omitempty"`
	OpenQuestions      []string             `json:"open_questions,omitempty"`
	Constraints        []string             `json:"constraints,omitempty"`
	ChangedFiles       []string             `json:"changed_files,omitempty"`
	Verification       []string             `json:"verification,omitempty"`
	Unknowns           []string             `json:"unknowns,omitempty"`
	ResumeInstruction  string               `json:"resume_instruction,omitempty"`
}

type CheckpointDecision added in v1.1.0

type CheckpointDecision struct {
	DecisionID string `json:"decision_id"`
	Status     string `json:"status"`
	Summary    string `json:"summary"`
	Supersedes string `json:"supersedes,omitempty"`
	Source     string `json:"source,omitempty"`
}

type CheckpointStage added in v1.1.0

type CheckpointStage struct {
	ID     string `json:"id"`
	Status string `json:"status"`
}

type CreateTaskInput

type CreateTaskInput struct {
	ProjectID      string     `json:"project_id"`
	TaskID         string     `json:"task_id,omitempty"`
	Title          string     `json:"title,omitempty"`
	Mode           string     `json:"mode,omitempty"`
	Stages         TaskStages `json:"stages,omitempty"`
	Segments       []Segment  `json:"segments"`
	WaitPolicy     WaitPolicy `json:"wait_policy"`
	IdempotencyKey string     `json:"idempotency_key,omitempty"`
}

type Feedback

type Feedback struct {
	ID             uint           `gorm:"primaryKey" json:"-"`
	TaskID         string         `gorm:"index;not null;size:128" json:"task_id"`
	Sequence       int64          `gorm:"not null" json:"sequence"`
	TaskRevision   int64          `gorm:"default:0" json:"task_revision"`
	Source         string         `gorm:"size:32;default:'human'" json:"source"` // "human" | "commander"
	Body           string         `gorm:"type:text;not null" json:"body"`
	References     PathReferences `gorm:"type:text" json:"references,omitempty"`
	IdempotencyKey string         `gorm:"size:128;index" json:"idempotency_key,omitempty"`
	CreatedAt      time.Time      `json:"created_at"`
}

type FeedbackSession

type FeedbackSession struct {
	ID                   string        `gorm:"primaryKey;size:128" json:"session_id"`
	WorkflowID           string        `gorm:"index;size:128" json:"workflow_id"`
	CredentialID         *uint         `gorm:"index" json:"credential_id,omitempty"`
	HostName             string        `gorm:"size:128" json:"host_name,omitempty"`
	ProjectDirectory     string        `gorm:"size:512" json:"project_directory"`
	Title                string        `gorm:"size:256" json:"title"`
	Summary              string        `gorm:"type:text;not null" json:"summary"`
	Status               string        `gorm:"size:32;default:'pending'" json:"status"`       // pending, completed, timeout, cancelled, archived
	UserPresence         string        `gorm:"size:32;default:'online'" json:"user_presence"` // online, away, autopilot
	ResponseText         string        `gorm:"type:text" json:"response_text"`
	UserMessages         StringArray   `gorm:"type:text" json:"user_messages"`
	Images               SessionImages `gorm:"type:text" json:"images"`
	ConsumedByAI         bool          `gorm:"default:false" json:"consumed_by_ai"`
	ConsumedAt           *time.Time    `json:"consumed_at,omitempty"`
	TimeoutSeconds       int           `gorm:"default:600" json:"timeout_seconds"`
	NoFeedbackChecks     int           `gorm:"default:0" json:"no_feedback_checks"`
	MaxNoFeedbackChecks  int           `gorm:"default:24" json:"max_no_feedback_checks"`
	PromptWaitMinutes    int           `gorm:"default:2" json:"prompt_wait_minutes"`
	WaitCountdownMinutes int           `gorm:"default:2" json:"wait_countdown_minutes"`
	IsMCPActive          bool          `gorm:"-" json:"is_mcp_active"`
	MCPActiveAt          *time.Time    `gorm:"-" json:"mcp_active_at,omitempty"`
	MCPTimeoutSec        int           `gorm:"-" json:"mcp_timeout_seconds,omitempty"`
	LastKeepaliveAt      *time.Time    `gorm:"-" json:"last_keepalive_at,omitempty"`
	DeadlineAt           *time.Time    `json:"deadline_at,omitempty"`
	CreatedAt            time.Time     `json:"created_at"`
	UpdatedAt            time.Time     `json:"updated_at"`
}

type MCPCredential added in v1.1.0

type MCPCredential struct {
	ID          uint        `gorm:"primaryKey" json:"id"`
	Name        string      `gorm:"size:128;uniqueIndex;not null" json:"name"`
	Token       string      `gorm:"size:256;uniqueIndex;not null" json:"token"`
	HostName    string      `gorm:"size:128" json:"host_name"`
	IsActive    bool        `gorm:"default:true" json:"is_active"`
	Permissions Permissions `gorm:"type:text" json:"permissions"`
	Note        string      `gorm:"size:512" json:"note"`
	CreatedAt   time.Time   `json:"created_at"`
	UpdatedAt   time.Time   `json:"updated_at"`
}

type MutationResult

type MutationResult struct {
	TaskID   string `json:"task_id"`
	Revision int64  `json:"revision"`
	State    string `json:"state,omitempty"`
}

type PathReference

type PathReference struct {
	Path        string `json:"path"`
	Line        int    `json:"line,omitempty"`
	Description string `json:"description,omitempty"`
}

type PathReferences

type PathReferences []PathReference

func (*PathReferences) Scan

func (p *PathReferences) Scan(value interface{}) error

func (PathReferences) Value

func (p PathReferences) Value() (driver.Value, error)

type Permissions added in v1.1.0

type Permissions struct {
	Feedback   bool `json:"feedback"`
	Sessions   bool `json:"sessions"`
	SystemInfo bool `json:"system_info"`
	Skills     bool `json:"skills"`
	Configure  bool `json:"configure"`
	Execute    bool `json:"execute"`
}

func AllPermissions added in v1.1.0

func AllPermissions() Permissions

func (Permissions) AllowsTool added in v1.1.0

func (p Permissions) AllowsTool(toolName string) bool

func (*Permissions) Scan added in v1.1.0

func (p *Permissions) Scan(value interface{}) error

func (Permissions) Value added in v1.1.0

func (p Permissions) Value() (driver.Value, error)

type PhaseItem added in v1.1.0

type PhaseItem struct {
	ID          string `json:"id"`
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
	Prompt      string `json:"prompt,omitempty"`
}

func DefaultPhaseTemplate added in v1.1.0

func DefaultPhaseTemplate() []PhaseItem

type QueuedFeedback

type QueuedFeedback struct {
	ID               uint          `gorm:"primaryKey" json:"id"`
	WorkflowID       string        `gorm:"index;size:128" json:"workflow_id"`
	HostName         string        `gorm:"size:128" json:"host_name,omitempty"`
	ProjectDirectory string        `gorm:"size:512" json:"project_directory"`
	ResponseText     string        `gorm:"type:text" json:"response_text"`
	UserMessages     StringArray   `gorm:"type:text" json:"user_messages"`
	Images           SessionImages `gorm:"type:text" json:"images"`
	Status           string        `gorm:"size:32;default:'pending'" json:"status"` // pending, consumed, revoked
	CreatedAt        time.Time     `json:"created_at"`
	UpdatedAt        time.Time     `json:"updated_at"`
}

type Report

type Report struct {
	ID                       uint           `gorm:"primaryKey" json:"-"`
	TaskID                   string         `gorm:"index;not null;size:128" json:"task_id"`
	Sequence                 int64          `gorm:"not null" json:"sequence"`
	AcknowledgedTaskRevision int64          `gorm:"default:0" json:"acknowledged_task_revision"`
	Kind                     string         `gorm:"size:32;not null" json:"kind"` // progress, stage, evidence, question, completion
	Body                     string         `gorm:"type:text;not null" json:"body"`
	References               PathReferences `gorm:"type:text" json:"references,omitempty"`
	IdempotencyKey           string         `gorm:"size:128;index" json:"idempotency_key,omitempty"`
	CreatedAt                time.Time      `json:"created_at"`
}

type ReportPage

type ReportPage struct {
	Reports      []Report `json:"reports"`
	NextSequence int64    `json:"next_sequence"`
	HasMore      bool     `json:"has_more"`
}

type ReportResult

type ReportResult struct {
	Report           Report     `json:"report"`
	FeedbackSequence int64      `json:"feedback_sequence"`
	Feedback         []Feedback `json:"feedback,omitempty"`
	Wait             WaitStatus `json:"wait"`
}

type Segment

type Segment struct {
	ID              uint      `gorm:"primaryKey" json:"-"`
	TaskID          string    `gorm:"index;not null;size:128" json:"task_id,omitempty"`
	Name            string    `gorm:"size:64;not null" json:"name"`
	Content         string    `gorm:"type:text;not null" json:"content"`
	Position        int       `gorm:"default:0" json:"position"`
	UpdatedRevision int64     `gorm:"default:1" json:"updated_revision"`
	CreatedAt       time.Time `json:"created_at,omitempty"`
	UpdatedAt       time.Time `json:"updated_at,omitempty"`
}

type SendFeedbackInput

type SendFeedbackInput struct {
	ProjectID        string          `json:"project_id"`
	TaskID           string          `json:"task_id"`
	ExpectedRevision int64           `json:"expected_revision"`
	Source           string          `json:"source,omitempty"` // "human" | "commander"
	Body             string          `json:"body"`
	References       []PathReference `json:"references,omitempty"`
	IdempotencyKey   string          `json:"idempotency_key,omitempty"`
}

type SessionImage

type SessionImage struct {
	Name     string `json:"name,omitempty"`
	Format   string `json:"format,omitempty"`
	Data     string `json:"data,omitempty"` // base64 (轻量传输时可省略)
	DataType string `json:"data_type,omitempty"`
	Hash     string `json:"hash,omitempty"`
	Width    int    `json:"width,omitempty"`
	Height   int    `json:"height,omitempty"`
	URL      string `json:"url,omitempty"`
}

type SessionImages

type SessionImages []SessionImage

func (*SessionImages) Scan

func (s *SessionImages) Scan(value interface{}) error

func (SessionImages) Value

func (s SessionImages) Value() (driver.Value, error)

type SetWaitPolicyInput

type SetWaitPolicyInput struct {
	ProjectID        string     `json:"project_id"`
	TaskID           string     `json:"task_id"`
	ExpectedRevision int64      `json:"expected_revision"`
	WaitPolicy       WaitPolicy `json:"wait_policy"`
	IdempotencyKey   string     `json:"idempotency_key,omitempty"`
}

type StringArray

type StringArray []string

func (*StringArray) Scan

func (s *StringArray) Scan(value interface{}) error

func (StringArray) Value

func (s StringArray) Value() (driver.Value, error)

type SyncInput

type SyncInput struct {
	ProjectID                    string `json:"project_id"`
	TaskID                       string `json:"task_id"`
	KnownTaskRevision            int64  `json:"known_task_revision"`
	AcknowledgedTaskRevision     int64  `json:"acknowledged_task_revision"`
	AfterFeedbackSequence        int64  `json:"after_feedback_sequence"`
	AcknowledgedFeedbackSequence int64  `json:"acknowledged_feedback_sequence"`
}

type SyncResult

type SyncResult struct {
	TaskID                       string      `json:"task_id"`
	State                        string      `json:"state"`
	Revision                     int64       `json:"revision"`
	ReportSequence               int64       `json:"report_sequence"`
	FeedbackSequence             int64       `json:"feedback_sequence"`
	AcknowledgedTaskRevision     int64       `json:"acknowledged_task_revision"`
	AcknowledgedFeedbackSequence int64       `json:"acknowledged_feedback_sequence"`
	Segments                     []Segment   `json:"segments,omitempty"`
	Feedback                     []Feedback  `json:"feedback,omitempty"`
	Wait                         *WaitStatus `json:"wait,omitempty"`
}

type SystemSetting

type SystemSetting struct {
	Key       string    `gorm:"primaryKey;size:64" json:"key"`
	Value     string    `gorm:"type:text;not null" json:"value"`
	UpdatedAt time.Time `json:"updated_at"`
}

type Task

type Task struct {
	ID                           string     `gorm:"primaryKey;size:128" json:"task_id"`
	ProjectID                    string     `gorm:"index;size:128;not null" json:"project_id"`
	Title                        string     `gorm:"size:256;default:''" json:"title"`
	Mode                         string     `gorm:"size:64;default:'managed_autopilot'" json:"mode"` // managed_autopilot, lite
	State                        string     `gorm:"size:32;default:'active'" json:"state"`           // active, closed, archived, paused
	CurrentStageID               string     `gorm:"size:64;default:''" json:"current_stage_id"`
	Stages                       TaskStages `gorm:"type:text" json:"stages,omitempty"`
	CommanderSessionID           string     `gorm:"size:128;default:''" json:"commander_session_id,omitempty"`
	ExecutorSessionID            string     `gorm:"size:128;default:''" json:"executor_session_id,omitempty"`
	CommanderHeartbeatAt         *time.Time `json:"commander_heartbeat_at,omitempty"`
	ExecutorHeartbeatAt          *time.Time `json:"executor_heartbeat_at,omitempty"`
	Revision                     int64      `gorm:"default:1" json:"revision"`
	ReportSequence               int64      `gorm:"default:0" json:"report_sequence"`
	FeedbackSequence             int64      `gorm:"default:0" json:"feedback_sequence"`
	AcknowledgedTaskRevision     int64      `gorm:"default:0" json:"acknowledged_task_revision"`
	AcknowledgedFeedbackSequence int64      `gorm:"default:0" json:"acknowledged_feedback_sequence"`
	AcknowledgedReportSequence   int64      `gorm:"default:0" json:"acknowledged_report_sequence"`
	WaitPolicy                   WaitPolicy `gorm:"type:text" json:"wait_policy"`
	Segments                     []Segment  `gorm:"foreignKey:TaskID;constraint:OnDelete:CASCADE" json:"segments,omitempty"`
	CreatedAt                    time.Time  `json:"created_at"`
	UpdatedAt                    time.Time  `json:"updated_at"`
}

type TaskPage

type TaskPage struct {
	Tasks      []TaskSummary `json:"tasks"`
	NextCursor string        `json:"next_cursor,omitempty"`
}

type TaskStage added in v1.1.0

type TaskStage struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Status    string    `json:"status"` // pending, in_progress, completed, blocked
	Summary   string    `json:"summary,omitempty"`
	Evidence  string    `json:"evidence,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

type TaskStages added in v1.1.0

type TaskStages []TaskStage

func (*TaskStages) Scan added in v1.1.0

func (s *TaskStages) Scan(value interface{}) error

func (TaskStages) Value added in v1.1.0

func (s TaskStages) Value() (driver.Value, error)

type TaskSummary

type TaskSummary struct {
	ID                         string     `json:"task_id"`
	ProjectID                  string     `json:"project_id"`
	Title                      string     `json:"title"`
	Mode                       string     `json:"mode"`
	State                      string     `json:"state"`
	CurrentStageID             string     `json:"current_stage_id,omitempty"`
	Stages                     TaskStages `json:"stages,omitempty"`
	CommanderSessionID         string     `json:"commander_session_id,omitempty"`
	ExecutorSessionID          string     `json:"executor_session_id,omitempty"`
	Revision                   int64      `json:"revision"`
	ReportSequence             int64      `json:"report_sequence"`
	FeedbackSequence           int64      `json:"feedback_sequence"`
	AcknowledgedReportSequence int64      `json:"acknowledged_report_sequence"`
	UnreadReportCount          int64      `json:"unread_report_count"`
	UpdatedAt                  time.Time  `json:"updated_at"`
}

type UpdateStagesInput added in v1.1.0

type UpdateStagesInput struct {
	ProjectID        string     `json:"project_id"`
	TaskID           string     `json:"task_id"`
	ExpectedRevision int64      `json:"expected_revision,omitempty"`
	CurrentStageID   string     `json:"current_stage_id,omitempty"`
	Stages           TaskStages `json:"stages"`
	IdempotencyKey   string     `json:"idempotency_key,omitempty"`
}

type UpdateTaskInput

type UpdateTaskInput struct {
	ProjectID        string `json:"project_id"`
	TaskID           string `json:"task_id"`
	ExpectedRevision int64  `json:"expected_revision"`
	Mode             string `json:"mode"` // replace, patch
	Segment          string `json:"segment"`
	OldText          string `json:"old_text,omitempty"`
	NewText          string `json:"new_text"`
	IdempotencyKey   string `json:"idempotency_key,omitempty"`
}

type UserNorm added in v1.1.0

type UserNorm struct {
	Name      string    `gorm:"primaryKey;size:128" json:"name"`
	Summary   string    `gorm:"size:500;not null" json:"summary"`
	Content   string    `gorm:"type:text;not null" json:"content"`
	IsActive  bool      `gorm:"default:true" json:"is_active"`
	SortOrder int       `gorm:"default:0" json:"sort_order"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type WaitPolicy

type WaitPolicy struct {
	AfterMinutes         int    `json:"after_minutes"`
	MaxNoFeedbackChecks  int    `json:"max_no_feedback_checks"`
	WaitInstruction      string `json:"wait_instruction"`
	ExhaustedInstruction string `json:"exhausted_instruction"`
}

func (*WaitPolicy) Scan

func (w *WaitPolicy) Scan(value interface{}) error

func (WaitPolicy) Value

func (w WaitPolicy) Value() (driver.Value, error)

type WaitStatus

type WaitStatus struct {
	State                string `json:"state"` // waiting, exhausted
	SourceReportSequence int64  `json:"source_report_sequence,omitempty"`
	NoFeedbackChecks     int    `json:"no_feedback_checks,omitempty"`
	MaxChecks            int    `json:"max_checks,omitempty"`
	AfterMinutes         int    `json:"after_minutes,omitempty"`
	Instruction          string `json:"instruction"`
}

type WorkflowCheckpoint added in v1.1.0

type WorkflowCheckpoint struct {
	ID          uint      `gorm:"primaryKey;autoIncrement" json:"id"`
	WorkflowID  string    `gorm:"index;size:128;not null" json:"workflow_id"`
	Revision    int       `gorm:"not null" json:"revision"`
	Status      string    `gorm:"size:32;not null;default:'submitted'" json:"status"`
	ContentJSON string    `gorm:"type:text;not null" json:"content_json"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

type WorkflowDraft

type WorkflowDraft struct {
	WorkflowID  string    `gorm:"primaryKey;size:128" json:"workflow_id"`
	ActiveIndex int       `gorm:"default:0" json:"active_index"`
	DraftsJSON  string    `gorm:"type:text" json:"drafts_json"`
	UpdatedAt   time.Time `json:"updated_at"`
}

type WorkflowNote added in v1.1.0

type WorkflowNote struct {
	ID         uint      `gorm:"primaryKey;autoIncrement" json:"id"`
	WorkflowID string    `gorm:"index;size:128" json:"workflow_id"`
	SessionID  string    `gorm:"index;size:128" json:"session_id,omitempty"`
	NoteKey    string    `gorm:"size:128" json:"note_key,omitempty"`
	Content    string    `gorm:"type:text;not null" json:"content"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
}

type WorkflowPhaseState added in v1.1.0

type WorkflowPhaseState struct {
	WorkflowID            string    `gorm:"primaryKey;size:128" json:"workflow_id"`
	CurrentPhaseID        string    `gorm:"size:64;not null;default:'assess'" json:"current_phase_id"`
	HumanPreferredPhaseID string    `gorm:"size:64;not null;default:'assess'" json:"human_preferred_phase_id"`
	PhasesJSON            string    `gorm:"type:text" json:"phases_json"`
	UpdatedAt             time.Time `json:"updated_at"`
}

Jump to

Keyboard shortcuts

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