Documentation
¶
Index ¶
- Constants
- Variables
- func ArchiveBaselineExpiresAt(b *model.ArchiveBaseline) time.Time
- func BackfillPhasePrompts(phases []model.PhaseItem)
- func ClaimStateLabel(state string) string
- func ClassifyLauncherExec(command string) (execLine string, err error)
- func CredentialArchiveError(c *model.MCPCredential) error
- func CredentialFilesError(c *model.MCPCredential) error
- func CredentialTerminalTokenError(c *model.MCPCredential) error
- func DraftReferencedKeys(draftsJSON string) map[string]struct{}
- func GenerateCapabilityToken() (string, error)
- func GenerateHiddenCredentialToken() (string, error)
- func GenerateToken() (string, error)
- func GroupErrorCode(err error) (code string, ok bool)
- func HashOAuthToken(plain string) string
- func HostDefaultState(v string) string
- func InboxPreview(q model.QueuedFeedback) string
- func InboxSessionID(queuedID uint) string
- func IsBoardPinned(code string) bool
- func IsCapabilityTokenShape(s string) bool
- func IsHeadlessPrefixCmd(word string) bool
- func IsSearchUnavailable(err error) bool
- func IsWebPlaceholderSessionID(sessionID string) bool
- func IsWindowsAbsPath(p string) bool
- func MaskToken(token string) string
- func NormalizeAllowedCIDRs(in []string) (model.StringList, error)
- func NormalizeAllowedPaths(in []string) ([]string, error)
- func NormalizeArchiveProjects(in []uint) (model.UintList, error)
- func NormalizeConfirmOptions(in []model.ConfirmOption) ([]model.ConfirmOption, error)
- func NormalizeModulePath(p string) (string, error)
- func NormalizePromptText(s string, max int) (string, error)
- func NormalizeReplyHash(raw string) string
- func NormalizeSemanticKinds(kinds []string) ([]string, error)
- func NormalizeTerminalHosts(in []string) (model.StringList, error)
- func NormalizeWakeTemplate(kind sessionprompt.Kind, text string) (string, error)
- func NormalizeWebFirstMessage(raw string) (string, error)
- func NormalizeWebHostName(raw string) (string, error)
- func NormalizeWebPhase(raw string) (string, error)
- func NormalizeWebProjectDirectory(raw string) (string, error)
- func NormalizeWebWorkflowTitle(raw string) (string, error)
- func NormalizeWorkLabels(in []string) ([]string, error)
- func NormalizeWorkRefs(in []string) ([]string, error)
- func PageDiagKeepFor(kind string) int
- func ParseArchiveProjects(raw any) (model.UintList, error)
- func ParseBoardKey(key string) (projectID uint, workflowID string, ok bool)
- func ParseInboxSessionID(id string) (queuedID uint, ok bool)
- func ParseSemanticChatRef(ref string) (conversationID string, seg int64, ok bool)
- func ProjectBoardKey(projectID uint) string
- func SanitizeCredentialUpdates(in map[string]any) (map[string]any, error)
- func SemanticKeyOf(kind, ref string) string
- func ShelveExplained(it model.WorkItem) bool
- func SlugifyProjectName(name string) string
- func TrashRetentionDays() int
- func ValidHeadlessBin(bin string) bool
- func ValidWindowsBin(bin string) bool
- func ValidateCredentialTerminal(c *model.MCPCredential) error
- func ValidateHostDefaultForNewModels(v string) error
- func ValidateHostExecMode(v string) error
- func ValidatePathReference(ref model.PathReference) error
- func ValidatePathReferences(refs []model.PathReference) error
- func ValidateSegments(segments []model.Segment) error
- func ValidateSidebarOrderKeys(keys []string) error
- func ValidateTerminalLimits(l model.TerminalLimits) (model.TerminalLimits, error)
- func ValidateTerminalModeCap(v string) error
- func WebWorkflowStartPrompt(title, workflowID, projectDir string) string
- func WindowsPathProblem(p string) string
- func WorkItemListLimit(requested int) int
- func WorkStateLabel(state string) string
- func WorkflowBoardKey(workflowID string) string
- type AgentEvent
- type AgentIdentityView
- type AgentIngestInput
- type AgentIngestResult
- type AgentLink
- type AgentLiveState
- type AgentLiveView
- type AgentScreenChange
- type AgentScreenInput
- type AgentScreenView
- type AgentSearchAccess
- type AgentSearchQuota
- type AgentSearchQuotaLimits
- type AgentSearchQuotaPatch
- type AgentSearchQuotaRange
- type AgentSessionFilter
- type AgentSessionView
- type AgentTouchInput
- type AppError
- type ApplyParamsResult
- type ArchiveSource
- func (a *ArchiveSource) Confirms(ctx context.Context) ([]model.ConfirmItem, error)
- func (a *ArchiveSource) GroupLastSeq(ctx context.Context, groupID string) (int64, error)
- func (a *ArchiveSource) GroupMessageCount(ctx context.Context, groupID string, uptoSeq int64) (int, error)
- func (a *ArchiveSource) GroupMessages(ctx context.Context, groupID string, afterSeq, uptoSeq int64, limit int) ([]model.ChatMessage, error)
- func (a *ArchiveSource) Groups(ctx context.Context) ([]archive.GroupInfo, error)
- func (a *ArchiveSource) InboxIDs(ctx context.Context) ([]uint, error)
- func (a *ArchiveSource) InboxRows(ctx context.Context, ids []uint) ([]model.QueuedFeedback, error)
- func (a *ArchiveSource) Project() archive.ProjectInfo
- func (a *ArchiveSource) Sessions(ctx context.Context, workflowID string, afterRowID, uptoRowID int64, limit int) ([]archive.SessionRow, error)
- func (a *ArchiveSource) SessionsMaxRowID(ctx context.Context) (int64, error)
- func (a *ArchiveSource) Tasks(ctx context.Context) (*archive.TaskSet, error)
- func (a *ArchiveSource) WorkflowIDs() []string
- func (a *ArchiveSource) Workflows(ctx context.Context) ([]archive.WorkflowInfo, error)
- type ArtifactCommentInput
- type ArtifactDataSetInput
- type AsyncParam
- type AuditFilter
- type AuditInput
- type AuthCredentials
- type AuthProfileInput
- type AutoResumeRecord
- type BoardAssignment
- type BoardCounterPlan
- type BoardDigest
- type BoardDigestGroup
- type BoardInfo
- type BoardLineEvent
- type BoardMergeBoard
- type BoardMergeCollision
- type BoardMergeItemRef
- type BoardMergeModuleDup
- type BoardMergePlan
- type BoardMergeRenumber
- type BoardMergeWorkflow
- type BoardOffered
- type BoardReconcilePlan
- type BoardStaleOffer
- type BoardWhy
- type BranchAnswerInput
- type BranchAssign
- type BranchBrief
- type BranchEscalateInput
- type BranchFeed
- type BranchFeedItem
- type BranchHistory
- type BranchLaunch
- type BranchLinks
- type BranchParamEventView
- type BranchParamRevert
- type BranchReadiness
- type BranchRound
- type BranchSayInput
- type BranchSayResult
- type BranchTasks
- type CandidateSet
- type CloseBranchResult
- type ConfirmAnswerInput
- type ConfirmBatchItem
- type ConfirmBatchResult
- type ConfirmCreateInput
- type ConfirmFilter
- type CreateGroupInput
- type CreateSessionInput
- type CreateWebBranchSpec
- type CreateWebWorkflowInput
- type CreateWebWorkflowResult
- type CredentialHost
- type DocACLFact
- type DocActor
- type DocBrief
- type DocLinkRef
- type DocLinks
- type DocWorkflowStat
- type DraftImageInfo
- type ErrorKind
- type GateInfo
- type GlobalAppSettings
- type GrantInput
- type GroupError
- type GroupTrashGrant
- type GroupTrashInput
- type GroupTrashPreview
- type GroupTrashRestoreResult
- type GroupTrashResult
- type GroupVisibility
- type GuardPresetState
- func (p *GuardPresetState) AutoResumeFrom(fromRun string) (AutoResumeRecord, bool)
- func (p *GuardPresetState) AutoResumeStartedSince(since time.Time) int
- func (p *GuardPresetState) AutoResumeStarting(runID string) (AutoResumeRecord, bool)
- func (p *GuardPresetState) AutoResumeTrailingQuick() int
- func (p *GuardPresetState) ClaimAutoResumeRun(runID string, attempt int) bool
- func (p *GuardPresetState) SettleAutoResume(runID string) bool
- type GuardStateDoc
- type GuiWakeConfig
- type GuiWakeDefault
- type GuiWakeTarget
- type HeadlessRun
- func (r HeadlessRun) EffectiveAfterNew() string
- func (r HeadlessRun) EffectiveAutoResumeOK() time.Duration
- func (r HeadlessRun) EffectiveBin() string
- func (r HeadlessRun) EffectiveMaxRunMinutes() int
- func (r HeadlessRun) EffectiveMaxRunSeconds() int
- func (r HeadlessRun) EffectivePosture() string
- func (r HeadlessRun) EffectiveSource() string
- type HeadlessWake
- type HostGrantResult
- type HostModelUpdate
- type ImportDocFile
- type ImportDocResult
- type InboxConfig
- type InboxGetOutcome
- type InboxPeek
- type InboxReadOptions
- type InboxReadResult
- type InboxSummary
- type JWTSecretResolution
- type JWTSecretSource
- type LauncherGuard
- type LinkBranchInput
- type LinkBranchResult
- type MigrationItem
- type MigrationMove
- type MigrationReport
- type ModeInfo
- type ModePatch
- type ModuleInput
- type ModulePageView
- type ModuleTask
- type PageDiagStats
- type PageSearchInfo
- type ParamEffect
- type PendingBranchAsk
- type PostGroupInput
- type PostGroupResult
- type ProjectBoardList
- type ProjectBoardView
- type ProjectDocFilter
- type ProjectDocInput
- type ProjectDocPatch
- type ProjectDocSaveResult
- type ProjectInput
- type ProjectPatch
- type ProjectSearchFilter
- type ProjectSearchHit
- type ProjectStats
- type ProjectSuggestion
- type QueueFeedbackInput
- type RebindRequest
- type RebindResult
- type ReplyRef
- type ReplyWindow
- type ResidentParam
- type ResolvedGuiTarget
- type RetractionEvent
- type RevokedFeedbackResult
- type RunFilter
- type SSHCheck
- type SSHConnUpdate
- type SearchCandidateQuery
- type SearchHintsConfig
- type SearchHintsFloatRange
- type SearchHintsIntRange
- type SearchHintsLimits
- type SearchHintsPatch
- type SearchHit
- type SearchIndexStatus
- type SearchKindStatus
- type SearchQuery
- type SearchResult
- type SearchUnavailableError
- type SecuritySettings
- type SemanticKey
- type SemanticMessage
- type SemanticRun
- type SemanticScope
- type SemanticSet
- type SemanticSourceInfo
- type SemanticStats
- type SemanticText
- type SessionKindFilter
- type SessionParamValues
- type SessionParamsPatch
- type SessionParamsView
- type SidebarOrder
- type Store
- func (s *Store) AckKeyNotice(ctx context.Context, sessionID string, at time.Time) (*model.FeedbackSession, bool, error)
- func (s *Store) AckReports(ctx context.Context, projectID, taskID string, throughSequence int64) (*model.AckSummary, error)
- func (s *Store) ActivateCredential(ctx context.Context, id uint) error
- func (s *Store) ActiveBranchLinks(ctx context.Context, workflowID string) (BranchLinks, error)
- func (s *Store) ActiveGrantsFor(ctx context.Context, projectID, identityID uint, groupRefs []string) ([]acl.Grant, error)
- func (s *Store) ActiveGrantsForCaller(ctx context.Context, projectID, identityID uint, workflowID string) ([]acl.Grant, error)
- func (s *Store) AddArtifactComment(ctx context.Context, in ArtifactCommentInput) (*model.ArtifactComment, error)
- func (s *Store) AddAuditEvent(ctx context.Context, in AuditInput) (bool, error)
- func (s *Store) AddConversationEvent(ctx context.Context, ev model.ConversationEvent) (*model.ConversationEvent, error)
- func (s *Store) AddGroupMembers(ctx context.Context, groupID, actor string, workflowIDs []string) error
- func (s *Store) AddPageDiagReport(ctx context.Context, r *model.PageDiagReport, keep int) error
- func (s *Store) AddProjectDir(ctx context.Context, projectID uint, host, dir, branchHint string) (*model.ProjectDir, error)
- func (s *Store) AddReport(ctx context.Context, input model.AddReportInput) (*model.ReportResult, error)
- func (s *Store) AdvanceConversationRead(ctx context.Context, conversationID, readerKind, readerRef string, ...) (model.ConversationRead, error)
- func (s *Store) AdvanceGroupRead(ctx context.Context, groupID, readerKind, readerRef string, seq int64) error
- func (s *Store) AgentCursorVersion(ctx context.Context, workflowID string) string
- func (s *Store) AgentLastActivity(workflowID string) (time.Time, bool)
- func (s *Store) AgentLinkOf(ctx context.Context, workflowID string) AgentLink
- func (s *Store) AgentSearchAccess(ctx context.Context) (AgentSearchAccess, error)
- func (s *Store) AgentSearchQuota(ctx context.Context) (AgentSearchQuota, error)
- func (s *Store) AnswerConfirmBatch(ctx context.Context, workflowID string, items []ConfirmBatchItem, ...) (*ConfirmBatchResult, error)
- func (s *Store) AnswerConfirmItem(ctx context.Context, workflowID, ref string, in ConfirmAnswerInput) (*model.ConfirmItem, error)
- func (s *Store) AppendTerminalAudit(ctx context.Context, e *model.TerminalAuditLog) error
- func (s *Store) ApplyMigration(ctx context.Context, projectID uint, expectHash string) (*MigrationReport, error)
- func (s *Store) ApplySessionParams(ctx context.Context, caller, target string, patch SessionParamsPatch, ...) (*ApplyParamsResult, error)
- func (s *Store) ApplyWorkPlan(ctx context.Context, workflowID string, plan []WorkPlanNode, reorder bool) (*WorkPlanResult, error)
- func (s *Store) ApplyWorkPlanAs(ctx context.Context, workflowID string, plan []WorkPlanNode, ...) (*WorkPlanResult, error)
- func (s *Store) ArchiveFeedbackSession(ctx context.Context, idOrWorkflow string) (*model.FeedbackSession, error)
- func (s *Store) ArchiveProject(ctx context.Context, id uint) error
- func (s *Store) ArchiveProjectDoc(ctx context.Context, docID uint, actor DocActor) (*model.ProjectDoc, error)
- func (s *Store) ArtifactDataDelete(ctx context.Context, docID uint, key string) (bool, error)
- func (s *Store) ArtifactDataGet(ctx context.Context, docID uint, key string) (*model.ArtifactData, error)
- func (s *Store) ArtifactDataList(ctx context.Context, docID uint) ([]model.ArtifactData, error)
- func (s *Store) ArtifactDataSet(ctx context.Context, in ArtifactDataSetInput) (*model.ArtifactData, error)
- func (s *Store) AsyncWindowTimes(ctx context.Context) (add, slice time.Duration)
- func (s *Store) BackfillDecisionConfirmItems(ctx context.Context)
- func (s *Store) BackfillHiddenOAuthCredentialTokens(ctx context.Context) error
- func (s *Store) BeatReplyWindow(ctx context.Context, workflowID string, now time.Time) (ReplyWindow, error)
- func (s *Store) BoardDigestFor(ctx context.Context, workflowID string, now time.Time, ...) (*BoardDigest, error)
- func (s *Store) BoardGuestOf(ctx context.Context, workflowID string) (parent string, ended bool, err error)
- func (s *Store) BoardKeyOf(ctx context.Context, workflowID string) (string, error)
- func (s *Store) BoardOfferedByWorkflow(ctx context.Context) ([]BoardOffered, error)
- func (s *Store) BoardWhyOf(ctx context.Context, workflowID string) (BoardWhy, error)
- func (s *Store) BoardWorkflowIDs(ctx context.Context, boardKey string) ([]string, error)
- func (s *Store) BranchAnswer(ctx context.Context, in BranchAnswerInput) (*model.ConfirmItem, error)
- func (s *Store) BranchBriefs(ctx context.Context, rows []model.WorkflowBranch) []BranchBrief
- func (s *Store) BranchEscalate(ctx context.Context, in BranchEscalateInput) (*model.ConfirmItem, error)
- func (s *Store) BranchFeed(ctx context.Context, workflowID string, limit int) (*BranchFeed, error)
- func (s *Store) BranchOf(ctx context.Context, workflowID string) (*model.WorkflowBranch, error)
- func (s *Store) BranchSay(ctx context.Context, in BranchSayInput) (*BranchSayResult, error)
- func (s *Store) BranchScopeOf(ctx context.Context, parent string) (map[string]WorkBranchScope, error)
- func (s *Store) CancelFeedbackSession(ctx context.Context, idOrWorkflow string) (*model.FeedbackSession, error)
- func (s *Store) CheckFeedback(ctx context.Context, input model.CheckFeedbackInput) (*model.CheckFeedbackResult, error)
- func (s *Store) ClaimConversation(ctx context.Context, workflowID, conv string, until, now time.Time) ([]string, error)
- func (s *Store) ClaimStaleOffers(ctx context.Context, now time.Time, staleAfter time.Duration, maxGroups int) ([]BoardStaleOffer, error)
- func (s *Store) ClearAgentScreen(workflowID string) (wasApproval bool)
- func (s *Store) ClearReplyWindow(ctx context.Context, workflowID string) error
- func (s *Store) Close() error
- func (s *Store) CloseBranch(ctx context.Context, branchWorkflowID, by string) (*CloseBranchResult, error)
- func (s *Store) CloseTask(ctx context.Context, projectID, taskID string, expectedRevision int64, ...) (*model.MutationResult, error)
- func (s *Store) CommitArchiveBaseline(ctx context.Context, id string, now time.Time) error
- func (s *Store) CompactWorkItems(ctx context.Context, now time.Time) (int, error)
- func (s *Store) ConfirmView(ctx context.Context, item *model.ConfirmItem) (model.ConfirmItemView, error)
- func (s *Store) ConfirmViews(ctx context.Context, items []model.ConfirmItem) ([]model.ConfirmItemView, error)
- func (s *Store) ConversationOwner(conv string, now time.Time) string
- func (s *Store) ConversationReadEpoch(ctx context.Context) (int64, error)
- func (s *Store) CopyUserNoteToMain(ctx context.Context, branchWorkflowID, text string, imageCount int) (*model.QueuedFeedback, error)
- func (s *Store) CountAgentMessagesBetween(ctx context.Context, workflowID string, from, to time.Time) (int, error)
- func (s *Store) CountBoardWorkItemsByState(ctx context.Context, workflowID string) (map[string]int, error)
- func (s *Store) CountFeedbackSessionsByWorkflow(ctx context.Context, workflowIDs []string) (map[string]int, error)
- func (s *Store) CountOAuthClients(ctx context.Context) (int64, error)
- func (s *Store) CountOpenArtifactComments(ctx context.Context, docID uint) int
- func (s *Store) CountPendingConfirms(ctx context.Context, workflowID string) (int, error)
- func (s *Store) CountPendingConfirmsByWorkflow(ctx context.Context, workflowIDs []string) (map[string]int, error)
- func (s *Store) CountProjectDocs(ctx context.Context, workflowID string) (int, error)
- func (s *Store) CountRecentNotices(ctx context.Context, workflowID string, since time.Time) (int, error)
- func (s *Store) CountSSHHostsViaGateway(ctx context.Context, gateway string) (int64, error)
- func (s *Store) CountUnackedKeyNotices(ctx context.Context, workflowID string) (int, error)
- func (s *Store) CountUnackedKeyNoticesByWorkflow(ctx context.Context, workflowIDs []string) (map[string]int, error)
- func (s *Store) CountUnreadAgentMessages(ctx context.Context, workflowID string, afterMs int64, updatesSince time.Time, ...) (int, error)
- func (s *Store) CountVisibleCredentials(ctx context.Context) (int64, error)
- func (s *Store) CountWorkItemsByState(ctx context.Context, workflowID string) (map[string]int, error)
- func (s *Store) CountWorkModules(ctx context.Context, workflowID string) (int, error)
- func (s *Store) CountWorkflowSessionsBefore(ctx context.Context, workflowID, beforeID string) (rounds, notices int64, err error)
- func (s *Store) CreateAuthProfile(ctx context.Context, in AuthProfileInput) (*model.AuthProfile, error)
- func (s *Store) CreateConfirmItem(ctx context.Context, in ConfirmCreateInput) (item *model.ConfirmItem, created bool, err error)
- func (s *Store) CreateCredential(ctx context.Context, cred *model.MCPCredential) error
- func (s *Store) CreateFeedbackSession(ctx context.Context, input CreateSessionInput) (*model.FeedbackSession, error)
- func (s *Store) CreateGrant(ctx context.Context, in GrantInput) (*model.ACLGrant, error)
- func (s *Store) CreateGroup(ctx context.Context, in CreateGroupInput) (*model.Conversation, error)
- func (s *Store) CreateHiddenOAuthCredential(ctx context.Context, grantID uint, name string, cred *model.MCPCredential) error
- func (s *Store) CreateNoticeSession(ctx context.Context, input CreateSessionInput) (*model.FeedbackSession, error)
- func (s *Store) CreateOAuthClient(ctx context.Context, c *model.OAuthClient) error
- func (s *Store) CreateOAuthGrant(ctx context.Context, g *model.OAuthGrant) error
- func (s *Store) CreateProject(ctx context.Context, in ProjectInput) (*model.Project, error)
- func (s *Store) CreateProjectDoc(ctx context.Context, in ProjectDocInput, actor DocActor) (*ProjectDocSaveResult, error)
- func (s *Store) CreateSSHHost(ctx context.Context, h *model.TerminalHost) error
- func (s *Store) CreateTask(ctx context.Context, input model.CreateTaskInput) (*model.Task, error)
- func (s *Store) CreateTerminalRun(ctx context.Context, r *model.TerminalRun) error
- func (s *Store) CreateUserNorm(ctx context.Context, norm *model.UserNorm) error
- func (s *Store) CreateWebWorkflow(ctx context.Context, input CreateWebWorkflowInput) (*CreateWebWorkflowResult, error)
- func (s *Store) CreateWorkItem(ctx context.Context, in WorkItemInput, actor WorkActor) (*WorkItemResult, error)
- func (s *Store) CreateWorkModule(ctx context.Context, workflowID string, parentID uint, ...) (*model.WorkModule, error)
- func (s *Store) DB() *gorm.DB
- func (s *Store) DataDir() string
- func (s *Store) DeactivateCredential(ctx context.Context, id uint) error
- func (s *Store) DecisionConfirmsByKey(ctx context.Context, docID uint) (map[string]*model.ConfirmItem, error)
- func (s *Store) DefaultAllowHostCodes(ctx context.Context) ([]string, error)
- func (s *Store) DefaultAuthProfile(ctx context.Context) (*model.AuthProfile, error)
- func (s *Store) DeleteAllDraftImages(ctx context.Context, workflowID string) (int64, error)
- func (s *Store) DeleteArchiveBaselines(ctx context.Context, credentialID, projectID uint) (int64, error)
- func (s *Store) DeleteAuthProfile(ctx context.Context, id uint) error
- func (s *Store) DeleteCredential(ctx context.Context, id uint) error
- func (s *Store) DeleteDraftImages(ctx context.Context, workflowID string, keys []string) (int64, error)
- func (s *Store) DeleteEmbeddingCredential(ctx context.Context) error
- func (s *Store) DeleteFeedbackSession(ctx context.Context, sessionID string) (*model.FeedbackSession, error)
- func (s *Store) DeleteNote(ctx context.Context, id uint) error
- func (s *Store) DeleteOAuthAccessTokensForGrant(ctx context.Context, grantID uint) error
- func (s *Store) DeleteProjectModule(ctx context.Context, projectID uint, path string) error
- func (s *Store) DeleteTerminalArchivesOfHost(ctx context.Context, machineCode string) error
- func (s *Store) DeleteTerminalHost(ctx context.Context, machineCode string) (bool, error)
- func (s *Store) DeleteTerminalLauncher(ctx context.Context, id string) ([]TerminalLauncher, TerminalLauncher, error)
- func (s *Store) DeleteTerminalLostDismissalsOfHost(ctx context.Context, machineCode string) error
- func (s *Store) DeleteTerminalRunsOfHost(ctx context.Context, machineCode string) error
- func (s *Store) DeleteTerminalSessionsOfHost(ctx context.Context, machineCode string) error
- func (s *Store) DeleteUnusedOAuthClient(ctx context.Context, clientID string) (bool, error)
- func (s *Store) DeleteUserNorm(ctx context.Context, name string) error
- func (s *Store) DeleteWorkItem(ctx context.Context, id uint) (*model.WorkItem, error)
- func (s *Store) DeleteWorkModule(ctx context.Context, id uint) (*WorkModuleDeleteResult, error)
- func (s *Store) DeleteWorkflowDraft(ctx context.Context, workflowID string) error
- func (s *Store) DiagBrowserReportsEnabled(ctx context.Context) (bool, error)
- func (s *Store) DiscardArchiveBaseline(ctx context.Context, id string) error
- func (s *Store) DismissConfirmItem(ctx context.Context, workflowID, ref, reason string) (*model.ConfirmItem, error)
- func (s *Store) DismissTerminalLost(ctx context.Context, machineCode string, sids []string, now time.Time) (int64, error)
- func (s *Store) DocACLFacts(ctx context.Context, ids []uint) (map[uint]DocACLFact, error)
- func (s *Store) DocDecisionExportRows(ctx context.Context, doc *model.ProjectDoc) []docs.DecisionExportRow
- func (s *Store) DocDecisionViews(ctx context.Context, doc *model.ProjectDoc, body string, historic bool) []confirm.DecisionView
- func (s *Store) DocLinks(ctx context.Context, doc *model.ProjectDoc) (*DocLinks, error)
- func (s *Store) EmbeddingUsageDays(ctx context.Context, fromDay, toDay string) ([]embedding.UsageDay, error)
- func (s *Store) EmbeddingUsageTotals(ctx context.Context) (embedding.UsageTotals, error)
- func (s *Store) EnsureEnvMCPCredential(ctx context.Context, envToken string) (*model.MCPCredential, error)
- func (s *Store) EscalateOverdueBranchAsks(ctx context.Context, now time.Time, after time.Duration, note string, ...) ([]model.ConfirmItem, error)
- func (s *Store) ExtendReplyWindow(ctx context.Context, workflowID string, add time.Duration, now time.Time) (ReplyWindow, error)
- func (s *Store) FindAnchoredSessionByCommit(ctx context.Context, workflowID, commit string) (*model.FeedbackSession, error)
- func (s *Store) FindCredentialByToken(ctx context.Context, token string) (*model.MCPCredential, error)
- func (s *Store) FindOAuthAccessToken(ctx context.Context, plainToken string) (*model.OAuthAccessToken, *model.OAuthGrant, *model.MCPCredential, error)
- func (s *Store) FindReplyRefs(ctx context.Context, workflowID, hash string, limit int) ([]ReplyRef, error)
- func (s *Store) FindTerminalRunByIdempotency(ctx context.Context, credentialID uint, key string) (*model.TerminalRun, error)
- func (s *Store) GetArchiveBaseline(ctx context.Context, id string, projectID, credentialID uint, now time.Time) (*model.ArchiveBaseline, error)
- func (s *Store) GetAuthCredentials(ctx context.Context) (*AuthCredentials, error)
- func (s *Store) GetAuthCredentialsWithDB(ctx context.Context, db *gorm.DB) (*AuthCredentials, error)
- func (s *Store) GetAuthProfile(ctx context.Context, id uint) (*model.AuthProfile, error)
- func (s *Store) GetBranchParamEvent(ctx context.Context, branch string, id uint) (*model.BranchParamEvent, error)
- func (s *Store) GetBranchPrefs(ctx context.Context) (model.BranchPrefs, error)
- func (s *Store) GetCheckpointByRevision(ctx context.Context, workflowID string, revision int) (*model.WorkflowCheckpoint, error)
- func (s *Store) GetConfirmItemByRef(ctx context.Context, workflowID, ref string) (*model.ConfirmItem, error)
- func (s *Store) GetConversationRead(ctx context.Context, conversationID, readerKind, readerRef string) (model.ConversationRead, error)
- func (s *Store) GetCredential(ctx context.Context, id uint) (*model.MCPCredential, error)
- func (s *Store) GetCredentialIfManageable(ctx context.Context, id uint) (*model.MCPCredential, *model.OAuthGrant, error)
- func (s *Store) GetCredentialIfVisible(ctx context.Context, id uint) (*model.MCPCredential, error)
- func (s *Store) GetCurrentFeedbackSession(ctx context.Context, projectDir string) (*model.FeedbackSession, error)
- func (s *Store) GetDraftImage(ctx context.Context, workflowID, key string) (*model.DraftImage, error)
- func (s *Store) GetEmbeddingConfig(ctx context.Context) (embedding.Config, error)
- func (s *Store) GetEmbeddingCredential(ctx context.Context) (embedding.Credential, bool, error)
- func (s *Store) GetFeedbackRoundsByWorkflow(ctx context.Context, workflowID string, limit int) ([]model.FeedbackSession, error)
- func (s *Store) GetFeedbackSession(ctx context.Context, sessionID string) (*model.FeedbackSession, error)
- func (s *Store) GetGlobalAppSettings(ctx context.Context) (*GlobalAppSettings, error)
- func (s *Store) GetGlobalAppSettingsWithDB(ctx context.Context, db *gorm.DB) (*GlobalAppSettings, error)
- func (s *Store) GetGrant(ctx context.Context, projectID, grantID uint) (*model.ACLGrant, error)
- func (s *Store) GetGroup(ctx context.Context, groupID string) (*model.Conversation, error)
- func (s *Store) GetGroupMember(ctx context.Context, groupID, memberKind, memberRef string) (*model.ConversationMember, error)
- func (s *Store) GetGuiWakeConfig(ctx context.Context) (GuiWakeConfig, error)
- func (s *Store) GetInboxConfig(ctx context.Context) InboxConfig
- func (s *Store) GetLatestAnchoredSession(ctx context.Context, workflowID, excludeSessionID string) (*model.FeedbackSession, error)
- func (s *Store) GetLatestCheckpoint(ctx context.Context, workflowID string) (*model.WorkflowCheckpoint, error)
- func (s *Store) GetLatestWorkflowFeedbackSession(ctx context.Context, workflowID string) (*model.FeedbackSession, error)
- func (s *Store) GetNote(ctx context.Context, id uint) (*model.WorkflowNote, error)
- func (s *Store) GetNoteByKey(ctx context.Context, workflowID, noteKey string) (*model.WorkflowNote, error)
- func (s *Store) GetNotifyPrefs(ctx context.Context) (notify.Prefs, error)
- func (s *Store) GetNtfyConfig(ctx context.Context) (ntfy.Config, error)
- func (s *Store) GetOAuthClient(ctx context.Context, clientID string) (*model.OAuthClient, error)
- func (s *Store) GetOAuthGrant(ctx context.Context, id uint) (*model.OAuthGrant, error)
- func (s *Store) GetOAuthGrantByRefreshHash(ctx context.Context, hash string) (*model.OAuthGrant, error)
- func (s *Store) GetOAuthPolicy(ctx context.Context) (model.OAuthPolicy, error)
- func (s *Store) GetProject(ctx context.Context, id uint) (*model.Project, error)
- func (s *Store) GetProjectDocByID(ctx context.Context, id uint) (*model.ProjectDoc, error)
- func (s *Store) GetProjectDocByRef(ctx context.Context, workflowID, ref string) (*model.ProjectDoc, error)
- func (s *Store) GetProjectDocInProject(ctx context.Context, projectID uint, ref string) (*model.ProjectDoc, error)
- func (s *Store) GetProjectDocRevision(ctx context.Context, docID uint, rev int) (*model.ProjectDocRevision, error)
- func (s *Store) GetProjectModule(ctx context.Context, projectID uint, path string) (*model.ProjectModule, error)
- func (s *Store) GetQueuedFeedback(ctx context.Context, id uint) (*model.QueuedFeedback, error)
- func (s *Store) GetSemanticRun(ctx context.Context) (SemanticRun, error)
- func (s *Store) GetSessionParams(ctx context.Context, caller, target string, now time.Time) (*SessionParamsView, error)
- func (s *Store) GetSessionsByWorkflow(ctx context.Context, workflowID string, limit int) ([]model.FeedbackSession, error)
- func (s *Store) GetSettings(ctx context.Context) (map[string]any, error)
- func (s *Store) GetSettingsWithDB(ctx context.Context, db *gorm.DB) (map[string]any, error)
- func (s *Store) GetSidebarOrder(ctx context.Context) (SidebarOrder, error)
- func (s *Store) GetSystemFlag(ctx context.Context, key string) (bool, error)
- func (s *Store) GetTask(ctx context.Context, projectID, taskID string) (*model.Task, error)
- func (s *Store) GetTerminalGuardState(ctx context.Context) (GuardStateDoc, error)
- func (s *Store) GetTerminalHost(ctx context.Context, machineCode string) (*model.TerminalHost, error)
- func (s *Store) GetTerminalPrefs(ctx context.Context) (TerminalPrefs, error)
- func (s *Store) GetTerminalRun(ctx context.Context, runID string) (*model.TerminalRun, error)
- func (s *Store) GetTerminalSession(ctx context.Context, machineCode, sid string) (*model.TerminalSession, error)
- func (s *Store) GetUserNorm(ctx context.Context, name string) (*model.UserNorm, error)
- func (s *Store) GetWorkItem(ctx context.Context, id uint) (*model.WorkItem, error)
- func (s *Store) GetWorkItemBySeq(ctx context.Context, workflowID string, seq int) (*model.WorkItem, error)
- func (s *Store) GetWorkModule(ctx context.Context, id uint) (*model.WorkModule, error)
- func (s *Store) GetWorkflowDraft(ctx context.Context, workflowID string) (*model.WorkflowDraft, error)
- func (s *Store) GetWorkflowPhase(ctx context.Context, workflowID string) (*model.WorkflowPhaseState, error)
- func (s *Store) GetWorkflowPhaseWithDefaults(ctx context.Context, workflowID string) (currentPhaseID string, phases []model.PhaseItem, err error)
- func (s *Store) GetWorkflowPrompt(ctx context.Context, workflowID string) (model.WorkflowPrompt, error)
- func (s *Store) GlobalWakeTemplates(ctx context.Context) WakeTemplates
- func (s *Store) GrantHostToTerminalCredentials(ctx context.Context, machineCode string) (HostGrantResult, error)
- func (s *Store) GroupLastMessage(ctx context.Context, groupID string) (*model.ChatMessage, error)
- func (s *Store) GroupLastSeq(ctx context.Context, groupID string) (int64, error)
- func (s *Store) GroupMemberCounts(ctx context.Context, workflowIDs []string) (map[string]int, error)
- func (s *Store) GroupMentionStates(ctx context.Context, groupID string, messageIDs []uint) (map[uint]map[string]string, error)
- func (s *Store) GroupMessagesAfterSeq(ctx context.Context, groupID string, afterSeq int64, limit int, ...) ([]model.ChatMessage, bool, error)
- func (s *Store) GroupReadSeqs(ctx context.Context, groupID string) (map[string]int64, error)
- func (s *Store) GroupRefsOfIdentity(ctx context.Context, workflowID string, identityID uint) []string
- func (s *Store) GroupUnread(ctx context.Context, groupID, readerKind, readerRef string, since time.Time) (unread, mentioned int, err error)
- func (s *Store) GroupsOfWorkflow(ctx context.Context, workflowID string) ([]model.Conversation, error)
- func (s *Store) HasAnyCredential(ctx context.Context) (bool, error)
- func (s *Store) HookLastSeen(workflowID string) (time.Time, bool)
- func (s *Store) IdentityLabelOf(ctx context.Context, identityID uint) string
- func (s *Store) IdentityProjectID(ctx context.Context, identityID uint) uint
- func (s *Store) ImportProjectDocs(ctx context.Context, workflowID string, files []ImportDocFile, mode string, ...) (*ImportDocResult, error)
- func (s *Store) InboxAck(ctx context.Context, workflowID string, ids []uint, now time.Time) ([]uint, error)
- func (s *Store) InboxGetMessage(ctx context.Context, workflowID string, id uint) (*model.QueuedFeedback, InboxGetOutcome, error)
- func (s *Store) InboxPeek(ctx context.Context, workflowID string, reminder bool, now time.Time) (InboxPeek, error)
- func (s *Store) InboxRead(ctx context.Context, workflowID string, opts InboxReadOptions, now time.Time) (InboxReadResult, error)
- func (s *Store) InboxSummary(ctx context.Context, workflowID string, now time.Time) (InboxSummary, error)
- func (s *Store) IngestAgentEvent(ctx context.Context, in AgentIngestInput) (AgentIngestResult, error)
- func (s *Store) InsertOAuthAccessToken(ctx context.Context, hash string, grantID uint, expires time.Time) error
- func (s *Store) InvalidateOAuthGrantFamily(ctx context.Context, id uint) error
- func (s *Store) IsAsyncEffective(ctx context.Context, workflowID string, now time.Time) bool
- func (s *Store) KeepaliveFeedbackSession(ctx context.Context, sessionID string, extendSec int) (*model.FeedbackSession, error)
- func (s *Store) LatestUserHints(ctx context.Context, workflowID string) (*UserHints, error)
- func (s *Store) LatestWorkflowOfIdentity(ctx context.Context, identityID uint) string
- func (s *Store) LinkBranch(ctx context.Context, in LinkBranchInput) (*LinkBranchResult, error)
- func (s *Store) LinkWorkItemSession(ctx context.Context, id uint, sessionID string) error
- func (s *Store) ListActiveTerminalRuns(ctx context.Context) ([]model.TerminalRun, error)
- func (s *Store) ListActiveUserNorms(ctx context.Context) ([]model.UserNorm, error)
- func (s *Store) ListAgentIdentities(ctx context.Context) ([]AgentIdentityView, error)
- func (s *Store) ListAgentSessions(ctx context.Context, f AgentSessionFilter, now time.Time) ([]AgentSessionView, error)
- func (s *Store) ListAllBranches(ctx context.Context) ([]model.WorkflowBranch, error)
- func (s *Store) ListArchiveBaselines(ctx context.Context, credentialID uint, projectIDs []uint, now time.Time) ([]model.ArchiveBaseline, error)
- func (s *Store) ListArtifactComments(ctx context.Context, docID uint, includeResolved bool, limit int) ([]model.ArtifactComment, error)
- func (s *Store) ListAuditEvents(ctx context.Context, f AuditFilter) ([]model.AuditEvent, error)
- func (s *Store) ListAuthProfiles(ctx context.Context) ([]model.AuthProfile, error)
- func (s *Store) ListBranchParamEventViews(ctx context.Context, branch string, limit int, now time.Time) ([]BranchParamEventView, error)
- func (s *Store) ListBranchParamEvents(ctx context.Context, branch string, limit int) ([]model.BranchParamEvent, error)
- func (s *Store) ListCheckpoints(ctx context.Context, workflowID string, limit int) ([]model.WorkflowCheckpoint, error)
- func (s *Store) ListConfirmItems(ctx context.Context, f ConfirmFilter) ([]model.ConfirmItem, error)
- func (s *Store) ListCredentialHosts(ctx context.Context) ([]CredentialHost, error)
- func (s *Store) ListCredentials(ctx context.Context) ([]model.MCPCredential, error)
- func (s *Store) ListDocWorkflowStats(ctx context.Context) ([]DocWorkflowStat, error)
- func (s *Store) ListDraftImages(ctx context.Context, workflowID string) ([]DraftImageInfo, error)
- func (s *Store) ListFeedbackRoundSessions(ctx context.Context, projectDir, status string, limit int) ([]model.FeedbackSession, error)
- func (s *Store) ListFeedbackSessions(ctx context.Context, projectDir, status string, limit int) ([]model.FeedbackSession, error)
- func (s *Store) ListFeedbackSessionsBrief(ctx context.Context, projectDir, status string, limit int) ([]model.FeedbackSession, error)
- func (s *Store) ListFeedbackSessionsBriefCovering(ctx context.Context, projectDir, status string, limit int) ([]model.FeedbackSession, error)
- func (s *Store) ListGrants(ctx context.Context, projectID uint, includeInactive bool) ([]model.ACLGrant, error)
- func (s *Store) ListGroupMembers(ctx context.Context, groupID string, includeLeft bool) ([]model.ConversationMember, error)
- func (s *Store) ListGroupTrash(ctx context.Context) ([]model.GroupTrash, error)
- func (s *Store) ListGroups(ctx context.Context, includeArchived bool) ([]model.Conversation, error)
- func (s *Store) ListInboxItems(ctx context.Context, workflowID string) ([]model.QueuedFeedback, error)
- func (s *Store) ListLiveOAuthGrantsByClient(ctx context.Context, clientID string) ([]model.OAuthGrant, error)
- func (s *Store) ListLiveOAuthGrantsForClient(ctx context.Context, clientID string) ([]model.OAuthGrant, error)
- func (s *Store) ListManageableCredentials(ctx context.Context) ([]model.MCPCredential, error)
- func (s *Store) ListNotes(ctx context.Context, workflowID string, sessionID string, limit int) ([]model.WorkflowNote, error)
- func (s *Store) ListOAuthGrants(ctx context.Context) ([]model.OAuthGrant, error)
- func (s *Store) ListPageDiagReports(ctx context.Context, kind string, limit int) ([]model.PageDiagReport, error)
- func (s *Store) ListPendingQueuedFeedbacks(ctx context.Context, workflowID string) ([]model.QueuedFeedback, error)
- func (s *Store) ListProjectDirs(ctx context.Context, projectID uint) ([]model.ProjectDir, error)
- func (s *Store) ListProjectDocRevisions(ctx context.Context, docID uint) ([]model.ProjectDocRevision, error)
- func (s *Store) ListProjectDocs(ctx context.Context, f ProjectDocFilter) ([]model.ProjectDoc, error)
- func (s *Store) ListProjectModules(ctx context.Context, projectID uint) ([]model.ProjectModule, error)
- func (s *Store) ListProjects(ctx context.Context, includeArchived bool) ([]model.Project, error)
- func (s *Store) ListPromptRevisions(ctx context.Context, workflowID, field string) ([]model.WorkflowPromptRevision, error)
- func (s *Store) ListRetractionEvents(ctx context.Context, workflowID string) ([]RetractionEvent, error)
- func (s *Store) ListSSHHostCodesViaGateway(ctx context.Context, gateway string) ([]string, error)
- func (s *Store) ListTasks(ctx context.Context, projectID, state, cursor string, limit int, ...) (*model.TaskPage, error)
- func (s *Store) ListTerminalArchives(ctx context.Context) ([]string, error)
- func (s *Store) ListTerminalAudit(ctx context.Context, limit int, beforeID uint) ([]model.TerminalAuditLog, error)
- func (s *Store) ListTerminalAuditSince(ctx context.Context, event, result string, since time.Time, limit int) ([]model.TerminalAuditLog, error)
- func (s *Store) ListTerminalHosts(ctx context.Context) ([]model.TerminalHost, error)
- func (s *Store) ListTerminalLaunchers(ctx context.Context) ([]TerminalLauncher, error)
- func (s *Store) ListTerminalLostDismissals(ctx context.Context) (map[string]map[string]struct{}, error)
- func (s *Store) ListTerminalRuns(ctx context.Context, f RunFilter) ([]model.TerminalRun, error)
- func (s *Store) ListTerminalRunsByIDs(ctx context.Context, ids []uint) ([]model.TerminalRun, error)
- func (s *Store) ListTerminalSessions(ctx context.Context, machineCode string, endedOnly bool, limit int) ([]model.TerminalSession, error)
- func (s *Store) ListTerminalThreads(ctx context.Context, f ThreadFilter) ([]ThreadStat, error)
- func (s *Store) ListUnusedOAuthClients(ctx context.Context, since time.Time) ([]model.OAuthClient, error)
- func (s *Store) ListUserNorms(ctx context.Context) ([]model.UserNorm, error)
- func (s *Store) ListVisibleCredentials(ctx context.Context) ([]model.MCPCredential, error)
- func (s *Store) ListWorkItemWorkflows(ctx context.Context) ([]WorkflowStat, error)
- func (s *Store) ListWorkItems(ctx context.Context, f WorkItemFilter) ([]model.WorkItem, error)
- func (s *Store) ListWorkModules(ctx context.Context, workflowID string) (*WorkModuleList, error)
- func (s *Store) ListWorkflowBindings(ctx context.Context) ([]WorkflowBinding, error)
- func (s *Store) ListWorkflowFeedbackSessions(ctx context.Context, workflowID string) ([]model.FeedbackSession, error)
- func (s *Store) ListWorkflowSessionBodies(ctx context.Context, workflowID string, ids []string) ([]model.FeedbackSession, error)
- func (s *Store) ListWorkflowSessionLinks(ctx context.Context, workflowID string) ([]model.WorkItemSessionLink, error)
- func (s *Store) ListWorkflowSessionsBefore(ctx context.Context, workflowID, beforeID string, limit int, ...) ([]model.FeedbackSession, error)
- func (s *Store) ListWorkflowSummaries(ctx context.Context, projectDir, hostName string, limit int) ([]map[string]any, error)
- func (s *Store) ListWorkflowTrash(ctx context.Context) ([]model.WorkflowTrash, error)
- func (s *Store) ListWorkflowUpdates(ctx context.Context, workflowID string, since time.Time, limit int) ([]WorkflowUpdate, error)
- func (s *Store) MarkBranchParamEventsTold(ctx context.Context, ids []uint, now time.Time) error
- func (s *Store) MarkGroupMentionsRead(ctx context.Context, groupID, workflowID string, messageIDs []uint) error
- func (s *Store) MarkHookInstallHint(workflowID string, now time.Time)
- func (s *Store) MarkInboxReceiptHint(ctx context.Context, workflowID string, now time.Time) (bool, error)
- func (s *Store) MarkModeTold(ctx context.Context, workflowID, sig string) error
- func (s *Store) MarkResidentTold(ctx context.Context, workflowID string, rev int) error
- func (s *Store) MarkSessionConsumedByAI(ctx context.Context, sessionID string, consumedAt ...time.Time) error
- func (s *Store) MarkTerminalSessionPurged(ctx context.Context, machineCode, sid string) error
- func (s *Store) MarkWorkflowHistorySessionsConsumed(ctx context.Context, workflowID string) error
- func (s *Store) MigrationDryRun(ctx context.Context, projectID uint) (*MigrationReport, error)
- func (s *Store) ModuleOwnerFor(ctx context.Context, projectID uint, path string) uint
- func (s *Store) ModulePage(ctx context.Context, projectID uint, modulePath string) (*ModulePageView, error)
- func (s *Store) MoveWorkModule(ctx context.Context, id uint, delta int) (*WorkModuleList, error)
- func (s *Store) NeedsHookInstallHint(workflowID string, now time.Time) bool
- func (s *Store) NewArchiveSource(ctx context.Context, projectID uint) (*ArchiveSource, error)
- func (s *Store) NotifyMainBranchCreated(ctx context.Context, rel model.WorkflowBranch) (*model.QueuedFeedback, error)
- func (s *Store) OAuthGrantsByCredentialIDs(ctx context.Context, ids []uint) (map[uint]model.OAuthGrant, error)
- func (s *Store) PageDiagStats(ctx context.Context) (PageDiagStats, error)
- func (s *Store) PageSearchViaIndex(ctx context.Context) bool
- func (s *Store) ParamEffects(ctx context.Context, branch string, evs []model.BranchParamEvent) []ParamEffect
- func (s *Store) PeekArchiveBaseline(ctx context.Context, id string, projectID, credentialID uint, now time.Time) (*model.ArchiveBaseline, error)
- func (s *Store) PendingBranchAsks(ctx context.Context, mainWorkflowID string) ([]PendingBranchAsk, error)
- func (s *Store) PlanBranchLink(ctx context.Context, in LinkBranchInput) (*LinkBranchResult, error)
- func (s *Store) PostBoardGroupLines(ctx context.Context, events []BoardLineEvent) ([]string, error)
- func (s *Store) PostGroupMessage(ctx context.Context, in PostGroupInput) (*PostGroupResult, error)
- func (s *Store) PreviewGroupTrash(ctx context.Context, groupID string) (*GroupTrashPreview, error)
- func (s *Store) PreviewHostGrant(ctx context.Context, machineCode string) (HostGrantResult, error)
- func (s *Store) PreviewWorkflowTrash(ctx context.Context, workflowID string) (*TrashPreview, error)
- func (s *Store) ProjectBlueprint(ctx context.Context, projectID uint, withTemplates bool) ([]docs.BlueprintItem, error)
- func (s *Store) ProjectBoardsOf(ctx context.Context, projectID uint) (*ProjectBoardList, error)
- func (s *Store) ProjectOfDir(ctx context.Context, host, dir string) (*model.Project, error)
- func (s *Store) ProjectOfWorkflow(ctx context.Context, workflowID string) (*model.Project, error)
- func (s *Store) ProjectStatsOf(ctx context.Context, projectID uint) (ProjectStats, error)
- func (s *Store) ProjectSuggestions(ctx context.Context) ([]ProjectSuggestion, error)
- func (s *Store) ProjectWorkflowIDs(ctx context.Context, projectID uint) ([]string, error)
- func (s *Store) PruneArchiveBaselines(ctx context.Context, now time.Time) (int64, error)
- func (s *Store) PruneSemanticProjects(ctx context.Context) ([]uint, error)
- func (s *Store) PruneTerminalAudit(ctx context.Context, keep int) (int64, error)
- func (s *Store) PruneTerminalRuns(ctx context.Context, cutoff time.Time) (int64, error)
- func (s *Store) PruneTerminalSessions(ctx context.Context, cutoff time.Time) (int64, error)
- func (s *Store) PurgeExpiredGroupTrash(ctx context.Context, now time.Time) ([]model.GroupTrash, error)
- func (s *Store) PurgeExpiredWorkflowTrash(ctx context.Context, now time.Time) ([]model.WorkflowTrash, error)
- func (s *Store) PurgeUnusedOAuthClients(ctx context.Context, maxAge time.Duration) error
- func (s *Store) PutDraftImage(ctx context.Context, img model.DraftImage) error
- func (s *Store) PutEmbeddingCredential(ctx context.Context, c embedding.Credential) error
- func (s *Store) PutGuiWakeConfig(ctx context.Context, cfg GuiWakeConfig) (GuiWakeConfig, error)
- func (s *Store) QueueWorkflowFeedback(ctx context.Context, input QueueFeedbackInput) (*model.QueuedFeedback, error)
- func (s *Store) ReadBranchHistory(ctx context.Context, caller, branchWorkflowID string, limit int) (*BranchHistory, error)
- func (s *Store) ReadFeedbacks(ctx context.Context, projectID, taskID string, afterSequence int64, limit int) ([]model.Feedback, error)
- func (s *Store) ReadReports(ctx context.Context, projectID, taskID string, afterSequence int64, limit int) (*model.ReportPage, error)
- func (s *Store) RebindWorkflow(ctx context.Context, req RebindRequest, apply bool) (*RebindResult, error)
- func (s *Store) RebuildSearchIndex(ctx context.Context) error
- func (s *Store) RecentWorkflows(ctx context.Context, limit int) ([]WorkflowBrief, error)
- func (s *Store) ReconcileReplyWindow(ctx context.Context, workflowID string, now time.Time) (w ReplyWindow, changed bool, err error)
- func (s *Store) RecordAgentActivity(workflowID string, at time.Time)
- func (s *Store) RecordAgentEvent(ctx context.Context, workflowID string, ev AgentEvent, at time.Time)
- func (s *Store) RecordHookSeen(workflowID string, at time.Time) bool
- func (s *Store) RecordSSHCheck(ctx context.Context, code string, c SSHCheck) error
- func (s *Store) RecordTerminalSessionEnds(ctx context.Context, machineCode string, ends []TerminalSessionEnd, ...) error
- func (s *Store) RecycleOldestUnusedOAuthClient(ctx context.Context) bool
- func (s *Store) RefundKeepaliveFeedbackSession(ctx context.Context, sessionID string, extendSec int) error
- func (s *Store) RegenerateCredentialToken(ctx context.Context, id uint) (*model.MCPCredential, string, error)
- func (s *Store) ReleaseGate(ctx context.Context, workflowID string, now time.Time) (ReplyWindow, error)
- func (s *Store) RemoveGroupMember(ctx context.Context, groupID, workflowID string) error
- func (s *Store) RemoveProjectDir(ctx context.Context, projectID, dirID uint) error
- func (s *Store) RenameAgentIdentity(ctx context.Context, id uint, name, by string) (*AgentIdentityView, error)
- func (s *Store) RenameFeedbackSession(ctx context.Context, idOrWorkflow, newTitle string) (*model.FeedbackSession, error)
- func (s *Store) RenderWake(ctx context.Context, in WakeInput) WakeResult
- func (s *Store) ReplaceSidebarOrder(ctx context.Context, baseVersion int64, keys []string) (SidebarOrder, error)
- func (s *Store) ReserveEmbeddingTokens(ctx context.Context, day string, estimate, cap int64) (bool, error)
- func (s *Store) ResetAgentSearchQuota(ctx context.Context) (AgentSearchQuota, error)
- func (s *Store) ResetAuthCredentials(ctx context.Context) error
- func (s *Store) ResetSearchHintsConfig(ctx context.Context) (SearchHintsConfig, error)
- func (s *Store) ResidentWriter(ctx context.Context, workflowID string) string
- func (s *Store) ResolveArtifactComment(ctx context.Context, docID, commentID uint, resolved bool) (*model.ArtifactComment, error)
- func (s *Store) ResolveAuthProfile(ctx context.Context, id uint) (*model.AuthProfile, error)
- func (s *Store) ResolveCallerIdentity(ctx context.Context, workflowID string, credentialID uint, host, dir string, ...) (id uint, asserted bool)
- func (s *Store) ResolveDocModule(ctx context.Context, projectID uint, docPath, explicit string) string
- func (s *Store) ResolveDraftImages(ctx context.Context, workflowID string, keys []string) (map[string]model.DraftImage, error)
- func (s *Store) ResolveJWTSecret(ctx context.Context, envSecret string) (JWTSecretResolution, error)
- func (s *Store) ResolveWakeTemplate(ctx context.Context, kind sessionprompt.Kind, workflowID, presetBody string, ...) (string, WakeLayer)
- func (s *Store) ResolveWorkModule(ctx context.Context, workflowID, ref string) (*model.WorkModule, error)
- func (s *Store) RestoreFeedbackSession(ctx context.Context, session *model.FeedbackSession) (*model.FeedbackSession, error)
- func (s *Store) RestoreGroupTrash(ctx context.Context, id uint) (*GroupTrashRestoreResult, error)
- func (s *Store) RestoreHookSeen(ctx context.Context) error
- func (s *Store) RestoreProjectDocRevision(ctx context.Context, docID uint, rev int, actor DocActor) (*ProjectDocSaveResult, error)
- func (s *Store) RestoreResidentRevision(ctx context.Context, workflowID string, revisionID uint, actor string, ...) (model.WorkflowPrompt, bool, error)
- func (s *Store) RestoreWorkflowTrash(ctx context.Context, id uint) (*TrashRestoreResult, error)
- func (s *Store) RevertBranchParamEvent(ctx context.Context, branch string, eventID uint, actor string, now time.Time) (*BranchParamRevert, error)
- func (s *Store) RevokeGrant(ctx context.Context, projectID, grantID uint) (*model.ACLGrant, error)
- func (s *Store) RevokeOAuthGrant(ctx context.Context, id uint) error
- func (s *Store) RevokeQueuedFeedback(ctx context.Context, queuedID uint) (*RevokedFeedbackResult, error)
- func (s *Store) RevokeSessionFeedback(ctx context.Context, sessionID string) (*RevokedFeedbackResult, *model.FeedbackSession, error)
- func (s *Store) RotateOAuthGrantRefresh(ctx context.Context, id uint, newHash string, graceUntil, idleUntil *time.Time) error
- func (s *Store) SaveArchiveBaseline(ctx context.Context, b *model.ArchiveBaseline) error
- func (s *Store) SaveAuthCredentials(ctx context.Context, username, password string) error
- func (s *Store) SaveCheckpoint(ctx context.Context, cp *model.WorkflowCheckpoint) error
- func (s *Store) SaveNote(ctx context.Context, note *model.WorkflowNote) error
- func (s *Store) SaveOAuthPolicy(ctx context.Context, p model.OAuthPolicy) error
- func (s *Store) SaveResidentPrompt(ctx context.Context, workflowID, text, actor string, now time.Time) (model.WorkflowPrompt, bool, error)
- func (s *Store) SaveSettings(ctx context.Context, settings map[string]any) error
- func (s *Store) SaveTerminalHost(ctx context.Context, h *model.TerminalHost) error
- func (s *Store) SaveWakeTemplate(ctx context.Context, workflowID string, kind sessionprompt.Kind, ...) (model.WorkflowPrompt, bool, error)
- func (s *Store) SaveWorkflowDraft(ctx context.Context, workflowID string, activeIndex int, draftsJSON string) (*model.WorkflowDraft, error)
- func (s *Store) Search(ctx context.Context, q SearchQuery) (*SearchResult, error)
- func (s *Store) SearchCandidates(ctx context.Context, q SearchCandidateQuery) *CandidateSet
- func (s *Store) SearchHintsConfig(ctx context.Context) (SearchHintsConfig, error)
- func (s *Store) SearchIndexEnabled() bool
- func (s *Store) SearchProject(ctx context.Context, f ProjectSearchFilter) ([]ProjectSearchHit, error)
- func (s *Store) SearchProjectDocs(ctx context.Context, workflowID, query string, limit int) ([]docs.SearchHit, error)
- func (s *Store) SearchStatus(ctx context.Context) (*SearchIndexStatus, error)
- func (s *Store) SearchWorkItems(ctx context.Context, q WorkSearchQuery) (*WorkSearchResult, error)
- func (s *Store) SeedBuiltinNorms(ctx context.Context) error
- func (s *Store) SeedDefaultAuthProfile(ctx context.Context) error
- func (s *Store) SemanticChunkVectors(ctx context.Context, kind, ref string) (map[string]model.EmbedChunk, error)
- func (s *Store) SemanticClear(ctx context.Context) (entries, chunks int64, err error)
- func (s *Store) SemanticDeleteEntries(ctx context.Context, keys []SemanticKey) error
- func (s *Store) SemanticEligible(ctx context.Context, kinds []string, projectIDs []uint) (SemanticSet, error)
- func (s *Store) SemanticEntries(ctx context.Context) (map[string]map[string]model.EmbedEntry, error)
- func (s *Store) SemanticLoad(ctx context.Context, kind string, refs []string) ([]SemanticText, error)
- func (s *Store) SemanticProjectIDs(ctx context.Context) ([]uint, error)
- func (s *Store) SemanticPut(ctx context.Context, e model.EmbedEntry, chunks []model.EmbedChunk) error
- func (s *Store) SemanticScan(ctx context.Context, sig string, ...) error
- func (s *Store) SemanticScopeFor(ctx context.Context, q SearchQuery) (*SemanticScope, error)
- func (s *Store) SemanticScopeUnion(ctx context.Context, projectIDs []uint) (*SemanticScope, error)
- func (s *Store) SemanticStats(ctx context.Context, sig string) (SemanticStats, error)
- func (s *Store) SemanticTouchEntry(ctx context.Context, e model.EmbedEntry) error
- func (s *Store) SemanticVisible(ctx context.Context, scope *SemanticScope, cands []SemanticKey) (map[string]*SemanticText, error)
- func (s *Store) SendFeedback(ctx context.Context, input model.SendFeedbackInput) (*model.Feedback, error)
- func (s *Store) SetAgentRunAuthority(workflowID, conv string, until time.Time)
- func (s *Store) SetAgentScreen(workflowID string, in AgentScreenInput, now time.Time) AgentScreenChange
- func (s *Store) SetAgentSearchAccess(ctx context.Context, keyword, semantic *bool) (AgentSearchAccess, error)
- func (s *Store) SetAgentSearchQuota(ctx context.Context, p AgentSearchQuotaPatch) (AgentSearchQuota, error)
- func (s *Store) SetDataDir(dir string)
- func (s *Store) SetDefaultAuthProfile(ctx context.Context, id uint) (*model.AuthProfile, error)
- func (s *Store) SetDiagBrowserReportsEnabled(ctx context.Context, on bool) error
- func (s *Store) SetGroupMemberPolicy(ctx context.Context, groupID, memberRef, policy string, mutedUntil *time.Time, ...) error
- func (s *Store) SetPageSearchViaIndex(ctx context.Context, on bool) error
- func (s *Store) SetQueuedFeedbackHints(ctx context.Context, queuedID uint, hints model.Hints, at time.Time) error
- func (s *Store) SetSearchHintsConfig(ctx context.Context, p SearchHintsPatch) (SearchHintsConfig, error)
- func (s *Store) SetSearchIndexEnabled(ctx context.Context, on bool) error
- func (s *Store) SetSemanticProjectIDs(ctx context.Context, ids []uint) (added, removed []uint, err error)
- func (s *Store) SetSessionReplyHints(ctx context.Context, sessionID string, hints model.Hints, at time.Time) error
- func (s *Store) SetSystemFlag(ctx context.Context, key string, on bool) error
- func (s *Store) SetTerminalArchived(ctx context.Context, keys []string, archived bool, now time.Time) (int64, error)
- func (s *Store) SetTerminalHostIdle(ctx context.Context, machineCode string, sec int) (changed bool, err error)
- func (s *Store) SetTerminalHostModel(ctx context.Context, machineCode string, u HostModelUpdate) (host *model.TerminalHost, changed bool, err error)
- func (s *Store) SetTerminalHostRecOff(ctx context.Context, machineCode string, off bool) (changed bool, err error)
- func (s *Store) SetTerminalHostRemark(ctx context.Context, machineCode, remark string) error
- func (s *Store) SetTerminalHostStatus(ctx context.Context, machineCode, status string) (changed bool, err error)
- func (s *Store) SetWaitPolicy(ctx context.Context, input model.SetWaitPolicyInput) (*model.MutationResult, error)
- func (s *Store) SetWorkflowHost(ctx context.Context, req WorkflowHostRequest, apply bool) (*WorkflowHostResult, error)
- func (s *Store) SetWorkflowPhase(ctx context.Context, workflowID, phaseID string, isHumanClick bool) error
- func (s *Store) SetWorkflowPhaseConfig(ctx context.Context, workflowID string, phases []model.PhaseItem) error
- func (s *Store) SettleEmbeddingTokens(ctx context.Context, day string, estimate, actual int64, failed bool) error
- func (s *Store) ShelvedAfterAnswer(ctx context.Context, workflowID string, now time.Time, limit int) (items []asyncmode.AnsweredTask, total int)
- func (s *Store) ShelvedUnexplained(ctx context.Context, workflowID string, now time.Time, limit int) (tasks []asyncmode.GateTask, total int)
- func (s *Store) SnapshotTo(ctx context.Context, dest string) error
- func (s *Store) SoftDeleteProjectDoc(ctx context.Context, docID uint) error
- func (s *Store) StartSearchIndexer(parent context.Context)
- func (s *Store) StopSearchIndexer()
- func (s *Store) StreamAnswerDeliveries(ctx context.Context, workflowID string, from, to time.Time) ([]model.QueuedFeedback, error)
- func (s *Store) StreamAnswers(ctx context.Context, workflowID string, r StreamRange) ([]model.ConfirmItem, error)
- func (s *Store) StreamCards(ctx context.Context, workflowID string, r StreamRange) ([]model.ConfirmItem, error)
- func (s *Store) StreamDecisionItems(ctx context.Context, workflowID string) ([]model.ConfirmItem, error)
- func (s *Store) StreamEndings(ctx context.Context, workflowID string, r StreamRange) ([]model.FeedbackSession, error)
- func (s *Store) StreamEvents(ctx context.Context, conversationID string, r StreamRange) ([]model.ConversationEvent, error)
- func (s *Store) StreamGroupMessages(ctx context.Context, groupID string, r StreamRange, vis *GroupVisibility, ...) ([]model.ChatMessage, error)
- func (s *Store) StreamInbox(ctx context.Context, workflowID string, r StreamRange) ([]model.QueuedFeedback, error)
- func (s *Store) StreamMergedInbox(ctx context.Context, workflowID string, sessionIDs []string) (map[string][]model.QueuedFeedback, error)
- func (s *Store) StreamNotices(ctx context.Context, workflowID string, r StreamRange) ([]model.FeedbackSession, error)
- func (s *Store) StreamReplies(ctx context.Context, workflowID string, r StreamRange) ([]model.FeedbackSession, error)
- func (s *Store) StreamReports(ctx context.Context, workflowID string, r StreamRange) ([]model.FeedbackSession, error)
- func (s *Store) StreamRetractions(ctx context.Context, workflowID string, r StreamRange) ([]model.QueuedFeedback, error)
- func (s *Store) StreamTaskUpdates(ctx context.Context, workflowID string, since time.Time, r StreamRange) ([]WorkflowUpdate, error)
- func (s *Store) SubmitFeedback(ctx context.Context, input SubmitFeedbackInput) (*model.FeedbackSession, error)
- func (s *Store) SupersedeOldCheckpoints(ctx context.Context, workflowID string, currentRevision int) error
- func (s *Store) SweepDraftImages(ctx context.Context, olderThan time.Time) (int64, error)
- func (s *Store) SwitchLauncherToContinue(ctx context.Context, id string) (TerminalLauncher, bool, error)
- func (s *Store) Sync(ctx context.Context, input model.SyncInput) (*model.SyncResult, error)
- func (s *Store) SyncDecisionConfirmItems(ctx context.Context, doc *model.ProjectDoc, body string) (bool, error)
- func (s *Store) SyncSearchIndex(ctx context.Context) error
- func (s *Store) SyncTerminalSessions(ctx context.Context, machineCode string, seen []TerminalSessionSeen, ...) (int, error)
- func (s *Store) TouchAgentIdentity(ctx context.Context, in AgentTouchInput, now time.Time) error
- func (s *Store) TouchCredentialUsage(ctx context.Context, id uint, ip string, at time.Time) error
- func (s *Store) TouchOAuthClient(ctx context.Context, clientID string)
- func (s *Store) TouchTerminalHost(ctx context.Context, machineCode string, seen TerminalHostSeen) error
- func (s *Store) TrashGroup(ctx context.Context, in GroupTrashInput) (*GroupTrashResult, error)
- func (s *Store) TrashWorkflow(ctx context.Context, in TrashInput) (*model.WorkflowTrash, error)
- func (s *Store) UnarchiveFeedbackSession(ctx context.Context, idOrWorkflow string) (*model.FeedbackSession, error)
- func (s *Store) UnlinkBranch(ctx context.Context, branchWorkflowID string, dryRun bool, by string) (*model.WorkflowBranch, error)
- func (s *Store) UnlinkWorkItemSession(ctx context.Context, id uint, sessionID string) error
- func (s *Store) UntoldBranchParamEvents(ctx context.Context, branch string) ([]model.BranchParamEvent, error)
- func (s *Store) UpdateAuthProfile(ctx context.Context, id uint, in AuthProfileInput) (*model.AuthProfile, error)
- func (s *Store) UpdateBranchPrefs(ctx context.Context, ...) (model.BranchPrefs, error)
- func (s *Store) UpdateBranchSettings(ctx context.Context, branchWorkflowID string, in UpdateBranchInput) (*model.WorkflowBranch, error)
- func (s *Store) UpdateBranchSettingsFull(ctx context.Context, branchWorkflowID string, in UpdateBranchInput) (*model.WorkflowBranch, []model.ConfirmItem, error)
- func (s *Store) UpdateCheckpointStatus(ctx context.Context, workflowID string, revision int, status string) error
- func (s *Store) UpdateCredential(ctx context.Context, id uint, updates map[string]any) (*model.MCPCredential, error)
- func (s *Store) UpdateEmbeddingConfig(ctx context.Context, mutate func(embedding.Config) embedding.Config, ...) (embedding.Config, error)
- func (s *Store) UpdateGroup(ctx context.Context, groupID string, in UpdateGroupInput) (*model.Conversation, error)
- func (s *Store) UpdateInboxConfig(ctx context.Context, mutate func(cur InboxConfig) InboxConfig) (InboxConfig, error)
- func (s *Store) UpdateNote(ctx context.Context, id uint, content string) error
- func (s *Store) UpdateNotifyPrefs(ctx context.Context, mutate func(cur notify.Prefs) (notify.Prefs, error)) (notify.Prefs, error)
- func (s *Store) UpdateNtfyConfig(ctx context.Context, mutate func(cur ntfy.Config) ntfy.Config) (ntfy.Config, error)
- func (s *Store) UpdateOAuthGrantCredential(ctx context.Context, grantID, credID uint) error
- func (s *Store) UpdateOAuthGrantRefreshMeta(ctx context.Context, grantID uint, hash string, idle, abs *time.Time) error
- func (s *Store) UpdateProject(ctx context.Context, id uint, patch ProjectPatch) (*model.Project, error)
- func (s *Store) UpdateProjectDoc(ctx context.Context, docID uint, patch ProjectDocPatch, actor DocActor) (*ProjectDocSaveResult, error)
- func (s *Store) UpdateSSHConn(ctx context.Context, code string, u SSHConnUpdate) error
- func (s *Store) UpdateSemanticRun(ctx context.Context, mutate func(SemanticRun) SemanticRun, ...) (SemanticRun, error)
- func (s *Store) UpdateSessionMaxChecks(ctx context.Context, idOrWorkflow string, maxChecks int) (*model.FeedbackSession, error)
- func (s *Store) UpdateSessionPromptWait(ctx context.Context, idOrWorkflow string, waitMinutes int) (*model.FeedbackSession, error)
- func (s *Store) UpdateSessionWaitCountdown(ctx context.Context, idOrWorkflow string, countdownMinutes int) (*model.FeedbackSession, error)
- func (s *Store) UpdateSessionWaitCountdownSeconds(ctx context.Context, idOrWorkflow string, seconds int) (*model.FeedbackSession, error)
- func (s *Store) UpdateStages(ctx context.Context, input model.UpdateStagesInput) (*model.MutationResult, error)
- func (s *Store) UpdateTask(ctx context.Context, input model.UpdateTaskInput) (*model.MutationResult, error)
- func (s *Store) UpdateTaskHeartbeat(ctx context.Context, projectID, taskID, role, sessionID string) error
- func (s *Store) UpdateTerminalGuardState(ctx context.Context, now time.Time, mutate func(*GuardStateDoc)) (GuardStateDoc, error)
- func (s *Store) UpdateTerminalPrefs(ctx context.Context, mutate func(*TerminalPrefs)) (TerminalPrefs, error)
- func (s *Store) UpdateTerminalRun(ctx context.Context, runID string, fields map[string]any) (bool, error)
- func (s *Store) UpdateTerminalRunIf(ctx context.Context, runID string, fromStates []string, fields map[string]any) (bool, error)
- func (s *Store) UpdateUserNorm(ctx context.Context, name string, updates map[string]any) (*model.UserNorm, error)
- func (s *Store) UpdateWorkItem(ctx context.Context, id uint, patch WorkItemPatch, actor WorkActor) (*WorkItemResult, error)
- func (s *Store) UpdateWorkModule(ctx context.Context, id uint, patch WorkModulePatch) (*model.WorkModule, error)
- func (s *Store) UpdateWorkflowMode(ctx context.Context, workflowID string, patch ModePatch, now time.Time) (ModeInfo, error)
- func (s *Store) UpsertProjectModule(ctx context.Context, projectID uint, in ModuleInput) (*model.ProjectModule, error)
- func (s *Store) UpsertTerminalLauncher(ctx context.Context, l TerminalLauncher) ([]TerminalLauncher, bool, error)
- func (s *Store) WithTx(ctx context.Context, fn func(tx *gorm.DB) error) error
- func (s *Store) WithdrawConfirmItem(ctx context.Context, workflowID, ref string, agentOnly bool) (*model.ConfirmItem, error)
- func (s *Store) WithdrawDocPendingConfirms(ctx context.Context, docID uint) error
- func (s *Store) WorkDigestFor(ctx context.Context, workflowID string) (*WorkDigest, error)
- func (s *Store) WorkModuleScope(ctx context.Context, moduleID uint) ([]uint, error)
- func (s *Store) WorkflowBinding(ctx context.Context, workflowID string) (host, dir string)
- func (s *Store) WorkflowBindingOf(ctx context.Context, workflowID string) (*WorkflowBinding, error)
- func (s *Store) WorkflowBoundDirectory(ctx context.Context, workflowID string) (string, error)
- func (s *Store) WorkflowGate(ctx context.Context, workflowID string) (GateInfo, error)
- func (s *Store) WorkflowHostInfoOf(ctx context.Context, workflowID string) (*WorkflowHostInfo, error)
- func (s *Store) WorkflowHostOverride(ctx context.Context, workflowID string) (string, error)
- func (s *Store) WorkflowIdentityID(ctx context.Context, workflowID string) uint
- func (s *Store) WorkflowModeInfo(ctx context.Context, workflowID string, now time.Time) (ModeInfo, error)
- func (s *Store) WorkflowTitleOf(ctx context.Context, workflowID string) string
- type StreamDir
- type StreamRange
- type SubmitFeedbackInput
- type TerminalHostSeen
- type TerminalLauncher
- type TerminalPrefs
- type TerminalSessionEnd
- type TerminalSessionSeen
- type ThreadFilter
- type ThreadStat
- type TrashInput
- type TrashPreview
- type TrashRestoreResult
- type UpdateBranchInput
- type UpdateGroupInput
- type UserHints
- type WakeInput
- type WakeLayer
- type WakeResult
- type WakeTemplates
- type WorkActor
- type WorkBranchScope
- type WorkDigest
- type WorkItemFilter
- type WorkItemInput
- type WorkItemPatch
- type WorkItemResult
- type WorkModuleDeleteResult
- type WorkModuleList
- type WorkModulePatch
- type WorkPlanNode
- type WorkPlanResult
- type WorkPolicy
- type WorkSearchFacets
- type WorkSearchHit
- type WorkSearchQuery
- type WorkSearchResult
- type WorkflowBinding
- type WorkflowBrief
- type WorkflowHostInfo
- type WorkflowHostRequest
- type WorkflowHostResult
- type WorkflowProjectRef
- type WorkflowStat
- type WorkflowUpdate
Constants ¶
const ( AgentEventTool = "tool" // 一次工具调用刚结束(说明智能体还在干活) AgentEventStop = "stop" // 一轮对话结束了(正常收尾、被中止或出错) )
汇报事件的种类。
const ( StopCompleted = "completed" StopAborted = "aborted" StopError = "error" StopOther = "other" )
一轮对话的结束状态。其他取值一律记为 StopOther。
const ( // ArchiveBaselineKeep 是每个(项目,令牌)保留的可用基线条数。 ArchiveBaselineKeep = 5 // ArchiveBaselineTTL 是基线从登记起的有效期。 ArchiveBaselineTTL = 30 * 24 * time.Hour // ArchiveBaselinePendingTTL 是登记中(包还没写完)的基线最多保留多久。 ArchiveBaselinePendingTTL = time.Hour )
const ( // AuditRetention 是审计保留时长(180 天)。 AuditRetention = 180 * 24 * time.Hour // AuditCrossReadDedupe 是跨界读取的去重窗口:同一主体 + 范围 30 分钟内只记一条。 AuditCrossReadDedupe = 30 * time.Minute )
const ( // BoardWhyProjectDir:会话目录属于某个未归档的项目 → 项目板。 BoardWhyProjectDir = "project_dir" // BoardWhyDirNotRegistered:有带目录的汇报会话,但目录没登记进任何未归档的项目(含所属项目已归档)→ 独立板。 BoardWhyDirNotRegistered = "dir_not_registered" // BoardWhyNoSessionDir:还没有带目录的汇报会话(例如分支里的 Agent 还没连上 RelayMesh)→ 独立板。 BoardWhyNoSessionDir = "no_session_dir" // BoardWhyPinnedByTasks:名下已有归板的任务,粘性规则让它一直用任务所在的板——这张板不是「目录现在也认的项目板」, // 所以之后登记 / 改目录都换不了板(要么按目录该落的板是另一张,要么它在没有项目的独立板上,目录一登记就会变成前一种)。 BoardWhyPinnedByTasks = "pinned_by_tasks" // BoardWhyPinnedByModules:同上,钉住它的是规划节点(名下还没有任务)。 BoardWhyPinnedByModules = "pinned_by_modules" // BoardWhyInherited:分支沿用主会话的任务板(#284)——它是一条活动关系里的分支,自己的会话目录没有登记进任何项目; // 名下的任务 / 规划节点若就在这张板上(沿用期间自己建出来的),原因仍然是「沿用」,不算被钉住。 BoardWhyInherited = "inherited" )
归板原因(BoardWhy.Code):工作流现在落在这张板的原因。branch list、任务页横幅、指派被拒的说明共用这一份,各处说法一致。
const ( AuditBranchParamsSet = "branch.params_set" AuditBranchParamsRevert = "branch.params_revert" )
分支会话参数相关的审计动作(只记字段与摘要,不记常驻规则 / 唤醒词的全文)。
const ( AuditBranchAnswer = "branch.answer" AuditBranchEscalate = "branch.escalate" )
审计动作(只记双方工作流编号、请示编号与风险档,不记正文)。
const ( BranchReadySay = "say" BranchReadyDecide = "decide" BranchReadyLaunch = "launch" BranchReadyAssign = "assign" // BranchReadyParams 是主会话能不能用 session_params 为这个分支写常驻规则(#302):「改参数」档位到了「常驻规则」或更高。 // 放在最后,前四项的顺序保持不变。 BranchReadyParams = "params" )
就绪度各项的键(也是呈现顺序):主会话对一个分支能做的五件事。
const ( // MaxActiveBranches 是一个主会话最多同时有多少个活动分支。 MaxActiveBranches = 8 // BranchCreatePerHour 是一个主会话每小时最多新建多少个分支(迁移命令不受限)。 BranchCreatePerHour = 5 // BranchSayMaxRunes 是一条分支消息的字数上限。 BranchSayMaxRunes = 4000 // BranchSayPerHour 是同一个发送方每小时最多发多少条分支消息(防两个 Agent 互相回复形成环路)。 BranchSayPerHour = 60 // BranchUnreadCap 是同一发送方发给同一个接收方、对方还没读的分支消息最多多少条。 BranchUnreadCap = 20 // BranchCopyRunes 是抄送给主会话的用户发言摘要的字数上限。 BranchCopyRunes = 200 // BranchListMax 是关系列表一次最多返回多少行。 BranchListMax = 500 // BranchReadDefault / BranchReadMax 是主会话读分支历史时的默认与最大轮数。 BranchReadDefault = 10 BranchReadMax = 20 // BranchSummaryRunes 是「摘要」档里每一轮正文保留的字数。 BranchSummaryRunes = 200 // BranchFullRunes 是「全文」档里每一轮每段正文保留的字数上限(防止一次返回过大)。 BranchFullRunes = 8000 )
const ( AuditBranchLink = "branch.link" AuditBranchUnlink = "branch.unlink" AuditBranchClose = "branch.close" AuditBranchSettings = "branch.settings" AuditBranchSay = "branch.say" )
分支相关的审计动作(只记双方工作流编号与字数,不记正文)。
const ( BranchRoleMain = "main" BranchRoleBranch = "branch" BranchRoleNone = "none" )
会话页的角色。
const ( CredentialTokenPrefix = "rm-" CredentialTokenBytes = 32 CredentialNameMaxLen = 128 CredentialNoteMaxLen = 512 CredentialMaxCount = 50 )
const ( CredentialMaxTerminalHosts = 100 CredentialMaxCIDRs = 50 CredentialMaxArchiveProjects = 50 CredentialMaxAllowedDirs = 50 CredentialMaxAllowedPaths = termproto.MaxFileRoots )
凭据终端相关字段的上限。它们只是「防写坏」的结构性边界,不是对模型行为的限制。
const ( // MaxDraftImageChars 单张草稿图片正文的长度上限(约 30MB 的原图)。 MaxDraftImageChars = 40 << 20 // MaxDraftImagesPerWorkflow 一个工作流同时能存放的草稿图片张数。 MaxDraftImagesPerWorkflow = 60 // MaxDraftImageCharsPerWorkflow 一个工作流所有草稿图片正文的总长度上限。 MaxDraftImageCharsPerWorkflow = 160 << 20 )
草稿图片(云存储)的配额。图片正文是 Base64 文本,所以限额都按文本长度计。
const ( GroupMaxMembers = 12 // 含你 GroupMaxBodyBytes = 8 * 1024 // 单条消息 GroupRatePerMinute = 10 // 每个 Agent 每群 GroupRatePerHour = 120 // 每个 Agent 每群 GroupHopLimit = 4 // 回复链到这一跳就丢弃 GroupHopWindow = 3 * time.Minute // 处理某条 @ 之后多久内发出的消息算回复链 GroupCoolWindow = 5 * time.Minute GroupCoolThreshold = 12 // 窗口内 Agent→Agent 消息数 GroupTitleMaxRunes = 80 // GroupHumanRef 是群里「你」的成员引用与已读读者引用。 GroupHumanRef = "user" )
群聊的限额与安全阈值(设计稿 03 §3.3 / §3.4)。
const ( MaxGuiWakeTargets = 50 // MaxGuiWakeWorkflowRunes 与会话守护 / 预设里的工作流编号同一个上限。目标编号沿用预设编号的写法(launcherIDRe:字母数字下划线连字符,最长 40)。 MaxGuiWakeWorkflowRunes = MaxGuardWorkflowRunes )
目标配置的取值范围。
const ( // GuiTextTemplate 渲染现有的唤醒词模板(与 CLI 唤醒同一套文字与变量,默认)。 GuiTextTemplate = "template" // GuiTextPlain 只发一句简短的「继续」;只对续聊开放——新会话的初始提示词必须带 %workflow 才接得进 RelayMesh。 GuiTextPlain = "plain" )
唤醒词的来源(GuiWakeTarget.TextMode)。
const ( // InboxExpireAfter 是未被取走的追加的保留期;超过后标为 expired,不再送达。 InboxExpireAfter = 7 * 24 * time.Hour // InboxMaxReminders 是每条消息最多让 hook 提醒几次。 InboxMaxReminders = 3 // InboxRecentWindow 是智能体用 inbox recent=true 找回「最近已确认的追加」时回看多久。 InboxRecentWindow = 24 * time.Hour // InboxListMax 是一次最多返回给 Web 的条数。追加信息在会话页里是对话中的永久气泡(不再是几天后消失的底部提示条), // 要能回看整个工作流的历史,所以放宽到 200;超出时保留最近的。 InboxListMax = 200 // InboxMaxPending 是同一个工作流里未确认的追加条数上限(防止误操作或脚本无限堆积)。 InboxMaxPending = 100 // InboxPreviewRunes 是提示行 / hook 里给出的预览长度。 InboxPreviewRunes = 160 )
const ( InboxViaFeedback = "feedback" // 智能体发起交互时随「秒回」带走 InboxViaHook = "hook" // Cursor hook 提醒后读取 InboxViaReceipt = "receipt" // 工具回执里的 inbox: 提示行提醒后读取 InboxViaTool = "tool" // 智能体自己调用 inbox 读取 )
一条追加是经哪条路径被智能体发现的。
const ( NormNameMaxLen = 128 NormSummaryMaxLen = 500 NormContentMaxLen = 20000 NormMaxCount = 50 )
const ( // PageDiagKeep 是库里最多留多少条页面自己交来的诊断上报。 PageDiagKeep = 50 // BrowserCrashKeep 是库里最多留多少条浏览器自报的崩溃。 BrowserCrashKeep = 200 // PageDiagKindBrowserCrash 是浏览器自报崩溃的 kind。 PageDiagKindBrowserCrash = "browser-crash" )
const ( // ProjectBoardKindProject 是项目板("p<项目编号>"),ProjectBoardKindStandalone 是工作流的独立板("w:<工作流编号>")。 ProjectBoardKindProject = "project" ProjectBoardKindStandalone = "standalone" )
const ( DefaultAgentKeywordPerMinute = 60 DefaultAgentSemanticPerMinute = 6 DefaultAgentSemanticGlobalPerMinute = 30 MinAgentSearchPerMinute = 1 MaxAgentKeywordPerMinute = 600 MaxAgentSemanticPerMinute = 120 MaxAgentSemanticGlobalPerMinute = 600 )
默认值与取值范围(下限都是 1:0 或负数没有意义,想彻底禁用请用「允许智能体使用…」的开关)。
const ( PageSearchModeIndex = "index" // 这次搜索用了全文索引的候选集 PageSearchModeLegacy = "legacy" // 回退到页面原来的逻辑 )
页面搜索的两种模式。
const ( PageReasonSwitchOff = "switch_off" // 设置里的「页面搜索走全文索引」关着 PageReasonIndexOff = "index_off" // 全文索引没在工作(关闭、环境变量强制关闭、建不出来) PageReasonBuilding = "building" // 这一类内容还没回填完,或正在整体重建 PageReasonTooShort = "too_short" // 检索词没有可走索引的内容(只剩单个汉字、纯标点……) PageReasonTooMany = "too_many" // 索引里的候选超过上限,求交的代价不值得 PageReasonNoMatch = "no_candidates" // 索引一条都没找到:规则有差别(子串 vs 整词)时,交给原来的逻辑再找一次 PageReasonError = "error" // 查索引时出错(记日志,页面不受影响) )
回退的原因(mode=legacy 时的 reason):稳定代码,前端与 e2e 按它分支。
const ( DefaultHintsEnabled = true DefaultHintsMax = 3 DefaultHintsThreshold = 0.60 DefaultHintsSessionThreshold = 0.70 DefaultHintsPerHour = 30 MinHintsMax = 1 MaxHintsMax = 5 // 相似度下限的范围(两个下限共用):太低(< 0.30)几乎什么都算「相关」,太高(> 0.95)等于只有几乎一模一样的才算。 MinHintsThreshold = 0.30 MaxHintsThreshold = 0.95 MinHintsPerHour = 1 MaxHintsPerHour = 600 )
默认值与取值范围。
const ( SearchKindDoc = "doc" // 项目文档(含路径、标签) SearchKindTask = "task" // 任务(标题、标签、说明、进度、结论) SearchKindConfirm = "confirm" // 确认项(标题、说明、选项、答复) SearchKindSession = "session" // 会话轮次(标题、汇报、答复、被「秒回」并进这一轮的用户追加) SearchKindMessage = "message" // 用户追加:收件箱里已被智能体读到的人工追加(含没有并进任何一轮的),见 searchMessageLive SearchKindChat = "chat" // 群消息 )
全文索引覆盖的六类内容(#266;「用户追加」是 #303 B 新增的一类)。
const ( // DefaultSessionsByWorkflow 是调用方没给条数(≤ 0)时,按工作流读会话一次返回的条数。 DefaultSessionsByWorkflow = 10 // MaxSessionsByWorkflow 是按工作流读会话一次最多返回的条数;调用方要得更多时按这个数截断。 MaxSessionsByWorkflow = 200 )
const ( GlobalSettingsKey = "app_settings" AuthCredentialsKey = "auth_credentials" )
const ( // HeadlessPostureAllowlist(默认):不带 --force,智能体只能做 CLI 自己的 permissions.allow 白名单放行的事 // (例如 Mcp(relaymesh:*)、Shell(git status));白名单之外的 shell 命令会被拒绝。 HeadlessPostureAllowlist = "allowlist" // HeadlessPostureForce:带 --force,等于放开全部命令;只在你明确接受时使用。 HeadlessPostureForce = "force" )
非交互唤醒的权限姿态。
const ( // AutoResumePending:已排期,到点(Due)开跑;到点前可以取消。 AutoResumePending = "pending" // AutoResumeStarted:已经续跑,RunID 是续跑出来的新运行。 AutoResumeStarted = "started" // AutoResumeStopped:你在到点前取消了这次自动续跑。 AutoResumeStopped = "stopped" // AutoResumeSkipped:这次出事不自动续跑,或到点时条件不满足(你已经重新运行了、预设改了……);Why 写明原因。 AutoResumeSkipped = "skipped" // AutoResumeGaveUp:本该续跑但预算用完、连续没有进展或没法提交,放弃并通知;Why 写明原因。 AutoResumeGaveUp = "gaveup" )
非交互运行异常退出后自动续跑(#151,D-260)的登记状态(AutoResumeRecord.State)。
const ( // AutoResumeKeep、AutoResumeKeepMax:登记最多保留这么久、这么多条。它用来算「24 小时内续跑了几次」「这一串续跑有没有进展」, // 也让界面能说明上一次出事之后发生了什么;不是审计日志。待开跑的登记不受时间限制(到点没跑成会被标成跳过)。 AutoResumeKeep = 7 * 24 * time.Hour AutoResumeKeepMax = 30 )
const ( // LauncherKindTerminal 是默认类型:点「启动」在主机上开一个终端会话并自动输入命令。 // 旧存档没有 kind 字段,都是这种;存盘时规整成空串。 LauncherKindTerminal = "terminal" // LauncherKindHeadless 是「非交互续聊」(#126):点「运行」经主机的执行通道跑一次 // `agent -p --resume <对话编号> …`,不开终端;运行配置见 HeadlessRun。 LauncherKindHeadless = "headless" )
启动器预设的类型(TerminalLauncher.Kind)。
const ( // MaxHeadlessPromptRunes 与会话 / 全局模板同一个上限(sessionprompt.TemplateMaxRunes,测试里核对): // v2 内置默认比旧版长,预设里「以默认为底稿」填进去必须还能存(#232 D3,原先是 600)。 MaxHeadlessPromptRunes = 1500 MaxHeadlessModelRunes = 64 MaxHeadlessBinRunes = 128 // DefaultHeadlessBin 是没填可执行文件时用的命令名。 DefaultHeadlessBin = "agent" )
非交互续聊预设的取值范围(按字符数)。
const ( // MinHeadlessRunMinutes 是下限:再短连智能体启动的时间都不够,没有意义。 MinHeadlessRunMinutes = 1 // MaxHeadlessRunMinutes 是上限,也是没填时的默认值:平台单次运行上限 7 天。 // 它与 termproto.MaxRunTimeoutSec 同值(store 不依赖协议包,由 terminal 包的测试守住这一点)。 MaxHeadlessRunMinutes = 7 * 24 * 60 )
非交互续聊预设「最长运行时间」的取值范围(分钟,#141)。
const ( // DefaultAutoResumeOKMinutes 是没填时的默认值:续跑出来的运行连续跑满 10 分钟,就算这次续跑成功。 DefaultAutoResumeOKMinutes = 10 // MinAutoResumeOKMinutes 是下限;MaxAutoResumeOKMinutes 是上限(1 天):再长就没有「算成功」的意义了。 MinAutoResumeOKMinutes = 1 MaxAutoResumeOKMinutes = 24 * 60 )
自动续跑「成功」判定时长的取值范围(分钟,#172)。
const ( // HeadlessSourceResume 是「指定会话」:命令带 `--resume <对话编号>`。填了对话编号就固定接这一个; // 留空就取这个工作流里智能体最近汇报的对话(跟随工作流,「启用 Agent」建出的预设就是这样)。 HeadlessSourceResume = "resume" // HeadlessSourceNew 是「新会话」:命令不带 `--resume`,Cursor CLI 新开一个对话,Hub 从输出的 init 事件里学到它的编号。 // 之后的运行怎么办由 HeadlessRun.AfterNew 决定。 HeadlessSourceNew = "new" // HeadlessSourceContinue 是「最近会话」:命令带 `--continue`,由 Cursor CLI 接着该目录里最近动过的对话。 // 它接到哪个对话是 CLI 的决定(编辑器里开的窗口、别的工作流的运行、手敲的命令都算),Hub 运行前并不知道。 HeadlessSourceContinue = "continue" )
非交互续聊预设的「对话来源」(HeadlessRun.Source,#191):这次运行接到哪个对话上,三选一。
const ( // HeadlessAfterRemember 是默认:把学到的对话编号记成工作流当前的对话,之后的运行接着它——所以只新开一次。 HeadlessAfterRemember = "remember" // HeadlessAfterStay 是「不切换」:每一次运行都新开一个对话,不接着上一次的。 HeadlessAfterStay = "stay" // HeadlessAfterContinue 是「切到最近会话」:运行成功之后,Hub 把这个预设的对话来源改成「最近会话」,再之后的运行用 `--continue`。 HeadlessAfterContinue = "continue" )
「新会话」运行之后的去向(HeadlessRun.AfterNew,#559):只在对话来源是「新会话」时有意义。
const ( MaxTerminalLaunchers = 20 MaxLauncherNameRunes = 40 MaxLauncherDirRunes = 512 MaxLauncherCommandRunes = 1000 )
启动器预设的取值范围(按字符数,不是字节数;中文名字和中文目录同样适用)。
const ( DefaultGuardSilenceMinutes = 30 MinGuardSilenceMinutes = 5 MaxGuardSilenceMinutes = 720 MaxGuardWorkflowRunes = 128 // MaxGuardPromptRunes 与会话 / 全局模板同一个上限(sessionprompt.TemplateMaxRunes,测试里核对): // v2 内置默认比旧版长,预设里「以默认为底稿」填进去必须还能存(#232 D3,原先是 300)。 MaxGuardPromptRunes = 1500 )
会话守护(LauncherGuard)的取值范围。静默分钟数的下限防止把「正常思考」当停摆,上限 12 小时。
const ( // 固定终端列数(宽度保持):小于 40 列几乎没法用,大于 400 列即使缩到最小字号也放不进手机屏幕。 MinFixedCols = 40 MaxFixedCols = 400 // 单会话记录保留的输出行数上限:小于 5000 行连一屏回看都不够;上限 1000 万行只是防止填错数字,实际受字节配额约束。 MinRecordMaxLines = 5000 MaxRecordMaxLines = 10_000_000 )
终端偏好的取值范围;0 一律表示「关闭 / 不限制」。
const ( // WebWorkflowFirstMessageMaxRunes 是首条指令的最大字符数。 WebWorkflowFirstMessageMaxRunes = 20000 // WebWorkflowProjectDirMaxRunes 是项目目录的最大字符数。 WebWorkflowProjectDirMaxRunes = 1024 // WebWorkflowHostNameMaxRunes 是主机名的最大字符数。 WebWorkflowHostNameMaxRunes = 120 )
「高级选项」各项的长度上限(按字符,不是字节)。
const ( // BoardDigestMaxSeqs 是每一类最多列出的任务编号个数。 BoardDigestMaxSeqs = 5 // BoardDigestStaleDefault 是指派派出后多久没人接算「久无人接」的默认值(B3d 起可以在设置里改)。 BoardDigestStaleDefault = 2 * time.Hour )
const ( // WorkSearchDefaultLimit / WorkSearchMaxLimit 是检索结果一页的条数。 WorkSearchDefaultLimit = 50 WorkSearchMaxLimit = 100 )
const ( WorkSnippetDescription = "description" WorkSnippetProgress = "progress" WorkSnippetConclusion = "conclusion" WorkSnippetLabels = "labels" WorkSnippetModule = "module" WorkSnippetWorkflow = "workflow" )
命中片段来自任务的哪一栏(SnippetField 的取值)。标题命中不出片段:标题本来就显示着。
const ( WorkflowHostOpSet = "set" WorkflowHostOpClear = "clear" )
const ( // DefaultTrashRetentionDays 是回收站默认的保留天数;环境变量 TrashRetentionEnv(1–MaxTrashRetentionDays)可以改。 DefaultTrashRetentionDays = 30 MaxTrashRetentionDays = 365 TrashRetentionEnv = "RELAYMESH_TRASH_RETENTION_DAYS" )
const (
// AgentNameMaxRunes 是身份改名的最大长度。
AgentNameMaxRunes = 80
)
const AnsweredNagWindow = 7 * 24 * time.Hour
AnsweredNagWindow 是反向提醒的回看范围:只看最近这段时间内被答复的确认卡,更早的答复还没人处理,多半是有意搁置。
const BoardStaleMaxGroupsPerScan = 5
BoardStaleMaxGroupsPerScan 是一次扫描最多发出的提醒条数(一条 = 一块任务板上的一个承接者)。 一口气有很多承接者同时到点(例如刚升级、或关掉提醒很久后又打开)时,每一遍只处理前几条,其余留给下一遍, 不会一下子弹出一屏通知。
const BranchAgentStateStalled = "stalled"
BranchAgentStateStalled 是分支的智能体在工作却久无动静(卡住)时的状态:与网页状态芯片的优先级一致,卡住盖过其他展示态。
const BranchAgentStateUnknown = "unknown"
BranchAgentStateUnknown 是分支还没有任何智能体会话(hook 从未汇报过)时的状态。
const BranchPrefsKey = "branch.prefs"
BranchPrefsKey 是分支全局偏好在 system_settings 表里的键,值是 JSON(见 model.BranchPrefs)。 只新增键、不改表结构;旧版本二进制不认识这个键,会直接忽略它。
const ( // CapabilityTokenPrefix 是能力 URL 凭据令牌的专用前缀:只有这一类凭据使用它,普通凭据不得使用。 // 固定前缀与固定长度也让服务端能在查库之前就丢弃形状不对的路径,随手乱填的网址不会产生数据库访问。 CapabilityTokenPrefix = "rmc-" )
const ConversationReadEpochKey = "conversation_read_epoch_ms"
ConversationReadEpochKey 是「已读纪元」的设置键:聊天功能上线(第一次用到)的时刻。 纪元之前发的消息一律算已读——否则上线当天每个工作流都会冒出几百条「未读」。
const DefaultAgentModesContent = `` /* 2911-byte string literal not displayed */
const DefaultAgentModesSummary = "会话场景模式 playbook(online 值守 / away 安全兜底 / autopilot 外部编排)+ Phase 0-7 开发工作流。"
const DefaultServerInstructions = `【RelayMesh 智能体协同中枢内生治理指引】
RelayMesh 是本工作区唯一的权威人机交互、多智能体协同与研发生命周期中枢。当连接到 RelayMesh 时,请严格遵循以下行为指引:
1. 简体中文自然表达规范:
- 涉及中文的一切输出(对话、提问、方案、代码变更总结、文档、提交信息与会话记录)默认保持语义流畅、自然通顺、结构清晰,杜绝电报式省略与生硬符号串堆砌。
2. 工程思维与推理纪律(C-PLAN / C-RT):
- 目标是系统整体质量与长期可维护性,杜绝以「改动最少/最快」为由采取局部最优或临时打补丁方案;
- 触发门槛:面对「多步 / 跨模块 / 不可逆 / 新建系统 / 影响面大」的任务,编码前必须进行系统性方案推演:
• C-PLAN:决策确认 → 问题拆解 → 数据流与状态 → 不变量 → 边界与异常 → 影响面 → 备选方案(≥2) → 验收标准;
• C-RT:反向自检反驳(哪最幼稚?什么输入会崩溃?漏了哪个边界?是否属于局部最优?),命中立即修正;
- 改前先读代码与架构规范,改动接口与类型时全量检查所有引用方。
3. RelayMesh 交互与沟通主载体契约:
- 方案提出、提问请示、歧义澄清、阶段汇报与任务最终总结,必须统一通过 RelayMesh 的 interactive_feedback 工具进行,严禁直接在普通 chat 正文提问或等待确认;
- 核心入参铁律(严禁颠倒/篡改):
• workflow_id (必填): 必须原样继承本会话法定工作流标识,严禁随意编造新名称或遗漏;
• title (单行短标题): 仅限 5~15 字概括,严禁将 Markdown 正文放入 title;
• summary (详尽正文): 必须放入完整的 Markdown 分析、推演、方案或代码汇报,严禁只填一句话短标题;
- 收到 === 等待回执 === 时,严格按回执指令调用 AwaitShell 等待并随后调用 continue_feedback_session 轮询,等待期间严禁输出 chat 正文、严禁调用其他工具、严禁擅自总结;
- 收到 === 用户反馈 === 时,方可作为用户的权威输入继续推进。
` + phaseSection + `
` + irreversibleSection + `
6. 场景模式与内置规范(agent-modes):
- 系统内置 agent-modes 场景模式规范(online 在线值守 / away 安全兜底 / autopilot 外部编排);可通过 manage_skills(action: "get", name: "agent-modes") 获取完整行为准则。
7. 会话状态与文档自适应策略(Workflow Sheet):
- 为避免上下文压缩丢失目标与关键决策,根据工作区环境自适应选择存储载体:
• 场景 A:若项目根目录存在 .cursor/sessions/ 规范,按该规范维护本地会话文档;
• 场景 B:遵守当前项目文档规范(如项目自有 docs/ 规范体系);
• 场景 C:若项目无本地会话文档体系,统一调用 RelayMesh 内置 workflow_context(action: "session_doc_save", workflow_id: "...", content: "...") 将会话文档与关键决策持久化至中枢工作表(Workflow Sheet),并可通过 workflow_context(action: "session_doc_get") 检索恢复。
8. 上下文获取与跨项目边界隔离(D-165):
- 主机名 (HostName) 由连接凭据权威锁定,项目目录 (project_directory) 由大模型主动传递;
- 凡调用 list_sessions 或 workflow_context(action: 'list_workflows') 获取上下文,必须传递 project_directory,系统严格限定在当前 (HostName, ProjectDirectory) 边界内,杜绝跨项目与跨主机污染;
- 仅当人工明确指定特定 workflow_id 时,才允许跨目录读取该指定工作流的会话历史。
9. 交付锚点(可选,用于定位信息的陈旧性):
- 项目目录是 git 仓库时,调用 interactive_feedback 可把 git log -1 --format='%h %s' 的单行输出放进 commit 参数,时间由服务端记录;不是 git 仓库时省略;
- 回执响应头的 anchor 行是本工作流最近一次交付锚点;上下文被重置后,据此用 git log <哈希>..HEAD 与 git status 核对期间发生了什么;
- 保存恢复胶囊(checkpoint_save)时可省略 basis.git_commit,服务端会取最近一次交付锚点并把胶囊关联到那次交付。`
const EmbeddingConfigKey = "search_semantic_config"
EmbeddingConfigKey 是语义检索配置在 system_settings 表里的键,值是 JSON(见 embedding.Config,不含密钥)。
它独立于全局设置(GlobalSettingsKey):全局设置会整体返回给浏览器。密钥不在这里,在 embed_credentials 表。
const GuardPromptUnsafe = "`$\\;&|<>(){}[]'\"!*?~#"
GuardPromptUnsafe 是唤醒提示词里不允许出现的字符:它们在 shell 里有特殊含义。
提示词本该输入到智能体的对话框;但万一那时 Cursor CLI 已经退出、会话停在普通的命令行里,输入的内容会被 shell 解释。 所以只允许「在 shell 里只是普通文字」的字符——中文标点、字母、数字、空格、% 都没问题。 提示词的开头由服务端固定为「【系统唤醒 …】」,第一个词因此也不会是任何命令。
const GuiWakeTargetsKey = "gui_wake_targets"
GuiWakeTargetsKey 是目标配置在 system_settings 表里的键,值是 JSON(见 GuiWakeConfig)。
const HeadlessOriginEnableAgent = "enable_agent"
HeadlessOriginEnableAgent 是 HeadlessRun.Origin 的取值:这条预设是会话页「启用 Agent」自动建的。
const HookSeenPersistEvery = time.Minute
HookSeenPersistEvery 是同一个工作流的 hook 时间落库的最小间隔:落库值最多比真实值旧这么久。 重启后恢复出来的值只会偏旧、不会偏新,对 60 分钟的新鲜度窗口可以忽略,方向也是安全的。
const InboxConfigKey = "inbox_config"
InboxConfigKey 是收件箱开关在 system_settings 表里的键,值是 JSON(见 InboxConfig)。
const InboxHookSeenBroadcastEvery = time.Minute
InboxHookSeenBroadcastEvery 是 hook 查询触发 Web 刷新的最小间隔:hook 每隔十几秒就会问一次, 没必要每次都让所有打开的页面重新拉取。
const InboxSessionIDPrefix = "inbox-"
InboxSessionIDPrefix:收件箱里的图片对外用 inbox-<编号> 当作「会话编号」寻址, 这样 get_session_image 与 /sessions/:id/images/:index 不用新增一套接口就能取到追加里的图片。
const JWTSecretKey = "jwt_secret"
JWTSecretKey 是自动生成的 JWT 签名密钥在 system_settings 表中的键。
安全约束:该键不属于任何对外接口返回的设置集合(GetSettings 只读取 app_settings,标题类查询按 key 前缀过滤), 也不得被列出、导出或写入日志。新增「枚举全部 system_settings」的代码前必须先排除该键。
const LostDismissalKeepDays = 90
LostDismissalKeepDays:忽略记录保留多久。守护进程自己也会淘汰很久以前的丢失会话, 过了这么久还没从主机的上报里消失的条目极少,宁可让它重新提醒一次,也不让这张表无限增长。
const MaxSSHHosts = 50
MaxSSHHosts 是可登记的 SSH 主机数量上限:每台主机都可能占用连接与轮询资源,上限防止被灌满。
const MaxTerminalArchives = 5000
MaxTerminalArchives 是归档记录的总数上限。超过时丢弃最早归档的几条: 代价只是对应的条目重新出现在侧栏里,不会丢任何会话、记录或审计。
const NotifyPrefsKey = "notify.prefs"
NotifyPrefsKey 是通知偏好在 system_settings 表里的键,值是 JSON(见 notify.Prefs)。 只新增键、不改表结构;旧版本二进制不认识这个键,会直接忽略它。
const NtfyConfigKey = "ntfy_config"
NtfyConfigKey 是 ntfy 推送配置在 system_settings 表里的键,值是 JSON(见 ntfy.Config,含访问令牌 / 密码)。
它独立于全局设置(GlobalSettingsKey):全局设置会整体返回给浏览器,而这里的凭据只许写、不许读。
const (
OAuthClientMax = 200
)
const PendingBranchAsksMax = 50
PendingBranchAsksMax 是回执头 / branch list 里一次最多列出的待定夺请示条数。
const RetractionEventsMax = 20
RetractionEventsMax 是历史查询里最多给几条撤回记录(取最近的)。
const SQLTraceEnv = "RELAYMESH_SQL_TRACE"
SQLTraceEnv 是开启 SQL 追踪的环境变量名(只在实验与排查里用,默认关闭,生产不设)。
设置为一个文件路径后,Store 执行的每一条 SQL 都以一行 JSON 追加写入该文件:开始时间、耗时(毫秒)、行数、报错与 SQL 原文 (绑定值已代入;超过 sqlTraceMaxLen 的部分截断,免得把整段汇报正文写进去)。配套的离线分析工具是 scripts/dev/explain-audit: 把真实页面加载(跑浏览器套件)时发出的 SQL 按「形状」归并、统计次数与耗时,再逐个形状做 EXPLAIN QUERY PLAN,找全表扫描与临时排序(#177)。
注意:文件里是真实数据的片段,只用于临时库;不要对着含真实内容的库长期打开,用完删除。
const SemanticChatSegment = 200
SemanticChatSegment 是一段群消息的条数。消息发出后不可改,所以写满的段版本戳恒定,只有最后一段随新消息变化。
const SemanticRunKey = "search_semantic_run"
SemanticRunKey 是语义检索运行设置在 system_settings 里的键(值是 JSON,见 SemanticRun)。
const (
// SettingTerminalExecPaused 为 "1" 时全局暂停一切模型运行(G5 的全局开关,重启后保持)。
SettingTerminalExecPaused = "terminal_exec_paused"
)
系统开关(system_settings 键值表)里保存的终端相关键。
const ShelveNagWindow = 24 * time.Hour
ShelveNagWindow 是「刚暂缓」的时间范围:只提醒最近这段时间内置的暂缓,历史上早已搁置的任务不翻旧账。
const SidebarOrderKey = "ui.sidebar_order"
SidebarOrderKey 是侧栏手动顺序在 system_settings 表里的键,值是 JSON(见 SidebarOrder)。
const SidebarOrderMaxKeys = 5000
SidebarOrderMaxKeys 是键表的键数上限(与前端 SIDEBAR_ORDER_MAX_KEYS 一致)。
const TerminalGuardStateKey = "terminal_guard_state"
TerminalGuardStateKey 是守护状态在 system_settings 表里的键,值是 JSON(见 GuardStateDoc)。
const TerminalLaunchersKey = "terminal_launchers"
TerminalLaunchersKey 是启动器预设在 system_settings 表里的键,值是 JSON(见 terminalLauncherDoc)。
const TerminalPrefsKey = "terminal_prefs"
TerminalPrefsKey 是终端偏好在 system_settings 表里的键,值是 JSON(见 TerminalPrefs)。
const TypingFreshness = 10 * time.Second
TypingFreshness 超过这个间隔没有新的心跳就算停手了。
const WebPlaceholderSessionPrefix = "sess-web-"
WebPlaceholderSessionPrefix 是网页新建会话时占位会话行的编号前缀。
const WebWorkflowTitleMaxRunes = 80
WebWorkflowTitleMaxRunes 是网页新建会话时名字的最大字符数(按字符,不是字节)。
const WindowsCmdHazards = "\"%^&|<>!"
WindowsCmdHazards 是 cmd.exe 会当成语法的字符:它们不能出现在 Windows 的目录与可执行文件路径里。
const WorkflowHostOverridePrefix = "wf_host_override:"
WorkflowHostOverridePrefix 是主机覆盖在 system_settings 里的键前缀。
const WorkflowUpdatesMax = 100
WorkflowUpdatesMax 是一次最多返回的进展条数:会话里只看最近的,更早的去任务页看。
Variables ¶
var ( // ErrArchiveBaselineMissing:没有这条基线,或它不属于这把令牌 / 这个项目(两种情况对调用方不作区分,避免成为「编号是否存在」的探针)。 ErrArchiveBaselineMissing = errors.New("archive baseline: not found") // ErrArchiveBaselineExpired:基线是这把令牌在这个项目里登记的,但已超过保留期。 ErrArchiveBaselineExpired = errors.New("archive baseline: expired") )
var ( // ErrInvalidLauncher 表示预设的某个字段不合法;错误信息可以直接展示给用户。 ErrInvalidLauncher = errors.New("终端启动预设不合法") // ErrLauncherLimit 表示预设数量已到上限,不能再新增(修改已有的不受影响)。 ErrLauncherLimit = errors.New("终端启动预设数量已到上限") // ErrLauncherNotFound 表示要删除的预设不存在(可能已在别的浏览器里删掉了)。 ErrLauncherNotFound = errors.New("终端启动预设不存在") )
var ErrInvalidGuiWake = errors.New("GUI 唤醒目标配置不合法")
ErrInvalidGuiWake 表示 GUI 唤醒的目标配置不合法;错误信息可以直接展示给用户。
var ErrInvalidSidebarOrder = errors.New("侧栏顺序不合法")
ErrInvalidSidebarOrder 表示提交的键表形状不对(前缀、长度、重复、总数)。校验类错误,调用方应当回 400。
var ErrInvalidTerminalPrefs = errors.New("终端偏好取值不合法")
ErrInvalidTerminalPrefs 表示偏好的取值超出范围;错误信息可以直接展示给用户。
var ErrSSHHostLimit = errors.New("ssh host limit reached")
ErrSSHHostLimit 表示 SSH 主机数量已达上限。
var ErrSidebarOrderConflict = errors.New("侧栏顺序版本冲突")
ErrSidebarOrderConflict 表示 base_version 与库里当前的版本不一致(别的设备已经写过了)。
var ErrTerminalHostExists = errors.New("terminal host already exists")
ErrTerminalHostExists 表示该机器码已存在记录(同一公钥)。
var ErrTerminalHostNotFound = errors.New("terminal host not found")
ErrTerminalHostNotFound 表示记录不存在。
var ErrTerminalKeyMismatch = errors.New("terminal host public key mismatch")
ErrTerminalKeyMismatch 表示同一机器码对应的已存公钥与传入公钥不一致(不应发生,发生即拒绝)。
var PageSearchWired = []string{"work_items"}
PageSearchWired 是已经接入「走全文索引」的页面(设置页据此如实说明哪些页面受这个开关影响)。 每个阶段接入一个页面就在这里加一项:work_items = 任务页;docs = 文档;conversation = 会话与群聊的搜索面板。
var SearchKinds = []string{SearchKindDoc, SearchKindTask, SearchKindConfirm, SearchKindSession, SearchKindMessage, SearchKindChat}
SearchKinds 是全部类型,也是默认的查询范围与结果里的展示顺序。
Functions ¶
func ArchiveBaselineExpiresAt ¶ added in v2.2.0
func ArchiveBaselineExpiresAt(b *model.ArchiveBaseline) time.Time
ArchiveBaselineExpiresAt 是一条基线的到期时刻。
func BackfillPhasePrompts ¶
BackfillPhasePrompts fills in missing Prompt fields from DefaultPhaseTemplate.
func ClaimStateLabel ¶
ClaimStateLabel 是接取状态的中文名;空串 = 未指派。
func ClassifyLauncherExec ¶
ClassifyLauncherExec 判断启动命令能否用 exec 启动;可以时返回包装后的 exec 片段(不含 cd)。
func CredentialArchiveError ¶ added in v2.2.0
func CredentialArchiveError(c *model.MCPCredential) error
CredentialArchiveError 在凭据打开了「项目归档导出」位却没有任何允许导出的项目时返回错误: 这一位没有「默认全部项目」的含义(那等于把整个 Hub 的过程信息交出去),名单为空就等于没有范围,不允许保存。
func CredentialFilesError ¶
func CredentialFilesError(c *model.MCPCredential) error
CredentialFilesError 在凭据打开了文件权限位却没有任何访问范围时返回错误。 文件权限没有「默认全部可访问」的含义:既不指定目录、也没有明确开启「允许整个文件系统」,就等于没有范围, 不允许保存这样的组合。「允许整个文件系统」只能由 allow_whole_fs 显式打开——在 allowed_paths 里写 `/` 仍然被拒绝(见 NormalizeAllowedPaths),免得一个手误就等于不设防。
func CredentialTerminalTokenError ¶
func CredentialTerminalTokenError(c *model.MCPCredential) error
CredentialTerminalTokenError 在凭据带终端权限、「运行预设」权限或「项目归档导出」权限而令牌强度不足时返回错误。 终端权限等价于远程代码执行,「运行预设」让一个智能体去唤醒另一个智能体(#179),「项目归档导出」能把整个项目的过程信息一次取走(#272), 令牌都必须不可猜;服务端自动生成的令牌始终合格。
func DraftReferencedKeys ¶
DraftReferencedKeys 解析草稿 JSON,返回它引用的全部图片内容键(解析失败按「没有引用」处理)。
func GenerateCapabilityToken ¶
GenerateCapabilityToken 生成能力 URL 凭据的令牌:专用前缀 + 32 字节随机数的十六进制。
func GenerateHiddenCredentialToken ¶
GenerateHiddenCredentialToken 生成隐藏 OAuth 凭据的内部占位令牌(高熵、永不对外返回、不可作 MCP Bearer)。
func GenerateToken ¶
func GroupErrorCode ¶
GroupErrorCode 取出错误里的群聊错误码;不是群聊错误时 ok 为 false。
func HashOAuthToken ¶
func HostDefaultState ¶
HostDefaultState 把库里的默认态归一成 allow / deny(空串等价于 deny)。
func InboxPreview ¶
func InboxPreview(q model.QueuedFeedback) string
InboxPreview 是一条追加的单行预览:折叠空白、截断到 InboxPreviewRunes 个字符;只有图片时注明张数。 智能体在回执里看到的正文就是 ResponseText(快捷标签只用于界面展示),所以预览也以它为准,没有正文时才退回到标签。
func IsBoardPinned ¶ added in v2.2.0
IsBoardPinned 判断归板原因代码是不是「被已有任务 / 规划节点钉住」。
func IsCapabilityTokenShape ¶
IsCapabilityTokenShape 判断字符串是否具有能力 URL 令牌的形状(前缀 + 64 位小写十六进制)。 它只是廉价的形状检查,不代表令牌有效。
func IsHeadlessPrefixCmd ¶
IsHeadlessPrefixCmd 判断一个词是不是 shell 内建或会改变后面命令含义的前缀命令(cd、env、sudo、bash……): 非交互运行的第一个词必须是可执行文件本身,不能是它们。
func IsSearchUnavailable ¶ added in v2.2.0
IsSearchUnavailable 报告 err 是否是「全文索引不可用」。
func IsWebPlaceholderSessionID ¶
IsWebPlaceholderSessionID 判断一个会话编号是不是网页新建会话时落下的占位行。
func IsWindowsAbsPath ¶ added in v2.1.0
IsWindowsAbsPath 判断一个路径是不是 Windows 的绝对路径:盘符(C:\work、C:/work)或 UNC(\\服务器\共享\…)。
func NormalizeAllowedCIDRs ¶
func NormalizeAllowedCIDRs(in []string) (model.StringList, error)
NormalizeAllowedCIDRs 校验来源白名单;每项可以是 CIDR 或单个 IP,单个 IP 保持原样。
func NormalizeAllowedPaths ¶
NormalizeAllowedPaths 校验并归一化文件工具的允许目录:去空白、去重、限条数与长度,写法必须是明确的绝对路径 (见 termproto.RootProblem)。文件系统根目录、相对路径、含 .. 的写法一律拒绝——这是一条强制的访问边界, 不接受含糊的写法。
func NormalizeArchiveProjects ¶ added in v2.2.0
NormalizeArchiveProjects 校验并归一化凭据允许导出归档的项目编号:必须是正整数,去重、升序,条数有上限。 项目是否真实存在由 API 层在保存时另行校验(这里没有项目表的依赖);运行时再核一遍项目仍然存在。
func NormalizeConfirmOptions ¶
func NormalizeConfirmOptions(in []model.ConfirmOption) ([]model.ConfirmOption, error)
NormalizeConfirmOptions 校验并规整选项:2~8 个,id 非空唯一,文案非空,各字段限长。
func NormalizeModulePath ¶
NormalizeModulePath 规整模块路径:用 / 分隔、最多 8 层、每层 ≤ 64 个字符,不允许 . / .. 段与路径里的危险字符。
func NormalizePromptText ¶ added in v2.1.0
NormalizePromptText 把用户写的提示词整理成存库的形态:统一换行为 \n、去掉除换行与制表符外的控制字符、去掉首尾空白, 并检查字数上限(按字符计)。空串合法,表示清除。
func NormalizeReplyHash ¶
NormalizeReplyHash 把用户写的哈希整理成小写十六进制:容忍大小写、前后空白和多写的 sess- 前缀; 不合法(太短、太长、含非十六进制字符)返回空串。这也保证了拼进 LIKE 的内容里没有通配符。
func NormalizeSemanticKinds ¶ added in v2.2.0
NormalizeSemanticKinds 只留合法类型,按 SearchKinds 的顺序去重;不认识的类型返回错误。
func NormalizeTerminalHosts ¶
func NormalizeTerminalHosts(in []string) (model.StringList, error)
NormalizeTerminalHosts 去重、裁剪并校验机器码列表;包含 "*" 时折叠为 ["*"]。
func NormalizeWakeTemplate ¶ added in v2.1.0
func NormalizeWakeTemplate(kind sessionprompt.Kind, text string) (string, error)
NormalizeWakeTemplate 把用户写的某类模板整理成存库的形态并检查:字数上限; 新开对话与网页启动提示词是给「还不认识这个工作流」的智能体看的,必须带 %workflow,否则它接不进来。 空串合法(= 清除,回到下一层)。
func NormalizeWebFirstMessage ¶
NormalizeWebFirstMessage 规整网页新建会话时写的首条指令:去首尾空白(正文里的换行原样保留);空串表示没有首条指令; 含 NUL 或超过 WebWorkflowFirstMessageMaxRunes 个字符的拒绝。
func NormalizeWebHostName ¶
NormalizeWebHostName 规整网页新建会话时填的主机名(会话的归属标签):折成单行;空串表示不指定(沿用全局设置 / 环境变量); 超过 WebWorkflowHostNameMaxRunes 个字符的拒绝。
func NormalizeWebPhase ¶
NormalizeWebPhase 规整网页新建会话时选的起始阶段:空串表示不指定(沿用默认阶段); 只接受 discuss / plan / dev,旧五段式的编号(assess / verify / done)换算成对应的新编号后接受;其它拒绝。
func NormalizeWebProjectDirectory ¶
NormalizeWebProjectDirectory 规整网页新建会话时填的项目目录:空串表示不绑定(返回 ""); 否则必须是绝对路径——POSIX 的 /…,Windows 的 X:\… 或 X:/…,以及 \\服务器\共享\…——不含控制字符,不超过 WebWorkflowProjectDirMaxRunes 个字符。
规整只做「不会改变含义」的那部分:POSIX 路径做 path.Clean(多余的 /、. 与 ..、末尾 /);Windows 路径只去掉末尾分隔符 (盘符根 C:\ 保留),不改大小写、不换分隔符。原因:D-161 比较的是字符串,智能体按启动提示词把这个值原样回填,两边才会一致。
func NormalizeWebWorkflowTitle ¶
NormalizeWebWorkflowTitle 规整网页新建会话时填的名字:空白与控制字符(含换行、制表)一律折成一个空格, 不可见的格式字符(零宽空格之类)直接丢掉,去掉首尾空白;规整后为空,或超过 WebWorkflowTitleMaxRunes 个字符的拒绝。
func NormalizeWorkLabels ¶
NormalizeWorkLabels 去空白、去重(不区分大小写)并校验数量与长度。
func NormalizeWorkRefs ¶
NormalizeWorkRefs 去空白、去重并校验数量与长度。引用是自由文本:提交(commit:abc1234)、决策(D-201)、文件路径、文档链接都可以。
func PageDiagKeepFor ¶ added in v2.2.0
PageDiagKeepFor 返回某个 kind 所在那一类的保留条数。
func ParseArchiveProjects ¶ added in v2.2.0
ParseArchiveProjects 把更新请求里的 archive_projects(JSON 数组)解析并归一化成项目编号名单。 API 层用它在保存前取得名单,核对每个项目是否真实存在(store 一侧没有项目表的依赖,只在运行时再核一遍)。
func ParseBoardKey ¶
ParseBoardKey 拆开 board_key:项目板返回 projectID,独立板返回 workflowID;不合法返回 ok=false。
func ParseInboxSessionID ¶
ParseInboxSessionID 反过来解析;不是 inbox-<数字> 时 ok 为 false。
func ParseSemanticChatRef ¶ added in v2.2.0
ParseSemanticChatRef 拆开群消息段的 ref:"<会话 ID>/<段号>"。
func SanitizeCredentialUpdates ¶
SanitizeCredentialUpdates 校验并归一化 REST 传入的凭据更新,返回可直接交给 GORM 的 map。
func SemanticKeyOf ¶ added in v2.2.0
SemanticKeyOf 是 SemanticVisible 结果里用的键。
func ShelveExplained ¶ added in v2.1.0
ShelveExplained 判断一个暂缓任务有没有写明缘由:进展 / 引用里带确认卡编号(Q<N>),或写了「等…」, 或已经有结论(说明是收尾性的搁置,不是在等谁)。
func SlugifyProjectName ¶
SlugifyProjectName 把项目名转成建议的 slug:小写字母数字与连字符;转不出来(比如全是汉字)就返回空串。
func TrashRetentionDays ¶ added in v2.2.0
func TrashRetentionDays() int
TrashRetentionDays 返回当前生效的保留天数。
func ValidHeadlessBin ¶ added in v2.1.0
ValidHeadlessBin 判断可执行文件的写法是否合法,不分主机系统(预设保存时用):POSIX 的命令名或路径(一直以来的规则), 或 Windows 的命令名、盘符 / UNC 路径。不管哪种,都不能是 cd、env、sudo、bash 这类前缀命令,也不能是 cmd / powershell 这类 shell。
func ValidWindowsBin ¶ added in v2.1.0
ValidWindowsBin 判断一个可执行文件的写法能不能用在 Windows 主机上:命令名(agent、agent.cmd),或盘符 / UNC 绝对路径 (路径里可以有空格,如 C:\Users\张三\AppData\Local\cursor-agent\agent.cmd)。不能是 shell,路径里没有 cmd 语法字符。
func ValidateCredentialTerminal ¶
func ValidateCredentialTerminal(c *model.MCPCredential) error
ValidateCredentialTerminal 校验并就地归一化一条完整凭据的终端相关字段(创建时调用)。
func ValidateHostDefaultForNewModels ¶
ValidateHostDefaultForNewModels 校验默认态取值:空串或 deny 表示不预先授予,allow 表示预先授予。
func ValidateHostExecMode ¶
ValidateHostExecMode 校验主机的执行模式(空串等价于 auto)。
func ValidatePathReference ¶
func ValidatePathReference(ref model.PathReference) error
func ValidatePathReferences ¶
func ValidatePathReferences(refs []model.PathReference) error
func ValidateSegments ¶
func ValidateSidebarOrderKeys ¶ added in v2.2.0
ValidateSidebarOrderKeys 检查一张键表的形状:不超过上限、每个键以允许的前缀开头且前缀之后非空、不超长、是合法 UTF-8、 没有控制字符、没有重复。返回的错误都包装了 ErrInvalidSidebarOrder。
func ValidateTerminalLimits ¶
func ValidateTerminalLimits(l model.TerminalLimits) (model.TerminalLimits, error)
ValidateTerminalLimits 校验令牌级限额(全部为零表示不设限,合法)。 AllowWholeFS 开启时 AllowedPaths 照常校验并保留(关闭开关后恢复为目录限制,永远不会比管理员显式配置的更宽), 但它们不起作用,运行时一律以 AllowWholeFS 为准。
func ValidateTerminalModeCap ¶
ValidateTerminalModeCap 校验令牌的执行模式上限。
func WebWorkflowStartPrompt ¶
WebWorkflowStartPrompt 是交给用户、由用户转发给智能体的「启动提示词」。 关键信息只有三条:带上这个 workflow_id、目录填自己当前的工作区(用户在「高级选项」里绑定了项目目录时,改成原样填那个目录, 否则 D-161 会把它挡在门外)、接入后先取用户留下的第一条指令(回执里带回来的,或收件箱里的)。projectDir 为空 = 没绑定。
func WindowsPathProblem ¶ added in v2.1.0
WindowsPathProblem 检查一个 Windows 路径里有没有不该出现的字符;没问题返回空串,有就返回一句话(可直接接在「目录」「可执行文件」后面)。 它不判断是不是绝对路径(见 IsWindowsAbsPath)。
func WorkItemListLimit ¶
WorkItemListLimit 是任务清单一次最多返回多少条:调用方没指定(或指定得不合理、超过 1000)就取默认的 500。 清单按最近更新从新到旧取前这么多条;REST 拿它判断清单是不是被截断了(顶到上限 = 更早更新的可能被略去), 这样页面能如实说明,而不是悄悄少显示。
func WorkStateLabel ¶
WorkStateLabel 返回状态的中文名(与界面一致);未知值原样返回。
func WorkflowBoardKey ¶
WorkflowBoardKey 返回工作流独立板的 key。
Types ¶
type AgentEvent ¶
AgentEvent 是 hook 汇报的一次事件。字段都由调用方自报,入库前统一清洗(见 NormalizeAgentEvent)。
func NormalizeAgentEvent ¶
func NormalizeAgentEvent(ev AgentEvent) (AgentEvent, bool)
NormalizeAgentEvent 清洗 hook 自报的事件:种类只认 tool / stop;状态只认 completed / aborted / error(其余记为 other, 只在 stop 事件里有意义);对话编号只认字母数字、下划线、连字符,最长 64 位,格式不对就当没有。返回 ok=false 表示没有可记的内容。
type AgentIdentityView ¶
type AgentIdentityView struct {
ID uint `json:"id"`
CredentialID uint `json:"credential_id"`
HostName string `json:"host_name"`
ProjectDirectory string `json:"project_directory"`
Name string `json:"name"`
DirectoryName string `json:"directory_name"`
Label string `json:"label"`
LabelDegraded bool `json:"label_degraded"`
ClientKind string `json:"client_kind,omitempty"`
CursorVersion string `json:"cursor_version,omitempty"`
FirstSeenAt time.Time `json:"first_seen_at"`
LastSeenAt time.Time `json:"last_seen_at"`
LastHookAt *time.Time `json:"last_hook_at,omitempty"`
LastMCPAt *time.Time `json:"last_mcp_at,omitempty"`
LastQueryAt *time.Time `json:"last_query_at,omitempty"`
}
AgentIdentityView 是对外的身份视图。
type AgentIngestInput ¶
type AgentIngestInput struct {
WorkflowID string
CredentialID uint
HostName string // 连接凭据 / 请求锁定的主机名;空就用工作流上记录的绑定
ProjectDirectory string // 调用方自报的项目目录;空就用工作流上记录的绑定
ConversationID string
ClientKind string
CursorVersion string
Event agentstate.Event
// Latest 为 true 表示「记到这个工作流最近活动的那个会话上」:Hub 自己产生的事件(托管终端的屏幕扫描器)不知道
// 对话 ID、凭据,也不该凭空造出一个新身份。找不到可归属的会话就什么都不记(res.IdentityID 为 0)。
Latest bool
// Conversation 为 true 表示「记到这个工作流里 ConversationID 这个对话的会话上」(不管它有没有结束):
// Hub 读到非交互运行的输出时清楚自己在续哪个对话——最近活动的会话可能是另一个,这个对话也可能刚被 hook 记成了 ended。
// 同样不造新身份:这个对话还没有任何 hook 汇报过,就什么都不记(res.IdentityID 为 0)。
Conversation bool
}
AgentIngestInput 是一次汇报(hook 事件,或 Hub 自己产生的事件)。
type AgentIngestResult ¶
type AgentIngestResult struct {
IdentityID uint
SessionID uint
NewSession bool
Change agentstate.Change
Snapshot agentstate.Snapshot
}
AgentIngestResult 是 IngestAgentEvent 的结果。IdentityID 为 0 表示认不出身份(没有项目目录),什么都没记。
type AgentLink ¶
type AgentLink struct {
ConversationID string // Cursor 对话编号(用于重新拉起时恢复同一个对话);未知时为空
LastToolAt time.Time // 最近一次工具调用结束的时间(零值 = 没汇报过)
StopAt time.Time // 最近一轮对话结束的时间(零值 = 没汇报过)
StopStatus string // 那一轮的结束状态;StopAt 为零值时为空
}
AgentLink 是某个工作流的智能体最近的运行情况。
type AgentLiveState ¶
type AgentLiveState string
AgentLiveState 是顶栏存活图标的结论。
const ( AgentLiveRunning AgentLiveState = "running" AgentLiveIdle AgentLiveState = "idle" AgentLiveQuiet AgentLiveState = "quiet" AgentLiveUnknown AgentLiveState = "unknown" )
type AgentLiveView ¶
type AgentLiveView struct {
State AgentLiveState `json:"state"`
Reason string `json:"reason,omitempty"`
At *time.Time `json:"at,omitempty"`
}
AgentLiveView 供 GET /workflows/:id/inbox 与前端使用。
func ComputeAgentLive ¶
func ComputeAgentLive(link AgentLink, hookAt time.Time, hookOK bool, sess *model.FeedbackSession, now time.Time) AgentLiveView
ComputeAgentLive 根据 hook 痕迹、智能体汇报与会话状态推断顶栏图标档位(纯函数)。
type AgentScreenChange ¶
type AgentScreenChange struct {
ApprovalStarted bool // 刚进入审批等待
ApprovalEnded bool // 审批等待刚结束(批准、跳过或中断)
Approval bool // 当前是否在审批等待
}
AgentScreenChange 描述一次上报带来的变化,供调用方决定要不要产生状态事件与通知。
type AgentScreenInput ¶
type AgentScreenInput struct {
Verified bool // cursor 版本在已验证清单里;false 时只展示「未识别」,不参与任何判断
Recognized bool // 守护进程认出了 TUI(Screen 非空)
CursorVersion string // 判断 Verified 所用的版本,仅展示
Word string
Tokens int // -1 = 没读到
CtxPct float64 // -1 = 没读到
Animating bool
Approval bool
Cancelled bool
QuietSeconds int // 上报时距最后一次输出的秒数;-1 = 不知道
}
AgentScreenInput 是一次屏幕上报(已按版本闸门判断过 Verified)。
type AgentScreenView ¶
type AgentScreenView struct {
TUI string // "ok"(版本已验证)| "unrecognized"(版本未验证或画面认不出)
Word string // 状态行动词,仅在动画中有值
Tokens int // -1 = 没读到
TokensSrc string // 有 Tokens 时为 "tui"
CtxPct float64 // -1 = 没读到
Approval bool
Animating bool
ReceivedAt time.Time
// contains filtered or unexported fields
}
AgentScreenView 是对外展示的屏幕信号。
type AgentSearchAccess ¶ added in v2.2.0
AgentSearchAccess 是两个开关的当前值。
func DefaultAgentSearchAccess ¶ added in v2.2.0
func DefaultAgentSearchAccess() AgentSearchAccess
DefaultAgentSearchAccess 是没设过时的值:全文开、语义关。
type AgentSearchQuota ¶ added in v2.2.0
type AgentSearchQuota struct {
KeywordPerMinute int `json:"keyword_per_minute"`
SemanticPerMinute int `json:"semantic_per_minute"`
SemanticGlobalPerMinute int `json:"semantic_global_per_minute"`
}
AgentSearchQuota 是三个额度的当前值(次 / 分钟)。
func DefaultAgentSearchQuota ¶ added in v2.2.0
func DefaultAgentSearchQuota() AgentSearchQuota
DefaultAgentSearchQuota 是没改过时的值:60 / 6 / 30。
func (AgentSearchQuota) Validate ¶ added in v2.2.0
func (q AgentSearchQuota) Validate() error
Validate 检查三项都在范围内,且语义合计不小于单个令牌的额度(合计比单个令牌还少,单个令牌的额度就永远用不满)。
type AgentSearchQuotaLimits ¶ added in v2.2.0
type AgentSearchQuotaLimits struct {
KeywordPerMinute AgentSearchQuotaRange `json:"keyword_per_minute"`
SemanticPerMinute AgentSearchQuotaRange `json:"semantic_per_minute"`
SemanticGlobalPerMinute AgentSearchQuotaRange `json:"semantic_global_per_minute"`
}
AgentSearchQuotaLimits 是三项额度各自允许的范围,设置页拿它给输入框标范围、做同样的校验。
func AgentSearchQuotaBounds ¶ added in v2.2.0
func AgentSearchQuotaBounds() AgentSearchQuotaLimits
AgentSearchQuotaBounds 返回三项额度的范围。
type AgentSearchQuotaPatch ¶ added in v2.2.0
type AgentSearchQuotaPatch struct {
KeywordPerMinute *int
SemanticPerMinute *int
SemanticGlobalPerMinute *int
}
AgentSearchQuotaPatch 是一次局部修改:nil 表示这一项不动。
func (AgentSearchQuotaPatch) Empty ¶ added in v2.2.0
func (p AgentSearchQuotaPatch) Empty() bool
Empty 表示一项都没给。
type AgentSearchQuotaRange ¶ added in v2.2.0
AgentSearchQuotaRange 是一项额度允许的范围(含两端)。
type AgentSessionFilter ¶
AgentSessionFilter 是 ListAgentSessions 的过滤条件。
type AgentSessionView ¶
type AgentSessionView struct {
ID uint `json:"id"`
IdentityID uint `json:"identity_id"`
WorkflowID string `json:"workflow_id"`
ConversationID string `json:"conversation_id"`
ClientKind string `json:"client_kind,omitempty"`
CursorVersion string `json:"cursor_version,omitempty"`
IdentityLabel string `json:"identity_label"`
HostName string `json:"host_name"`
ProjectDir string `json:"project_directory"`
StartedAt *time.Time `json:"started_at,omitempty"`
EndedAt *time.Time `json:"ended_at,omitempty"`
EndReason string `json:"end_reason,omitempty"`
LastTool string `json:"last_tool,omitempty"`
ToolStartedAt *time.Time `json:"tool_started_at,omitempty"`
TurnStartedAt *time.Time `json:"turn_started_at,omitempty"`
TurnEndedAt *time.Time `json:"turn_ended_at,omitempty"`
LastEventAt time.Time `json:"last_event_at"`
LastMCPAt *time.Time `json:"last_mcp_at,omitempty"`
LastQueryAt *time.Time `json:"last_query_at,omitempty"`
State string `json:"state"` // 展示态(含 waiting_you / offline)
BaseState string `json:"base_state"` // 状态机里的状态
Sub string `json:"sub,omitempty"`
StateSource string `json:"state_source,omitempty"` // hook | tui | run:现在这个状态是谁说的(空 = 旧数据,没有记录)
Since time.Time `json:"since"`
QuietSeconds int `json:"quiet_seconds"`
WaitingYou bool `json:"waiting_you"`
Stalled bool `json:"stalled"`
StalledSoft bool `json:"stalled_soft"`
ApprovalSuspected bool `json:"approval_suspected"`
ApprovalOverdue bool `json:"approval_overdue"`
Reason string `json:"reason,omitempty"`
// 托管终端的屏幕信号(M3.2)。TUI 为空表示这个会话没有可用的屏幕扫描结果。
TUI string `json:"tui,omitempty"` // ok | unrecognized
LiveWord string `json:"live_word,omitempty"` // 状态行动词(动画中才有)
TokensLive *int `json:"tokens_live,omitempty"` // 状态行里的实时 token 数
TokensSource string `json:"tokens_source,omitempty"` // tui
CtxPct *float64 `json:"ctx_pct,omitempty"` // 页脚的上下文占用百分比
ScreenAt *time.Time `json:"screen_at,omitempty"` // 屏幕信号的接收时间
}
AgentSessionView 是对外的会话视图:库里的状态加上 Evaluate 推导出的展示状态。
type AgentTouchInput ¶
type AgentTouchInput struct {
WorkflowID string
CredentialID uint
HostName string
ProjectDirectory string
Query bool // 读类调用(收件箱、会话列表、文档读取……)
// Hook 为真表示这是编辑器 hook 的轮询(没带运行情况事件的那种):只记「hook 最近一次查询」,不算智能体调用 RelayMesh。
Hook bool
ClientKind string // hook 顺带汇报的客户端类型(ide / cli),其余场景留空
CursorVersion string
}
AgentTouchInput 是一次 MCP 调用(带工作流编号)留下的痕迹。
type AppError ¶
func NewConflictError ¶
func NewForbiddenError ¶
NewForbiddenError 表示任务级权限不允许这次操作;消息写给智能体看:谁能做、该怎么做。
func NewInvalidInputError ¶
func NewNotFoundError ¶
func NewTaskClosedError ¶
type ApplyParamsResult ¶ added in v2.1.0
type ApplyParamsResult struct {
Branch string `json:"branch"`
Parent string `json:"parent"`
Level string `json:"level"`
Applied []model.BranchParamEvent `json:"applied"`
Unchanged []string `json:"unchanged,omitempty"` // 与现有取值一致、没写的字段
}
ApplyParamsResult 是 session_params(set) 的结果。出错时也会返回已经写入的部分(Applied)。
type ArchiveSource ¶ added in v2.2.0
type ArchiveSource struct {
// contains filtered or unexported fields
}
ArchiveSource 实现 archive.Source。创建时一次性解析导出范围,之后不再变化。
func (*ArchiveSource) Confirms ¶ added in v2.2.0
func (a *ArchiveSource) Confirms(ctx context.Context) ([]model.ConfirmItem, error)
Confirms 实现 archive.Source:范围内工作流的全部确认项(含已答复、已过期),按(工作流,序号)升序。
func (*ArchiveSource) GroupLastSeq ¶ added in v2.2.0
GroupLastSeq 实现 archive.Source。
func (*ArchiveSource) GroupMessageCount ¶ added in v2.2.0
func (a *ArchiveSource) GroupMessageCount(ctx context.Context, groupID string, uptoSeq int64) (int, error)
GroupMessageCount 实现 archive.MessageCounter:群里 seq <= uptoSeq 的消息条数。 增量导出用它确认「基线之前的消息还原样在」(群消息现在只追加;将来若出现删除,条数对不上就整份重发)。
func (*ArchiveSource) GroupMessages ¶ added in v2.2.0
func (a *ArchiveSource) GroupMessages(ctx context.Context, groupID string, afterSeq, uptoSeq int64, limit int) ([]model.ChatMessage, error)
GroupMessages 实现 archive.Source:按 seq 升序的一页。不做成员可见性裁剪——导出是人(管理员)取全量历史, 离开的成员「看不到离开之后的消息」那条规则是对 Agent 读取的限制,不适用于这里。
func (*ArchiveSource) Groups ¶ added in v2.2.0
Groups 实现 archive.Source:绑定了本项目的群,加上范围内工作流做过成员的群(离开了也算)。 成员的显示名取工作流的显示标题。群里其它项目的成员也会列出来(跨项目群的历史本来就是一整份)。
func (*ArchiveSource) InboxIDs ¶ added in v2.2.0
func (a *ArchiveSource) InboxIDs(ctx context.Context) ([]uint, error)
InboxIDs 实现 archive.Source:范围内「用户追加」行的编号,升序。群消息投递(chat_mention)是群里那条消息的副本, 不算用户追加,由群聊文件承载。网页上看到的列表有 200 条上限,这里没有。
func (*ArchiveSource) InboxRows ¶ added in v2.2.0
func (a *ArchiveSource) InboxRows(ctx context.Context, ids []uint) ([]model.QueuedFeedback, error)
InboxRows 实现 archive.Source:按编号取行(升序),图片只剩元数据。
func (*ArchiveSource) Project ¶ added in v2.2.0
func (a *ArchiveSource) Project() archive.ProjectInfo
Project 实现 archive.Source。
func (*ArchiveSource) Sessions ¶ added in v2.2.0
func (a *ArchiveSource) Sessions(ctx context.Context, workflowID string, afterRowID, uptoRowID int64, limit int) ([]archive.SessionRow, error)
Sessions 实现 archive.Source:一个工作流 afterRowID < rowid <= uptoRowID 的会话轮次,按 rowid 升序一页。 用 rowid(SQLite 的插入序)而不是时间做游标:它在表里唯一、单调,翻页不会漏行也不会重行。
func (*ArchiveSource) SessionsMaxRowID ¶ added in v2.2.0
func (a *ArchiveSource) SessionsMaxRowID(ctx context.Context) (int64, error)
SessionsMaxRowID 实现 archive.Source:会话轮次表当前最大的 rowid,作为这次导出的水位。
func (*ArchiveSource) Tasks ¶ added in v2.2.0
Tasks 实现 archive.Source:规划树加全部任务(含已完成、已搁置),时间线与关联会话成批取。 不用 ListWorkItems:它为界面服务,有数量上限,也会在响应里夹带统计之类的派生字段。
func (*ArchiveSource) WorkflowIDs ¶ added in v2.2.0
func (a *ArchiveSource) WorkflowIDs() []string
WorkflowIDs 返回导出范围内的工作流编号(升序,拷贝)。文档不走 Source 接口(渲染要用到 API 层的决策表与目录), 调用方用它去取「还挂在工作流名下、没有并入项目」的文档。
func (*ArchiveSource) Workflows ¶ added in v2.2.0
func (a *ArchiveSource) Workflows(ctx context.Context) ([]archive.WorkflowInfo, error)
Workflows 实现 archive.Source:每个工作流的标题、目录、关系、轮次数与首末活动时间。 首末时间取会话行的创建 / 更新时间,用两次「取一行」的查询,不用 MIN/MAX 聚合—— SQLite 的聚合结果没有列类型,时间会以字符串返回,要自己解析。
type ArtifactCommentInput ¶
type ArtifactCommentInput struct {
DocID uint
Anchor string
Body string
AuthorKind string
AuthorRef string
AuthorLabel string
}
ArtifactCommentInput 是新增评论的入参。
type ArtifactDataSetInput ¶
type ArtifactDataSetInput struct {
DocID uint
Key string
ValueJSON string
ExpectedVersion *int
ActorLabel string
ActorRef string
}
ArtifactDataSetInput 是写一个键的入参。ExpectedVersion 非空时做乐观并发:版本不符返回冲突(0 = 期望这个键还不存在)。
type AsyncParam ¶ added in v2.1.0
type AsyncParam struct {
Enabled bool `json:"enabled"` // 用户 / 主会话设的开关
EverEnabled bool `json:"ever_enabled"` // 用户是否开启过(主会话只能恢复开启过的)
HookSeen bool `json:"hook_seen"` // 是否见过这个分支的编辑器 hook(开启的前提)
Effective bool `json:"effective"` // 此刻是不是有效的异步模式(hook 过期会降级)
}
AsyncParam 是异步对话开关的当前状态(不含授权档位)。
type AuditFilter ¶
type AuditFilter struct {
ProjectID uint
ActorRef string
Action string // 精确,或以 . 结尾的前缀(如 doc.)
Result string
ScopeRef string // 前缀
Since time.Time
Until time.Time
Limit int
BeforeID uint // 翻页:只取 id 小于它的
}
AuditFilter 审计筛选。
type AuditInput ¶
type AuditInput struct {
ProjectID uint
ActorKind string
ActorRef string
ActorLabel string
Action string
ScopeKind string
ScopeRef string
Target string
Result string // 空 = allow
Detail any // 序列化成 JSON;不得含正文
// Dedupe > 0 时:窗口内已有同主体、同动作、同范围、同结果的记录就不再写。
Dedupe time.Duration
// DedupeExact 为 true 时,去重还要求目标与详情也完全相同:只有「同一个目标、同一个原因」的重复才合并,
// 不同的原因 / 不同的目标各记各的(项目管理 Agent 运行预设被拒绝时,用户要看清每一种原因,而不是只看到第一条)。
DedupeExact bool
}
AuditInput 是要记的一条审计。
type AuthCredentials ¶
type AuthProfileInput ¶
AuthProfileInput 是新建 / 修改档位的入参;修改时只改非 nil 的字段。
type AutoResumeRecord ¶
type AutoResumeRecord struct {
// FromRun 是出事的那次运行(它异常退出了);同一次运行最多一条登记。
FromRun string `json:"from_run"`
// Attempt 是这次续跑在这一串里排第几次(1 起);出事的运行本身是手动运行时从 1 开始。
Attempt int `json:"attempt"`
// Class、Code、Reason 是出事的原因:类别(retriable……)、服务端错误码、一句中文。
Class string `json:"class,omitempty"`
Code string `json:"code,omitempty"`
Reason string `json:"reason,omitempty"`
// PlannedAt 是登记(出事被发现)的时间,Due 是排定的开跑时间。
PlannedAt time.Time `json:"planned_at"`
Due time.Time `json:"due,omitempty"`
State string `json:"state"`
// Why 是跳过 / 放弃 / 取消的原因(一句中文)。
Why string `json:"why,omitempty"`
// RunID 是续跑出来的新运行;StartedAt 是它提交的时间。
RunID string `json:"run_id,omitempty"`
StartedAt time.Time `json:"started_at,omitempty"`
// Quick 在续跑出来的运行又失败时由后一次登记补上:它跑得太短(没有进展,短于「续跑成功」的判定时长)。连续几次 Quick 就熔断。
Quick bool `json:"quick,omitempty"`
// Settled 表示这次续跑出来的运行连续跑满了「续跑成功」的判定时长(#172):这次续跑算成功,
// 24 小时内累计的续跑次数(预算与退避阶梯)从它之后重新算,它自己和它之前的登记都不再占名额。
Settled bool `json:"settled,omitempty"`
}
AutoResumeRecord 是一次「异常退出之后自动续跑」的登记:从排期,到开跑 / 跳过 / 放弃 / 被你取消。 它只记运行编号、次数、时间与一句话原因,不含任何输出内容。
type BoardAssignment ¶
type BoardAssignment struct {
WorkflowID string `json:"workflow_id"`
BoardKey string `json:"board_key"`
Items int `json:"items"`
Modules int `json:"modules"`
// Reason 说明依据:粘性(已有归板的任务 / 节点)、目录归属,或冲突回退。
Reason string `json:"reason"`
// Fallback 为 true 表示它本该落到 WantedKey,因序号或规划节点路径冲突回退到自己的独立板。
Fallback bool `json:"fallback,omitempty"`
WantedKey string `json:"wanted_key,omitempty"`
Conflicts []string `json:"conflicts,omitempty"`
}
BoardAssignment 是迁移里一个工作流的归板决定。
type BoardCounterPlan ¶
type BoardCounterPlan struct {
BoardKey string `json:"board_key"`
LastSeq int `json:"last_seq"`
// Existing 是现有 work_board_counters 里的值,没有记录为 0。
Existing int `json:"existing"`
}
BoardCounterPlan 是迁移后某张板的序号计数;只列需要写(没有记录或要调大)的。
type BoardDigest ¶ added in v2.1.0
type BoardDigest struct {
ToAccept BoardDigestGroup
Returned BoardDigestGroup
AwaitingReview BoardDigestGroup
Declined BoardDigestGroup
Stale BoardDigestGroup
StaleGone BoardDigestGroup
}
BoardDigest 是某个工作流在共享任务板上「该处理的协作待办」。返回值可能来自缓存,调用方只读、不要改。
func (*BoardDigest) Empty ¶ added in v2.1.0
func (d *BoardDigest) Empty() bool
Empty 表示没有任何待办——回执里就不出现 board: 行,与升级前逐字一致。
type BoardDigestGroup ¶ added in v2.1.0
BoardDigestGroup 是一类待办:个数、最多 BoardDigestMaxSeqs 个任务编号(板内序号,按派出时间从早到晚)、 其中最早一条的派出时间(零值 = 没有可比的时间)。
type BoardInfo ¶
type BoardInfo struct {
// Key 是板的 key。
Key string
// Project 在项目板时非空。
Project *model.Project
// Host / Dir 是解析所依据的最近一条带目录的汇报会话;没有时为空。
Host, Dir string
// Reason 是一句话说明为什么落在这张板(迁移预演与排错用)。
Reason string
// Why 是 Reason 对应的机器可读代码(BoardWhyProjectDir / BoardWhyDirNotRegistered / BoardWhyNoSessionDir)。
Why string
// Archived 在目录属于一个「已归档」项目(所以没算项目板)时是那个项目的 slug,只用来把原因讲准。
Archived string
}
BoardInfo 是一个工作流按目录归属解析出的板。
type BoardLineEvent ¶ added in v2.1.0
type BoardLineEvent struct {
Event string // assign / reassign / deliver / decline / reject_delivery / accept_delivery
ActorRef string // 谁做的:工作流编号;人在网页上做的是 GroupHumanRef
AssignerRef string // 派发者(工作流)
AssigneeRef string // 承接者(工作流)
Seq int // 任务在板上的编号(#N)
Title string
UpdateID uint // 时间线记录编号:幂等键用,0 = 没有
}
BoardLineEvent 是一次值得告诉群里的协作事件。
type BoardMergeBoard ¶
type BoardMergeBoard struct {
Key string `json:"key"`
ProjectID uint `json:"project_id,omitempty"`
ProjectSlug string `json:"project_slug,omitempty"`
ACLMode string `json:"acl_mode,omitempty"`
// Workflows 按「谁更早」排序(有任务的最早创建时间,其次编号):排在前面的保留自己的序号。
Workflows []string `json:"workflows"`
Tasks int `json:"tasks"`
// Counter 是迁移后 work_board_counters.last_seq:板内最大序号与各工作流旧计数的最大值。
Counter int `json:"counter"`
// Renumbered 是要改号的任务数;DupModules 是会被合并掉的重复规划节点数。
Renumbered int `json:"renumbered"`
DupModules int `json:"dup_modules"`
}
BoardMergeBoard 是规划出的一张板。
type BoardMergeCollision ¶
type BoardMergeCollision struct {
BoardKey string `json:"board_key"`
Seq int `json:"seq"`
Items []BoardMergeItemRef `json:"items"`
}
BoardMergeCollision 是同一张板里两个以上工作流用了同一个序号。
type BoardMergeItemRef ¶
type BoardMergeItemRef struct {
ItemID uint `json:"item_id"`
WorkflowID string `json:"workflow_id"`
Title string `json:"title"`
}
BoardMergeItemRef 指向一条任务。
type BoardMergeModuleDup ¶
type BoardMergeModuleDup struct {
BoardKey string `json:"board_key"`
Path string `json:"path"`
Workflows []string `json:"workflows"`
ModuleIDs []uint `json:"module_ids"`
// Tasks 是挂在这些节点上的任务数。
Tasks int `json:"tasks"`
}
BoardMergeModuleDup 是同一张板里路径相同的规划节点(会合并成一个)。
type BoardMergePlan ¶
type BoardMergePlan struct {
Items int `json:"items"`
Workflows []BoardMergeWorkflow `json:"workflows"`
Boards []BoardMergeBoard `json:"boards"`
Collisions []BoardMergeCollision `json:"collisions"`
Renumbers []BoardMergeRenumber `json:"renumbers"`
ModuleDups []BoardMergeModuleDup `json:"module_dups"`
// Warnings 是不阻塞但值得人看一眼的发现(解析不到目录、跨工作流的父子 / 模块引用、计数落后等)。
Warnings []string `json:"warnings"`
}
BoardMergePlan 是并入预演的完整结果。
func PlanBoardMerge ¶
PlanBoardMerge 读库算出「若把每个工作流并入它目录归属的板,序号有没有冲突、要改哪些号」,不写任何表。 只用到旧列(不看 board_key),所以对迁移前后的库都可用;它按目录归属动态解析,不考虑任务已经落在哪张板。
type BoardMergeRenumber ¶
type BoardMergeRenumber struct {
BoardKey string `json:"board_key"`
WorkflowID string `json:"workflow_id"`
ItemID uint `json:"item_id"`
OldSeq int `json:"old_seq"`
NewSeq int `json:"new_seq"`
}
BoardMergeRenumber 是一条改号动作:只重编冲突的那几条,别的序号原样保留;旧号写进别名表。
type BoardMergeWorkflow ¶
type BoardMergeWorkflow struct {
WorkflowID string `json:"workflow_id"`
Tasks int `json:"tasks"`
MaxSeq int `json:"max_seq"`
// Counter 是旧计数表 work_item_counters 里的值;HasCounter 表示有没有这条记录。
Counter int `json:"counter"`
HasCounter bool `json:"has_counter"`
Modules int `json:"modules"`
FirstTaskAt time.Time `json:"first_task_at,omitempty"`
BoardKey string `json:"board_key"`
ProjectSlug string `json:"project_slug,omitempty"`
Host string `json:"host,omitempty"`
Dir string `json:"dir,omitempty"`
Reason string `json:"reason"`
}
BoardMergeWorkflow 是规划里的一个工作流:它有多少任务、落在哪张板、依据是什么。
type BoardOffered ¶ added in v2.1.0
type BoardOffered struct {
WorkflowID string `json:"workflow_id"`
Count int `json:"count"`
OldestAt *time.Time `json:"oldest_at,omitempty"`
}
BoardOffered 是某个工作流手上「指派给它、还没接取」的协作任务:个数与最早一条的派出时间。 网页侧栏会话卡的「N 项待接取」徽标用(#180 B3b);口径与回执头 board: 行的「指派待你接取」一致。
type BoardReconcilePlan ¶
type BoardReconcilePlan struct {
// Placed 是已经归板的任务数(board_key 非空);Unplaced / UnplacedModules 是这次要归板的任务数与规划节点数。
Placed int `json:"placed"`
Unplaced int `json:"unplaced"`
UnplacedModules int `json:"unplaced_modules"`
Assignments []BoardAssignment `json:"assignments"`
Counters []BoardCounterPlan `json:"counters"`
Warnings []string `json:"warnings"`
}
BoardReconcilePlan 是给历史任务补板的完整计划。
func PlanBoardReconcile ¶
PlanBoardReconcile 只读地算出启动迁移会做什么(供 dry-run 工具使用)。
func (*BoardReconcilePlan) Changed ¶
func (p *BoardReconcilePlan) Changed() bool
Changed 表示这份计划是否会写库。
type BoardStaleOffer ¶ added in v2.1.0
type BoardStaleOffer struct {
BoardKey string
AssigneeWorkflowID string
// Seqs 是这些指派的编号(#N,板内序号),从小到大。
Seqs []int
// ID 只在恰好一个指派时有值:它的数据库编号。任务页地址里的 ?task= 按它打开详情;它和 #N(Seqs)不是同一个数,
// 多个板、多个工作流并存时两者必然错开,深链写成 #N 会打开别的任务。
ID uint
// Title 只在恰好一个指派时有值:它的标题。
Title string
// OldestAt 是其中最早的派出时间(提醒里写「已等多久」用)。
OldestAt time.Time
}
BoardStaleOffer 是一条提醒要说的事:同一块任务板上、同一个承接者那里「久无人接」的指派。
type BoardWhy ¶ added in v2.2.0
type BoardWhy struct {
// Key 是现在使用的板。
Key string
// Code 是 BoardWhy* 之一。
Code string
// Pinned 在 Code 为 pinned_* 时是钉住它的任务 / 规划节点个数(只数落在 Key 这张板上的)。
Pinned int
// KeyProject 在 Key 是项目板时是项目的 slug(查不到为空)。
KeyProject string
// DirReason / DirKey / DirProject 是「按目录重新解析」得到的结果:代码、板、项目 slug(落独立板时为空)。
// 没被钉住时它们就是现状本身(DirReason == Code,DirKey == Key)。
DirReason string
DirKey string
DirProject string
// Archived 在目录属于一个已归档的项目时是它的 slug,只用来把「没算项目板」讲准。
Archived string
// From 在 Code 为 inherited 时是主会话的工作流编号(分支沿用的是它所在的板)。
From string
// contains filtered or unexported fields
}
BoardWhy 说明一个工作流现在落在哪张板、为什么。只在读取时现算,不落库。
不变量:Key 永远等于 BoardKeyOf 的结果。名下有任务 / 规划节点时,只有「它们钉住的板正好是目录现在也认的那张项目板」才报目录那一层的原因 (那时钉不钉都是同一张项目板);其余一律报 pinned_*——钉在独立板上的工作流,目录登记之后也不会换板(换板只能经显式合并), 报成「目录没登记」会把人引到一个修不好问题的动作上。
type BranchAnswerInput ¶ added in v2.1.0
type BranchAnswerInput struct {
Main string // 调用者(主会话)的工作流编号
Branch string // 分支的工作流编号
Ref string // 请示编号(Q12)
OptionIDs []string
Note string
Custom string
}
BranchAnswerInput 是主会话代答的入参。
type BranchAssign ¶ added in v2.1.0
type BranchAssign struct {
Open bool `json:"open"`
BoardReason string `json:"board_reason,omitempty"`
MainBoardReason string `json:"main_board_reason,omitempty"`
BoardNote string `json:"board_note,omitempty"`
}
BranchAssign 是主会话能不能把任务派给这个分支(#236 P5):用户有没有在开放范围里打开「任务」= 派单, 以及两边是不是在同一张项目板上——派单要求承接者与任务在同一张项目板,不同板时指派会被拒绝,原因要讲清楚。 板读不出来时整个字段不输出(不假装「不在同一张板上」)。
不在同一张板上时多三项,说明「为什么」(只在 BoardShared 为 false 时才查、才输出;同板的行与以前逐字节一致): BoardReason 是分支一侧的归板原因(BoardWhy* 代码);MainBoardReason 只在主会话自己不在项目板上时输出,说明问题出在主会话一侧; BoardNote 是一句话事实说明(含被钉住的任务个数、按目录现在该落的项目)。读不出原因时这三项留空,board_shared 照旧。
func (*BranchAssign) NotSharedAdvice ¶ added in v2.2.0
func (a *BranchAssign) NotSharedAdvice(proj string) string
NotSharedAdvice 是「分支与主会话不在同一张项目板上」时的下一步(只写能做的事):proj 是「主会话所在的项目」的说法 (写给主会话的智能体用「你所在的项目」,写进就绪度的用「主会话所在的项目」)。原因读不出来时给出通用的一句。
type BranchBrief ¶ added in v2.1.0
type BranchBrief struct {
model.WorkflowBranch
Title string `json:"title"`
ParentTitle string `json:"parent_title,omitempty"`
Preset string `json:"preset,omitempty"` // 开放范围与哪个预设完全一致(visible / collab / managed);都不一致时为空,界面显示「自定义」
LastActivityAt *time.Time `json:"last_activity_at,omitempty"`
Waiting bool `json:"waiting,omitempty"` // 有一轮汇报在等回复
UnreadToMain int `json:"unread_to_main,omitempty"` // 这个分支发给主会话、主会话还没读的消息数
Missing bool `json:"missing,omitempty"` // 这个工作流在库里已经没有任何会话行(已失效)
PendingAsks int `json:"pending_asks,omitempty"` // 路由给主会话、还在等它定夺的请示数(#236 P2)
// 下面六项只给活动关系填(#236 P4 / P5 / #264 I-2,见 branch_status.go):状态恒向主会话开放,不受开放范围控制。
AgentState string `json:"agent_state,omitempty"` // 分支的 Agent 此刻的状态(取值同网页状态芯片:working / idle / waiting_you / … / stalled;没有任何会话是 unknown)
AgentStateAt *time.Time `json:"agent_state_at,omitempty"` // 这个状态从什么时候开始
Tasks *BranchTasks `json:"tasks,omitempty"` // 名下没做完的任务数(待办 / 进行中 / 验证中),全为 0 时不出现
Launch *BranchLaunch `json:"launch,omitempty"` // 启动方式:「启动」开没开、有几条预设能唤醒它
Assign *BranchAssign `json:"assign,omitempty"` // 派单:「任务」开没开、主会话与分支是否在同一张项目板上(#236 P5)
Readiness []BranchReadiness `json:"readiness,omitempty"` // 主会话用「发消息 / 代答请示 / 启动 / 派单 / 改常驻规则」五项能力的就绪度,没就绪的写明还缺什么(#264 I-2;改常驻规则是 #302 加的)
}
BranchBrief 是一条关系加上界面 / 智能体要看的概况。
type BranchEscalateInput ¶ added in v2.1.0
type BranchEscalateInput struct {
Main string
Branch string
Ref string
Note string // 必填:用户靠它看懂为什么转给他
}
BranchEscalateInput 是主会话转交的入参。
type BranchFeed ¶ added in v2.1.0
type BranchFeed struct {
Role string `json:"role"` // main | branch | none
Relation *BranchBrief `json:"relation,omitempty"` // role = branch:自己作为分支的那条关系
ParentTitle string `json:"parent_title,omitempty"` // role = branch:主会话的标题
Branches []BranchBrief `json:"branches,omitempty"` // role = main:自己的全部分支(含已结束)
Items []BranchFeedItem `json:"items"`
Titles map[string]string `json:"titles,omitempty"` // 工作流编号 → 标题,界面给发言者标名字用
}
BranchFeed 是 GET /workflows/:id/branch-feed 的内容。
type BranchFeedItem ¶ added in v2.1.0
type BranchFeedItem struct {
Kind string `json:"kind"` // message | event
ID uint `json:"id,omitempty"`
At time.Time `json:"at"`
Actor model.MsgActor `json:"actor"`
ActorTitle string `json:"actor_title,omitempty"` // 发言者所在会话的标题
Text string `json:"text,omitempty"`
State string `json:"state,omitempty"` // message:queued | delivered | acked | expired
Event string `json:"event,omitempty"` // event:created | closed | ask_routed(请示先送主会话定夺)| escalated(请示转交 / 升级给用户)| main_answered(主会话代答)| params_changed(主会话改了分支的参数)| params_reverted(用户撤销了主会话的修改)
Branch string `json:"branch,omitempty"` // 关联的分支工作流编号
By string `json:"by,omitempty"` // event:谁做的(human / agent:<wf> / migrate)
Outgoing bool `json:"outgoing,omitempty"` // message:是本会话的智能体发出去的(收件人是 To);否则是别人发给本会话的
To string `json:"to,omitempty"` // message:收件人的工作流编号(只有 Outgoing 时有)
Ref string `json:"ref,omitempty"` // event(ask_routed / escalated / main_answered):请示编号 Q12
RefTitle string `json:"ref_title,omitempty"`
// event(params_changed / params_reverted):ID 是参数事件的编号,Text 是一句人话摘要(不含常驻规则全文)。
Field string `json:"field,omitempty"` // 哪个参数:resident | phase | wake_resume | wake_new | title | async
Reverted bool `json:"reverted,omitempty"` // params_changed:已被用户撤销
Revertable bool `json:"revertable,omitempty"` // params_changed:现在还能撤销(POST …/params-events/:id/revert)
RevertOf uint `json:"revert_of,omitempty"` // params_reverted:撤销的是哪条事件
}
BranchFeedItem 是会话页时间线里的一项:一条消息,或一行事件。
type BranchHistory ¶ added in v2.1.0
type BranchHistory struct {
Branch string `json:"branch"`
Title string `json:"title,omitempty"`
Depth string `json:"depth"` // summary | full
Rounds []BranchRound `json:"rounds"`
}
BranchHistory 是 branch read 的返回。
type BranchLaunch ¶ added in v2.1.0
type BranchLaunch struct {
Open bool `json:"open"`
Presets int `json:"presets"`
Preset string `json:"preset,omitempty"` // 按名字排在最前的那条预设的编号
Name string `json:"name,omitempty"`
}
BranchLaunch 是分支的「启动方式」:用户有没有在开放范围里打开「启动」,以及有几条非交互续聊预设能唤醒它。 「此刻能不能运行」(主机在线、上一次运行有没有结束……)不在这里:它随时在变,要看 preset_run 的 list / status,或网页「运行」窗里的检查。
type BranchLinks ¶ added in v2.1.0
type BranchLinks struct {
AsBranch *model.WorkflowBranch
AsMain []model.WorkflowBranch
}
BranchLinks 是一个工作流在分支关系里的位置:它作为分支的那一条(至多一条)与它作为主会话的全部活动分支。
type BranchParamEventView ¶ added in v2.1.0
type BranchParamEventView struct {
model.BranchParamEvent
Revertable bool `json:"revertable"`
// RevertBlocked 是主会话写入的、还没撤销的事件现在不能撤销的原因(之后又改过 / 当前值已变…),能撤销或不适用时为空。
RevertBlocked string `json:"revert_blocked,omitempty"`
}
BranchParamEventView 是给界面的一条事件:事件本身,加上「现在能不能撤销」。
type BranchParamRevert ¶ added in v2.1.0
type BranchParamRevert struct {
Reverted model.BranchParamEvent `json:"reverted"` // 被撤销的原事件(已带 reverted_at)
Event model.BranchParamEvent `json:"event"` // 撤销本身产生的新事件
}
BranchParamRevert 是一次撤销的结果。
type BranchReadiness ¶ added in v2.2.0
type BranchReadiness struct {
Key string `json:"key"`
Ready bool `json:"ready"`
Missing []string `json:"missing,omitempty"`
}
BranchReadiness 是主会话用某一项能力的「就绪度」(#264 I-2):Ready = 现在就能用;否则 Missing 逐条写还缺什么, 每一条都是一件可以去做的事(多数是只有用户能在网页的开放范围里改的)。 它只依据已有的数据判断(开放范围、启动预设、两边的任务板),不探测「此刻」才知道的动态条件(主机在线、上一次运行有没有结束……)。
type BranchRound ¶ added in v2.1.0
type BranchRound struct {
SessionID string `json:"session_id"`
At time.Time `json:"at"`
Kind string `json:"kind"` // report(阻塞汇报)| notice(进度通知)
Status string `json:"status"` // pending | completed | timeout | cancelled | archived
Title string `json:"title,omitempty"`
Summary string `json:"summary"`
Reply string `json:"reply,omitempty"` // 用户(或回复方)的回复;摘要档只给首行
Images int `json:"images,omitempty"`
}
BranchRound 是主会话能看到的分支的一轮。
type BranchSayInput ¶ added in v2.1.0
type BranchSayInput struct {
From string // 发送方的工作流编号(调用方自己)
To string // 可空:发送方是分支 → 主会话;发送方只有一个活动分支 → 那个分支
Text string
}
BranchSayInput 是一条分支消息的入参。
type BranchSayResult ¶ added in v2.1.0
type BranchSayResult struct {
Row model.QueuedFeedback `json:"row"`
From string `json:"from_role"` // main | branch
To string `json:"to"`
ToTitle string `json:"to_title,omitempty"`
Direction string `json:"direction"` // main_to_branch | branch_to_main
}
BranchSayResult 是发送结果。
type BranchTasks ¶ added in v2.1.0
type BranchTasks struct {
Todo int `json:"todo,omitempty"`
Doing int `json:"doing,omitempty"`
Review int `json:"review,omitempty"`
}
BranchTasks 是分支名下还没做完的任务数,口径与收尾门(gateWhere)一致:待办 / 进行中数承接者、验证中数验收者。 三项全为 0 时整个字段不输出。
type CandidateSet ¶ added in v2.2.0
type CandidateSet struct {
PageSearchInfo
Refs []string
Terms []string // 归一后的检索词(页面要高亮时用)
// TitleRefs 是 Refs 里「全部检索词在标题里就满足」的那些引用(校验时顺带得出,页面排序「标题命中优先」用);Mode 不是 index 时为空。
TitleRefs map[string]bool
}
CandidateSet 是一次候选集查询的结果。Mode 为 index 时 Refs 是候选引用(新近的在前,每个引用至多出现一次); 否则 Refs 为空,页面走原来的逻辑,Reason 说明为什么。
func (*CandidateSet) UseIndex ¶ added in v2.2.0
func (c *CandidateSet) UseIndex() bool
UseIndex 报告页面这次是否该用候选集求交。
type CloseBranchResult ¶ added in v2.1.0
type CloseBranchResult struct {
Branch model.WorkflowBranch `json:"branch"`
Changed bool `json:"changed"` // false = 早已结束
// Escalated 是结束时被立即转交给用户的、原本路由给主会话的请示(调用方据此发「新请示」通知与刷新界面)。
Escalated []model.ConfirmItem `json:"-"`
// Returned 是结束时退回主会话名下的任务序号:主会话派给这个分支、还没交付的待办 / 进行中任务(#236 P5,见 returnBranchTasksTx)。
Returned []int `json:"returned_tasks,omitempty"`
}
CloseBranchResult 是结束分支的结果。
type ConfirmAnswerInput ¶
ConfirmAnswerInput 一次作答:选项 id + 可选备注 + 可选的自定义答复(#183)+ 作答来源。
type ConfirmBatchItem ¶
type ConfirmBatchItem struct {
Ref string `json:"ref"`
Options []string `json:"options,omitempty"`
Note string `json:"note,omitempty"`
}
ConfirmBatchItem 是批量作答里的一项;Options 为空且批量要求「采用推荐」时取该项的推荐选项。
type ConfirmBatchResult ¶
type ConfirmBatchResult struct {
Items []*model.ConfirmItem
Message string
}
ConfirmBatchResult 批量作答的结果:已作答的项与投递给智能体的那条收件箱文案。
type ConfirmCreateInput ¶
type ConfirmCreateInput struct {
WorkflowID string
Kind string
Title string
Body string
Options []model.ConfirmOption
Multi bool
AllowNote bool
DefaultOption string
Risk string
TaskSeq int
DocID uint
DocKey string
Anchor string
CreatedBy string
}
ConfirmCreateInput 创建确认项(REST 不暴露;MCP async_ask 与文档同步使用)。
type ConfirmFilter ¶
type ConfirmFilter struct {
WorkflowID string
Statuses []string
Kinds []string
TaskSeq int
DocID uint
Limit int
Offset int
Ascending bool
}
ConfirmFilter 列表筛选。Ascending=false 时新的在前(序号倒序),true 时旧的在前(待确认队列用)。
type CreateGroupInput ¶
type CreateGroupInput struct {
Title string
ProjectID string
CreatedBy string
Members []string // 工作流编号;调用方负责校验它们处于聊天模式(G-1)
}
CreateGroupInput 是建群的入参。建群只有你能做(API 层校验 actor 是 human,工具层没有入口)。
type CreateSessionInput ¶
type CreateSessionInput struct {
SessionID string `json:"session_id,omitempty"`
WorkflowID string `json:"workflow_id,omitempty"`
CredentialID uint `json:"credential_id,omitempty"`
EnvHostName string `json:"env_host_name,omitempty"`
CredentialHostName string `json:"credential_host_name,omitempty"`
ProjectDirectory string `json:"project_directory"`
Title string `json:"title,omitempty"`
Summary string `json:"summary"`
TimeoutSeconds int `json:"timeout_seconds,omitempty"`
// 交付锚点(可选):调用方已校验并规整;为空表示本轮没有锚点。
GitCommit string `json:"git_commit,omitempty"`
GitSubject string `json:"git_subject,omitempty"`
// NoticeLevel 只对 CreateNoticeSession 有意义(#275):key = 要发布成「重点」通知;其余一律按普通处理(库里存空串)。
NoticeLevel string `json:"-"`
// KeyNoticeLimit / KeyNoticeWindow 是重点通知的限速:同一个工作流在 KeyNoticeWindow 之内最多已有 KeyNoticeLimit 条重点通知时,
// 这一条降为普通通知(不报错)。计数与插入在同一个事务里,并发发布不会一起越过上限;0 = 不限。
KeyNoticeLimit int `json:"-"`
KeyNoticeWindow time.Duration `json:"-"`
}
type CreateWebBranchSpec ¶ added in v2.1.0
type CreateWebBranchSpec struct {
ParentWorkflowID string
// CreatedBy 是谁建的:human(默认,网页用户)或 agent:<主会话工作流编号>(主会话经 MCP 建的)。
CreatedBy string
// ExposePreset 与 Expose 二选一;都空 = 协作预设。
ExposePreset string
Expose *model.BranchExpose
CopyUserNotes *bool
}
CreateWebBranchSpec 是网页新建分支时的关系入参。
type CreateWebWorkflowInput ¶
type CreateWebWorkflowInput struct {
// Title 必填,经 NormalizeWebWorkflowTitle 规整。
Title string
// WorkflowID 可选;为空自动生成 wf-web-<日期>-<6 位随机>。给定时必须符合 webWorkflowIDPattern 且库里还没有这个工作流。
WorkflowID string
// EnvHostName 是服务自己配置的主机名,仅作兜底(全局设置里的主机名优先)。
EnvHostName string
// ProjectDirectory 可选:把占位会话(以及这个工作流)绑定到某个项目目录,经 NormalizeWebProjectDirectory 规整;
// 为空 = 不绑定(D-161 不比较,智能体带什么目录都行)。
ProjectDirectory string
// HostName 可选:用户指定的主机名(会话的归属标签),经 NormalizeWebHostName 规整;
// 为空沿用「全局设置 > 服务环境变量 > hosts」。智能体接入后,凭据绑定的主机仍以凭据为准。
HostName string
// Branch 可选(#236):把新工作流建成 Branch.ParentWorkflowID 的分支。关系与占位会话在同一个事务里落库:
// 主会话不存在 / 深度 / 上限 / 限额任何一条不满足,整个创建回滚,不会留下半个会话。
Branch *CreateWebBranchSpec
}
CreateWebWorkflowInput 是网页新建会话的入参。
type CreateWebWorkflowResult ¶
type CreateWebWorkflowResult struct {
Session *model.FeedbackSession
StartPrompt string
// Branch 是新建分支时落库的关系;不是分支则为 nil。
Branch *model.WorkflowBranch
}
CreateWebWorkflowResult 是网页新建会话的结果。
type CredentialHost ¶
type CredentialHost struct {
Name string `json:"name"`
HostName string `json:"host_name"`
Active bool `json:"active"`
}
CredentialHost 是「凭据名 → 主机名」的只读视图,供运维挑选改绑目标主机;不含令牌。
type DocACLFact ¶ added in v2.2.0
type DocACLFact struct {
ID uint
WorkflowID string
ProjectID uint
ModulePath string
OwnerIdentityID uint
Path string
}
DocACLFact 是对一篇文档做访问判定要用到的元数据(不含正文)。
type DocActor ¶
type DocActor struct {
Kind string // human / agent / import
// IdentityID 是写入者的 Agent 身份(#114);新建文档时记为负责人,0 = 不记。
IdentityID uint
}
DocActor 描述写入者。
type DocBrief ¶
type DocBrief struct {
ID uint `json:"id"`
WorkflowID string `json:"workflow_id"`
Path string `json:"path"`
Title string `json:"title"`
Kind string `json:"kind"`
Status string `json:"status"`
Render string `json:"render,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
DocBrief 是模块页里一篇文档的摘要(不含正文)。
type DocLinkRef ¶
type DocLinkRef struct {
Target string `json:"target,omitempty"` // 出链:正文里写的目标(已规范化路径)
ID uint `json:"id,omitempty"`
WorkflowID string `json:"workflow_id,omitempty"`
Path string `json:"path"`
Title string `json:"title,omitempty"`
Exists bool `json:"exists"`
}
DocLinkRef 是链接关系里的一端:出链指向的文档(可能不存在),或反链来自的文档。
type DocLinks ¶
type DocLinks struct {
Outlinks []DocLinkRef `json:"outlinks"`
Backlinks []DocLinkRef `json:"backlinks"`
}
DocLinks 是一篇文档的出链与反链。
type DocWorkflowStat ¶
type DocWorkflowStat struct {
WorkflowID string `json:"workflow_id"`
Total int `json:"total"`
UpdatedAt time.Time `json:"updated_at"`
}
DocWorkflowStat 供页头角标。
type DraftImageInfo ¶
type DraftImageInfo struct {
Key string `json:"key"`
Name string `json:"name,omitempty"`
Format string `json:"format,omitempty"`
Hash string `json:"hash,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Size int `json:"size"`
UpdatedAt time.Time `json:"updated_at"`
}
DraftImageInfo 是一张草稿图片的元数据(不含正文)。
type ErrorKind ¶
type ErrorKind string
const ( ErrNotFound ErrorKind = "not_found" ErrConflict ErrorKind = "conflict" ErrInvalidInput ErrorKind = "invalid_input" ErrClosed ErrorKind = "task_closed" ErrForbidden ErrorKind = "forbidden" // 任务级权限(#175 B2):调用方不是这条任务的创建者 / 承接者 / 管理者 ErrOperationFailed ErrorKind = "operation_failed" ErrIdempotencyClash ErrorKind = "idempotency_clash" )
type GateInfo ¶ added in v2.1.0
type GateInfo struct {
// Strict 门开着(用户没关);Released 本轮已被用户放行。
Strict bool
Released bool
// Total 是挡着收尾的任务总数,Tasks 是其中按编号升序的前 asyncmode.GateViewMax 个。
Total int
Tasks []asyncmode.GateTask
}
GateInfo 是某个会话此刻的收尾门状态(Web 弹层与回执 tasks: 行用)。
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"`
// DefaultWaitCountdownSeconds 秒级默认挂起倒计时;-1 = 没设过,沿用分钟值。
DefaultWaitCountdownSeconds int `json:"defaultWaitCountdownSeconds"`
// 异步对话(#123):智能体每发一条新消息,回复窗口加这么多分钟;<=0 按默认 5。
AsyncWindowAddMinutes int `json:"asyncWindowAddMinutes"`
// 异步对话:智能体每次用计时器最多连续等这么多分钟再回头读收件箱;<=0 按默认 10。
AsyncWaitSliceMinutes int `json:"asyncWaitSliceMinutes"`
UserMemory string `json:"userMemory"`
ServerInstructions string `json:"serverInstructions"`
PhaseTemplate []model.PhaseItem `json:"phaseTemplate"`
Security SecuritySettings `json:"security"`
FlowPrompts struct {
Online struct {
WaitPollPrompt string `json:"waitPollPrompt"`
ExhaustedPrompt string `json:"exhaustedPrompt"`
} `json:"online"`
} `json:"flowPrompts"`
}
type GrantInput ¶
type GrantInput struct {
ProjectID uint
PrincipalKind string // identity | group
PrincipalRef string // identity:身份编号;group:会话编号
ScopeKind string // project | module | doc | workflow | tasks(项目任务板的管理权,只能由用户授予)
ScopeRef string
Role string // read | comment | edit(manage 不能授予)
GrantedByKind string // human | identity
GrantedByRef string
GrantedByLabel string
ExpiresAt *time.Time
Note string
}
GrantInput 是一条新授权。
type GroupError ¶
type GroupError struct {
Code string // not_member | rate_limited | hop_limit | too_large | group_archived
Message string
}
GroupError 是群聊规则拒绝一次操作时的错误,Code 给 MCP / API 做机器可读的分流。
func (*GroupError) Error ¶
func (e *GroupError) Error() string
type GroupTrashGrant ¶ added in v2.2.0
type GroupTrashGrant struct {
ID uint `json:"id"`
ProjectID uint `json:"project_id"`
ProjectName string `json:"project_name,omitempty"`
ScopeKind string `json:"scope_kind"`
ScopeRef string `json:"scope_ref"`
Role string `json:"role"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}
GroupTrashGrant 是被撤销(或将被撤销)的一条群级授权的元数据:所属项目、范围、角色与有效期。不含任何正文。
type GroupTrashInput ¶ added in v2.2.0
type GroupTrashInput struct {
GroupID string
// ConfirmName 是用户手动输入的群名;必须与 PreviewGroupTrash 给出的 ConfirmName 一致。
ConfirmName string
// Now 留空取当前时间(测试用来固定时间)。
Now time.Time
}
GroupTrashInput 是把一个群移进回收站的参数。
type GroupTrashPreview ¶ added in v2.2.0
type GroupTrashPreview struct {
GroupID string `json:"group_id"`
// ConfirmName 是确认框要求手动输入的名字(群名);服务端删除时按它核对。
ConfirmName string `json:"confirm_name"`
Archived bool `json:"archived"`
// ProjectID / ProjectName 是群绑定的项目(绑定随群行消失,项目本身不变)。
ProjectID string `json:"project_id,omitempty"`
ProjectName string `json:"project_name,omitempty"`
// Messages 含系统行;Members 含「你」与已离开的;ActiveMembers 是仍在群里的工作流成员。
Messages int `json:"messages"`
Members int `json:"members"`
ActiveMembers int `json:"active_members"`
// Bytes 是消息正文的大致体积(长度之和,只是估计)。
Bytes int64 `json:"bytes"`
// Grants 是现在对这个群有效、删除时会被撤销的群级授权。
Grants []GroupTrashGrant `json:"grants"`
// UnreadMentions 是成员收件箱里还没读的「群聊 @ 提醒」条数(删除时被撤回)。
UnreadMentions int `json:"unread_mentions"`
// Blockers 非空表示现在不能删,每条都是写给人看的原因与解决办法。
Blockers []string `json:"blockers"`
RetentionDays int `json:"retention_days"`
}
GroupTrashPreview 是「删除这个群会发生什么」:确认框据此展示范围与拦截原因。
type GroupTrashRestoreResult ¶ added in v2.2.0
type GroupTrashRestoreResult struct {
GroupID string `json:"group_id"`
Title string `json:"title"`
Messages int `json:"messages"`
Members int `json:"members"`
// LeftMembers 是恢复时「工作流已经不存在」、因此放回时记为已离开的成员数(不制造幽灵在线成员)。
LeftMembers int `json:"left_members"`
// ProjectCleared 为真表示删除时绑定的项目现在已经不存在,恢复时清空了绑定(ClearedProjectID 是原来的绑定)。
ProjectCleared bool `json:"project_cleared"`
ClearedProjectID string `json:"cleared_project_id,omitempty"`
// RevokedGrants 是删除时被撤销的群级授权清单:**恢复不会把它们还回去**,由用户决定要不要重新授权。
RevokedGrants []GroupTrashGrant `json:"revoked_grants"`
}
GroupTrashRestoreResult 是恢复的结果。
type GroupTrashResult ¶ added in v2.2.0
type GroupTrashResult struct {
// Entry 是回收站条目(不含快照正文)。
Entry *model.GroupTrash
// Grants 是被撤销的、此刻有效的群级授权(API 层据此给授权所属的项目各记一条 revoke 审计)。
Grants []GroupTrashGrant
// RetractedMentions 是被撤回的未读「群聊 @ 提醒」条数。
RetractedMentions int
}
GroupTrashResult 是移进回收站的结果。
type GroupVisibility ¶
GroupVisibility 限定一个 Agent 能看到的消息:入群之后,且(离开前)。人读取时传 nil。
type GuardPresetState ¶
type GuardPresetState struct {
// AutoResumes 是「非交互运行异常退出后自动续跑」的登记(按登记先后,新的在后)。
AutoResumes []AutoResumeRecord `json:"auto_resumes,omitempty"`
}
GuardPresetState 是一个预设的持久运行状态。
func (*GuardPresetState) AutoResumeFrom ¶
func (p *GuardPresetState) AutoResumeFrom(fromRun string) (AutoResumeRecord, bool)
AutoResumeFrom 返回为 fromRun 这次出事登记的自动续跑;没有时 ok 为 false。
func (*GuardPresetState) AutoResumeStartedSince ¶
func (p *GuardPresetState) AutoResumeStartedSince(since time.Time) int
AutoResumeStartedSince 返回 since 之后已经开跑的自动续跑次数(滚动窗口里的预算用量)。 成功的续跑(Settled,见 SettleAutoResume)会把计数清零:从最近一次成功的续跑之后才开始数,它自己和它之前的都不算。
func (*GuardPresetState) AutoResumeStarting ¶
func (p *GuardPresetState) AutoResumeStarting(runID string) (AutoResumeRecord, bool)
AutoResumeStarting 返回那条「开跑出了 runID 这次运行」的登记;runID 不是自动续跑出来的就 ok 为 false。
func (*GuardPresetState) AutoResumeTrailingQuick ¶
func (p *GuardPresetState) AutoResumeTrailingQuick() int
AutoResumeTrailingQuick 返回沿着「续跑出来的运行又出事」这条链,最近连续有几次续跑「没有进展」(Quick)。 链断了(中间被你手动运行过、或某次续跑被跳过)就停:那之后重新算。
func (*GuardPresetState) ClaimAutoResumeRun ¶
func (p *GuardPresetState) ClaimAutoResumeRun(runID string, attempt int) bool
ClaimAutoResumeRun 把「已开跑、却还没写上运行编号」的那条登记认领给 runID(#187):占名额、提交运行、写聊天行、写运行编号是分开的几步, 运行很快就结束(或这几步被负载拖慢)时,结束的处理会先到,按编号找不到登记。结束的处理拿运行说明末尾「自动续跑 n/m」里的次数 attempt 来认领: 找最近一条已开跑、编号为空、次数相同的登记。提交方随后写入的是同一个编号,所以认领与写入的先后不影响结果。 返回是否有改动:已经有登记带着这个编号、找不到合适的登记(不是续跑出来的、编号已经写上、次数对不上),都返回 false 且什么也不改。
func (*GuardPresetState) SettleAutoResume ¶
func (p *GuardPresetState) SettleAutoResume(runID string) bool
SettleAutoResume 认定「开跑出了 runID 这次运行」的那次续跑成功(调用方已确认它连续跑满了判定时长): 标上 Settled、去掉 Quick,并让预算用量从它之后重新算。返回是否有改动:runID 不是自动续跑出来的、 那条登记不是「已开跑」状态、或者早就认定过,都返回 false(幂等,调用方据此只写一次聊天行)。
type GuardStateDoc ¶
type GuardStateDoc struct {
Presets map[string]*GuardPresetState `json:"presets"`
}
GuardStateDoc 是整份预设运行状态:预设编号 → 状态。
func (*GuardStateDoc) Preset ¶
func (d *GuardStateDoc) Preset(id string) *GuardPresetState
Preset 返回某个预设的状态;没有时返回新建的空状态(并登记进文档,方便调用方直接改)。
type GuiWakeConfig ¶ added in v2.2.0
type GuiWakeConfig struct {
Targets []GuiWakeTarget `json:"targets"`
Default *GuiWakeDefault `json:"default,omitempty"`
}
GuiWakeConfig 是整份 GUI 唤醒目标配置。
func (GuiWakeConfig) Normalize ¶ added in v2.2.0
func (c GuiWakeConfig) Normalize() GuiWakeConfig
Normalize 规整各字段:全部去首尾空白,文字来源按小写、空值归为 template;不改调用方的数据。
func (GuiWakeConfig) Resolve ¶ added in v2.2.0
func (c GuiWakeConfig) Resolve(workflowID string) (ResolvedGuiTarget, bool)
Resolve 为工作流找目标:先找专属目标(工作流编号完全相同),没有再用默认目标;都没有返回 false。
func (GuiWakeConfig) Validate ¶ added in v2.2.0
func (c GuiWakeConfig) Validate() error
Validate 检查一份(已规整的)配置;错误信息面向用户,并带上出问题的条目。
type GuiWakeDefault ¶ added in v2.2.0
type GuiWakeDefault struct {
Host string `json:"host"`
Repo string `json:"repo,omitempty"`
TextMode string `json:"text_mode,omitempty"`
}
GuiWakeDefault 是没有专属目标的工作流使用的默认目标。
type GuiWakeTarget ¶ added in v2.2.0
type GuiWakeTarget struct {
ID string `json:"id"`
WorkflowID string `json:"workflow_id"`
// Host 是装着 Cursor 的那台主机的机器码(常见情形是一台 Windows 桌面,不是项目所在的 Linux 主机)。
Host string `json:"host"`
// Repo 是 Cursor 侧栏里的仓库分组标识(repo:github.com/owner/name)。新建会话必填;续聊可空(给了就核对行所在的分组)。
Repo string `json:"repo,omitempty"`
// TextMode 是 GuiTextTemplate(默认)或 GuiTextPlain。
TextMode string `json:"text_mode,omitempty"`
}
GuiWakeTarget 是一个工作流的 GUI 唤醒目标。
type HeadlessRun ¶
type HeadlessRun struct {
// Bin 是可执行文件(命令名或路径);空 = DefaultHeadlessBin。
Bin string `json:"bin,omitempty"`
// Model 是 --model 的值;空 = 不带(用 CLI 自己的默认模型)。
Model string `json:"model,omitempty"`
// Posture 是权限姿态:allowlist(默认,不带 --force,只能做 CLI 白名单放行的事)或 force(带 --force,放开全部命令)。
Posture string `json:"posture,omitempty"`
// WorkflowID 是智能体使用的 RelayMesh 工作流编号:用来找到它最近的对话、替换提示词里的 %workflow、
// 在聊天里记系统行、判断这次运行有没有向 RelayMesh 汇报。
WorkflowID string `json:"workflow_id,omitempty"`
// ConversationID 固定要接着的对话;空 = 用 hook 汇报的、这个工作流最近的 CLI 对话编号。
ConversationID string `json:"conversation_id,omitempty"`
// Prompt 是提示词正文;空 = 服务端默认文本。其中 %workflow 换成工作流编号。
Prompt string `json:"prompt,omitempty"`
// MaxRunMinutes 是一次运行最长跑多久(分钟,#141);0 = 没设,用平台单次运行上限 7 天。
// 到点由主机强制结束这次运行(运行状态「超时」,界面写「达到运行时长上限」);设了的值收进 [1 分钟, 7 天],负数被拒绝。
// 续聊是一个会话而不是一条短命令,所以默认不设短限;想给一次运行封顶(防止它无人看管地跑太久)才需要填。
MaxRunMinutes int `json:"max_run_minutes,omitempty"`
// AutoResume 打开后,这个预设发起的运行如果「异常退出」且错误被 CLI 自己标成可重试(#151,D-260),Hub 会在退避之后
// 自动再续聊一次:24 小时最多 3 次,连续 2 次没有进展就停下并通知。默认关闭——它是无人值守的模型调用,有成本。
// 你取消的、运行时长上限到点的、成功退出的、需要你处理或认不出原因的失败,一律不会自动续跑。
AutoResume bool `json:"auto_resume,omitempty"`
// AutoResumeOKMinutes 是自动续跑「成功」的判定时长(分钟,#172,追加 #304):续跑出来的运行连续跑满这么久,
// 就算这次续跑成功,24 小时内累计的续跑次数与退避从头算,不再被它之前的几次续跑拖累;
// 比它短就算「没有进展」(连续 2 次没有进展就熔断)。0 = 没设,用默认的 10 分钟;设了的值收进 [1 分钟, 1 天],负数被拒绝。
AutoResumeOKMinutes int `json:"auto_resume_ok_minutes,omitempty"`
// Source 是对话来源(#191):resume(指定会话)/ new(新会话)/ continue(最近会话),见 HeadlessSource*。
// 空 = 按旧字段推导(EffectiveSource):填了对话编号 → resume;勾了 NewConversation → new(记下编号);都没有 → resume(跟随工作流)。
// 存量预设不迁移:读取时推导,到用户在表单里保存一次才写入这个字段。
Source string `json:"source,omitempty"`
// AfterNew 是「新会话」运行之后的去向(#559):remember(记下编号,默认)/ stay(不切换)/ continue(成功后切到最近会话),
// 见 HeadlessAfter*。只在 Source 是 new 时有意义;规整时其它来源会把它清空。
AfterNew string `json:"after_new,omitempty"`
// NewConversation 是旧版的「第一次运行时新开对话」勾选(#176 第三期)。它仍然是存量预设的来源:这个预设在「还不知道要接哪个对话」
// (预设里没有固定对话编号、这个工作流里也没有智能体接入过)时不再报错,而是新开一个对话——命令不带 --resume,提示词换成
// 「接入工作流」版本,对话编号从这次运行输出的 init 事件里学到并记下来,之后的运行就是续聊,所以它只会新开一次。
// 设了 Source 之后它只是 Source / AfterNew 的镜像(规整时按 new + remember 同步),让回滚到旧版本时行为基本不变;
// 没设 Source 的存量预设仍按它推导。固定了对话编号(ConversationID)就不能再选新开:二选一。
NewConversation bool `json:"new_conversation,omitempty"`
// Origin 标记预设是怎么来的:空 = 手工建的;HeadlessOriginEnableAgent = 会话页「启用 Agent」自动建的(#176)。
// 只用来在启动器清单里给它打标记、以及让「启用 Agent」再次点击时复用同一条预设,不改变运行行为。
Origin string `json:"origin,omitempty"`
}
HeadlessRun 是「非交互续聊」预设(Kind == "headless")的运行配置。
点「运行」时,Hub 经主机的执行通道运行(与 ExecMesh 同一条通道、同一套闸门):
<bin> -p --resume <对话编号> --approve-mcps --trust [--model <模型>] [--force] --workspace <目录> --output-format stream-json '<提示词>'
对话来源(Source,#191)三选一:指定会话 = 上面这条命令;新会话 = 命令不带 `--resume <对话编号>`,其余相同; 最近会话 = 命令里的 `--resume <对话编号>` 换成 `--continue`(由 Cursor CLI 接着该目录里最近的对话)。
命令只由这些已校验的字段拼出,所有动态部分都经过单引号包裹(Linux / macOS 是 bash 的单引号,Windows 主机是 PowerShell 的单引号字面量,#178); 预设不能写任意命令,所以改配置不会变成任意命令执行。Windows 主机上目录与可执行文件的写法见 headless_paths.go。
func NormalizeHeadlessRun ¶
func NormalizeHeadlessRun(r HeadlessRun) (HeadlessRun, error)
NormalizeHeadlessRun 规整并校验一份非交互运行配置:会话页的「运行」(#128)与预设共用这套字段规则。 错误信息面向用户,已去掉「终端启动预设不合法」的前缀;返回的配置总是规整后的。
func (HeadlessRun) EffectiveAfterNew ¶ added in v2.1.0
func (r HeadlessRun) EffectiveAfterNew() string
EffectiveAfterNew 返回「新会话」运行之后的去向(HeadlessAfter*):对话来源不是「新会话」时返回空串; 是「新会话」但没设(旧预设,或界面没传)时就是默认的「记下编号」——与旧版的勾选行为一致。
func (HeadlessRun) EffectiveAutoResumeOK ¶
func (r HeadlessRun) EffectiveAutoResumeOK() time.Duration
EffectiveAutoResumeOK 返回实际生效的「续跑成功」判定时长:没设就是默认的 10 分钟,超过上限的收进上限。
func (HeadlessRun) EffectiveBin ¶
func (r HeadlessRun) EffectiveBin() string
EffectiveBin 返回实际使用的可执行文件。
func (HeadlessRun) EffectiveMaxRunMinutes ¶
func (r HeadlessRun) EffectiveMaxRunMinutes() int
EffectiveMaxRunMinutes 返回实际生效的最长运行时间(分钟):没设就是平台单次运行上限。
func (HeadlessRun) EffectiveMaxRunSeconds ¶
func (r HeadlessRun) EffectiveMaxRunSeconds() int
EffectiveMaxRunSeconds 是 EffectiveMaxRunMinutes 换算成秒:交给执行通道当这次运行的超时。
func (HeadlessRun) EffectivePosture ¶
func (r HeadlessRun) EffectivePosture() string
EffectivePosture 返回实际生效的权限姿态。
func (HeadlessRun) EffectiveSource ¶ added in v2.1.0
func (r HeadlessRun) EffectiveSource() string
EffectiveSource 返回实际生效的对话来源(HeadlessSource*)。设了 Source 就用它;没设的存量预设按旧字段推导: 勾了「新开对话」→ new;其余(固定了编号,或都空 = 跟随工作流)→ resume。读取时推导,不改写存档。 (旧版校验不允许「勾了新开」同时「固定了编号」,这样的组合根本存不进来;万一传进来,validate 会按 new 的规则拒绝它。)
type HeadlessWake ¶
type HeadlessWake struct {
Enabled bool `json:"enabled"`
Posture string `json:"posture,omitempty"` // allowlist | force;空 = allowlist
}
HeadlessWake 是非交互唤醒的配置。
func (HeadlessWake) EffectivePosture ¶
func (h HeadlessWake) EffectivePosture() string
EffectivePosture 返回实际生效的权限姿态。
type HostGrantResult ¶
type HostGrantResult struct {
// Granted 是这次新写入名单的令牌名称(令牌名不是机密,可用于审计与界面提示)。
Granted []string `json:"granted"`
// Full 是名单已满(达到 CredentialMaxTerminalHosts)、无法再写入的令牌数。
Full int `json:"full"`
}
HostGrantResult 是把一台主机写入模型令牌名单的结果。
type HostModelUpdate ¶
type HostModelUpdate struct {
AllowModel *bool
ExecMode *string
ModelPaused *bool
// DefaultForNewModels 是主机对新建模型授权的默认态(allow / deny);归一后比较,deny 与空串视为同一状态。
DefaultForNewModels *string
}
HostModelUpdate 描述对主机「模型访问」设置的一次修改;nil 字段表示不修改。
type ImportDocFile ¶
type ImportDocFile struct {
Path string
Content string
Kind string
Status string
Tags []string
Title string
}
ImportProjectDocs 批量导入。
type ImportDocResult ¶
type InboxConfig ¶
type InboxConfig struct {
Enabled bool `json:"enabled"` // 总开关
ReceiptHint bool `json:"receipt_hint"` // 第二层:工具回执里追加 inbox: 提示
Hooks bool `json:"hooks"` // 第一层:Cursor hook 的提醒 / 拦截(hook 查询时由服务端判断)
PromptClause bool `json:"prompt_clause"` // 第三层:MCP 指引里的收件箱条款
HookInstallHint bool `json:"hook_install_hint"` // 未装 hook 时在回执末尾提示安装(可关)
}
InboxConfig 是追加指令收件箱的手动开关:一个总开关,外加三层发现机制各自的开关。 总开关关闭等于回到「被动模式」:不再追加回执提示行、不再让 hook 提醒、不再在指引里提收件箱; 已经排队的追加一条都不会丢,智能体下次发起交互时仍然会被秒回带走。
func (InboxConfig) ClauseOn ¶
func (c InboxConfig) ClauseOn() bool
func (InboxConfig) Effective ¶
func (c InboxConfig) Effective(envOff bool) InboxConfig
Effective 叠加环境变量的总闸(RELAYMESH_INBOX=off):它只能关,不能开。
func (InboxConfig) HintOn ¶
func (c InboxConfig) HintOn() bool
HintOn / HooksOn / ClauseOn 是「总开关 ∧ 分层开关」。
func (InboxConfig) HookInstallHintOn ¶
func (c InboxConfig) HookInstallHintOn() bool
HookInstallHintOn 是否在回执里提示安装 hook。
func (InboxConfig) HooksOn ¶
func (c InboxConfig) HooksOn() bool
type InboxGetOutcome ¶ added in v2.2.0
type InboxGetOutcome string
InboxGetOutcome 是 InboxGetMessage 的结论。
const ( InboxGetOK InboxGetOutcome = "ok" InboxGetNotFound InboxGetOutcome = "not_found" // 编号不存在、不属于这个工作流、不是人工追加,或撤回时智能体从未知道它:一律当作没有,不泄露存在与否 InboxGetUnread InboxGetOutcome = "unread" // 还在排队、没被读过:要先用 inbox 读取(读取会标为已送达,撤回的逻辑才知道它读过) InboxGetRetracted InboxGetOutcome = "retracted" // 智能体知道它存在、之后被用户撤回:只告知撤回,不给正文 )
type InboxPeek ¶
type InboxPeek struct {
InboxSummary
Remind bool `json:"remind"`
}
InboxPeek 是 hook 的查询结果:概况,外加「这次该不该提醒」。
type InboxReadOptions ¶
type InboxReadOptions struct {
// Recent 同时返回最近已确认的几条(上下文被压缩后想找回之前读过的追加时用)。
Recent bool
}
InboxReadOptions 控制 InboxRead 返回什么。
type InboxReadResult ¶
type InboxReadResult struct {
New []model.QueuedFeedback // 这次第一次送达
Pending []model.QueuedFeedback // 此前已读取、仍未确认(再列一遍,防止遗漏)
Retracted []model.QueuedFeedback // 读取或被提醒后被撤回,这是第一次告诉智能体:请忽略(DeliveredAt 为空的是「只被提醒过、没读过」)
Recent []model.QueuedFeedback // 最近已确认的(仅 Recent=true 时)
}
InboxReadResult 是一次读取收件箱的结果。
type InboxSummary ¶
type InboxSummary struct {
Unread int `json:"unread"` // 排队中、智能体还没读到的条数
UnreadMentions int `json:"unread_mentions,omitempty"` // 其中是群聊 @ 提醒(kind=chat_mention)的条数
UnreadAnswers int `json:"unread_answers,omitempty"` // 其中是确认项答复(kind=answer)的条数;提示行据此换措辞
UnreadBranch int `json:"unread_branch,omitempty"` // 其中是分支会话之间的消息(kind=branch,#236)的条数;提示行单独说
Delivered int `json:"delivered"` // 已读取、尚未确认的条数
RetractNotices int `json:"retract_notices"` // 智能体读过或被提醒过、之后被撤回、还没告诉它的条数(#199)
OldestUnreadAt *time.Time `json:"oldest_unread_at,omitempty"` // 最早一条未读的时间
LatestUnreadAt *time.Time `json:"latest_unread_at,omitempty"` // 最新一条未读的时间
LatestPreview string `json:"latest_preview,omitempty"` // 最新一条未读的预览(单行、截断)
}
InboxSummary 是一个工作流收件箱的概况:提示行与 hook 都靠它。
type JWTSecretResolution ¶
type JWTSecretResolution struct {
// Secret 是最终用于签名的密钥,恒满足 config.IsStrongJWTSecret。
Secret string
Source JWTSecretSource
// EnvRejectedReason 非空表示运维显式设置了 RELAYMESH_JWT_SECRET 但强度不足而被忽略(原因不含密钥内容)。
// 变量缺省(等于内置默认值)不算显式设置,不会填充该字段。
EnvRejectedReason string
// PersistError 仅在 Source 为 ephemeral 时非空:说明无法持久化的原因。
PersistError error
}
JWTSecretResolution 是 ResolveJWTSecret 的结果。
type JWTSecretSource ¶
type JWTSecretSource string
JWTSecretSource 标记当前生效的 JWT 签名密钥来源,仅用于日志与诊断。
const ( JWTSecretSourceEnv JWTSecretSource = "env" // 环境变量 RELAYMESH_JWT_SECRET(强度合格) JWTSecretSourceDB JWTSecretSource = "database" // 此前自动生成并持久化在数据库中的密钥 JWTSecretSourceGenerated JWTSecretSource = "generated" // 本次启动新生成并已持久化 JWTSecretSourceEphemeral JWTSecretSource = "ephemeral" // 持久化失败,仅本进程内存有效,重启后失效 )
type LauncherGuard ¶
type LauncherGuard struct {
// Enabled 是监测开关;关闭时保留其余配置,下次打开不用重填。
Enabled bool `json:"enabled"`
// WorkflowID 是这个会话里的智能体使用的 RelayMesh 工作流编号:服务端据此判断它是不是在合法地等你回复、
// 有没有没读的回复或追加、有没有进行中的任务。留空只能监测「意外退出」,无法判断停摆。
WorkflowID string `json:"workflow_id,omitempty"`
// SilenceMinutes 是多久没有任何活动才算停摆;0 表示用默认值(DefaultGuardSilenceMinutes)。
SilenceMinutes int `json:"silence_minutes,omitempty"`
// ResumeCommand 是会话已经结束时重新拉起用的一整行命令,其中 {chat_id} 会换成智能体最近一次汇报的对话编号。
// 留空表示只能在会话还活着时唤醒。
ResumeCommand string `json:"resume_command,omitempty"`
// WakePrompt 是唤醒时输入的提示词正文;留空用服务端的默认正文。支持 %n(第几次)、%max(上限)、%reason(原因)。
// 开头的「【系统唤醒 …】」由服务端固定加上;正文里不能有 shell 特殊字符(见 GuardPromptUnsafe)。
WakePrompt string `json:"wake_prompt,omitempty"`
// ExitEndsSession 为 true 时启动行使用 exec 包装命令,命令退出即会话结束(默认 false)。
ExitEndsSession bool `json:"exit_ends_session,omitempty"`
// Headless 是「非交互唤醒」(#113 M3.4,默认关闭):会话已经结束、你又点了「非交互唤醒」时,
// Hub 经这台主机的执行通道运行一次 `agent -p --resume <对话编号> …`,不打开终端。
Headless *HeadlessWake `json:"headless,omitempty"`
}
LauncherGuard 是终端启动器预设的「会话守护」配置(D-214)。
它只描述「怎么判断、怎么唤醒」,不会让任何东西自动运行:唤醒是人在界面里点一下之后, 由浏览器把一句固定的提示词输入到会话里(会话已经结束时,按 ResumeCommand 重新拉起再输入)。
func (LauncherGuard) EffectiveSilence ¶
func (g LauncherGuard) EffectiveSilence() time.Duration
EffectiveSilence 返回实际生效的停摆判定时长。
type LinkBranchInput ¶ added in v2.1.0
type LinkBranchInput struct {
ParentWorkflowID string
BranchWorkflowID string
// CreatedBy:human / agent:<主会话工作流编号> / migrate。
CreatedBy string
// Expose 为空时按 CreatedBy 取默认预设:migrate → 仅可见,其余 → 协作。
Expose *model.BranchExpose
// CopyUserNotes 为空时取默认值 true。
CopyUserNotes *bool
// SkipRateLimit 为 true 时不受「每小时新建数」限制(迁移命令)。
SkipRateLimit bool
}
LinkBranchInput 是建立一条分支关系的入参。
type LinkBranchResult ¶ added in v2.1.0
type LinkBranchResult struct {
Branch model.WorkflowBranch `json:"branch"`
Created bool `json:"created"` // 新写了一行
Reopened bool `json:"reopened"` // 把已关闭的关系重新打开
}
LinkBranchResult 是建立关系的结果。
func (LinkBranchResult) Noop ¶ added in v2.1.0
func (r LinkBranchResult) Noop() bool
Noop 表示关系早已存在且生效,这次什么都没改。
type MigrationItem ¶
type MigrationItem struct {
DocID uint `json:"doc_id"`
WorkflowID string `json:"workflow_id"`
FromPath string `json:"from_path"`
ToPath string `json:"to_path"`
Title string `json:"title"`
Reason string `json:"reason,omitempty"` // 空 = 路径不变;sheet | conflict(与 MigrationMove 同义)
}
MigrationItem 是一篇待并入项目的文档的去向(路径不变的也在内)。
Moves 只列「要改路径」的,看不出其余文档是谁;Items 把每一篇都列出来——用户确认迁移前要看清「每篇文档去哪」, 知识库页也靠它在迁移完成前继续列出这些还没并入的文档,不让它们从入口上消失(#131)。
type MigrationMove ¶
type MigrationMove struct {
DocID uint `json:"doc_id"`
WorkflowID string `json:"workflow_id"`
FromPath string `json:"from_path"`
ToPath string `json:"to_path"`
Reason string `json:"reason"` // sheet | conflict
}
MigrationMove 是一篇文档的去向。
type MigrationReport ¶
type MigrationReport struct {
ProjectID uint `json:"project_id"`
Workflows []string `json:"workflows"`
Docs int `json:"docs"` // 涉及的、尚未归入项目的文档数
Assigned int `json:"assigned"` // 其中原路径不变直接归入的
Moves []MigrationMove `json:"moves"` // 需要改路径的
Items []MigrationItem `json:"items"` // 全部待迁移的文档(= Docs 篇,含路径不变的);不参与哈希
Already int `json:"already"` // 已经在项目里的文档数
Unplaceable []string `json:"unplaceable,omitempty"` // 改路径后仍不合法(太长等)而跳过的文档说明
Hash string `json:"hash"`
Applied bool `json:"applied"`
}
MigrationReport 是迁移报告(dry-run 与确认后都用这个结构)。
type ModeInfo ¶
type ModeInfo struct {
WorkflowID string
Row model.WorkflowMode // 没有行时只有 WorkflowID 有值
State asyncmode.State
HookSeen time.Time // 最近一次见到该工作流的 hook;零值表示没见过(落库节流,重启后恢复,见 RestoreHookSeen)
// Profile 只在开启过异步的工作流上解析(回执里的 auth: 行要用);
// 没开启过的工作流不付这次查询的代价,也不需要它——界面要展示默认档位时自己取。
Profile *model.AuthProfile
}
ModeInfo 是某个工作流此刻的异步对话状态:用户的开关、有效模式的判定、选用的档位。
type ModePatch ¶
type ModePatch struct {
Enabled *bool
ProfileID *uint // 0 表示跟随默认档位
// StrictWrapup 开关「严格收尾门」(#232 D2):true = 开(默认),false = 关、回到老口径。
StrictWrapup *bool
}
ModePatch 是修改工作流异步状态的入参:只改非 nil 的字段。
type ModuleInput ¶
ModuleInput 新建 / 修改模块。
type ModulePageView ¶
type ModulePageView struct {
Module model.ProjectModule `json:"module"`
Children []model.ProjectModule `json:"children"`
OwnerLabel string `json:"owner_label,omitempty"`
Index *DocBrief `json:"index,omitempty"` // modules/<m>/index.md
Design *DocBrief `json:"design,omitempty"` // modules/<m>/design.md
Decisions []DocBrief `json:"decisions"`
Artifacts []DocBrief `json:"artifacts"` // 渲染类型不是 md 的
Docs []DocBrief `json:"docs"` // 其余
Recent []DocBrief `json:"recent"`
Tasks []ModuleTask `json:"tasks"`
}
ModulePageView 是模块页:总述 + 设计 + 决策 + 相关任务 + 最近修订 + 渲染型文档 + 负责人。
type ModuleTask ¶
type ModuleTask struct {
WorkflowID string `json:"workflow_id"`
Seq int `json:"seq"`
Title string `json:"title"`
State string `json:"state"`
}
ModuleTask 是模块页里的相关任务(按名称与任务看板的模块对齐,设计稿 06 §3.2;任务本身不动)。
type PageDiagStats ¶ added in v2.2.0
type PageDiagStats struct {
PageCount int64 `json:"page_count"`
PageLastAt *time.Time `json:"page_last_at,omitempty"`
BrowserCount int64 `json:"browser_count"`
BrowserLastAt *time.Time `json:"browser_last_at,omitempty"`
BrowserKeep int `json:"browser_keep"`
PageKeep int `json:"page_keep"`
BrowserReportsOn bool `json:"browser_reports_on"`
}
PageDiagStats 是两类上报当前的条数与最近一条的时间(给诊断面板看「收到过没有」用)。
type PageSearchInfo ¶ added in v2.2.0
PageSearchInfo 是页面响应里带的那一小段:{"mode":"index"} 或 {"mode":"legacy","reason":"too_short"}。
type ParamEffect ¶ added in v2.1.0
type ParamEffect struct {
Event string
Payload any // 事件 session_updated 时是 *model.FeedbackSession(调用方要走各自的载荷规整,不能原样广播)
}
ParamEffect 是一次参数写入(或撤销)之后要广播给网页的一条事件。
type PendingBranchAsk ¶ added in v2.1.0
type PendingBranchAsk struct {
Branch string `json:"branch"`
BranchTitle string `json:"branch_title,omitempty"`
Ref string `json:"ref"`
Title string `json:"title"`
Risk string `json:"risk"`
CreatedAt time.Time `json:"created_at"`
}
PendingBranchAsk 是主会话眼里一条在等它定夺的请示。
type PostGroupInput ¶
type PostGroupInput struct {
ConversationID string
SenderKind string // human | workflow
SenderRef string // GroupHumanRef | 工作流编号
Body string //
Mentions []string // 工作流编号 / all / human
ReplyTo string // m:<消息 id>
IdemKey string // Agent 重试保护;人发的不用
// 下面两个只用来拼投递给对方的提示前缀。
SenderLabel string // Agent 的身份标签
SenderProject string // Agent 所在项目(目录最后一段即可)
}
PostGroupInput 是发一条群消息的入参。
type PostGroupResult ¶
type PostGroupResult struct {
Message *model.ChatMessage
Group *model.Conversation
Recipients []string // 被扔进收件箱的工作流
Duplicate bool // 幂等键命中:没有新写入
Cooling bool // 群在冷却中:消息只落库、没有投递
CoolingStarted bool // 这一条触发了冷却(要通知你)
MentionsHuman bool // Agent 点名了你(或 @all):要穿透免打扰通知你
HopDropped bool // 回复链过长:消息没有落库
}
PostGroupResult 是一次发送的结果。
type ProjectBoardList ¶ added in v2.2.0
type ProjectBoardList struct {
// Boards:项目自己的板排第一(即使还没有任务——空项目也能在页面里建第一条任务),其余按最近有动静排。
Boards []ProjectBoardView `json:"boards"`
// DefaultBoard 是页面默认打开的板:项目板有任务(或别的板都没有任务)就是项目板,否则是最近有动静的那张有任务的板。
DefaultBoard string `json:"default_board"`
}
ProjectBoardList 是 ProjectBoardsOf 的结果。
type ProjectBoardView ¶ added in v2.2.0
type ProjectBoardView struct {
BoardKey string `json:"board_key"`
// Kind 是 ProjectBoardKindProject / ProjectBoardKindStandalone。
Kind string `json:"kind"`
// Own 为真:这是这个项目自己的项目板。
Own bool `json:"own"`
// ProjectID / ProjectName:项目板才有;别的项目的板(成员工作流从那边带来的任务)带项目名,页面据此起名。
ProjectID uint `json:"project_id,omitempty"`
ProjectName string `json:"project_name,omitempty"`
// WorkflowID 是代表这张板的工作流(任务接口按它解析到板);项目板还没有任何任务、成员又都不在这张板上时为空。
WorkflowID string `json:"workflow_id"`
// Members 是项目成员里「有任务、且任务在这张板上」的工作流。
Members []string `json:"workflows"`
// 下面几个数是整张板的(口径同任务清单的概况)。
Total int `json:"total"`
Active int `json:"active"`
Doing int `json:"doing"`
Review int `json:"review"`
UpdatedAt time.Time `json:"updated_at"`
}
ProjectBoardView 是项目相关的一张任务板。
type ProjectDocFilter ¶
type ProjectDocFilter struct {
WorkflowID string
Query string
Kinds []string
Statuses []string
Tag string
Prefix string
Limit int
IncludeArchived bool
// 项目范围(#114):ProjectID > 0 时按项目取(跨该项目的所有工作流),此时 WorkflowID 被忽略。
ProjectID uint
ModulePath string // 模块路径前缀(含子模块)
OwnerIdentityID uint
Render string
UpdatedAfter time.Time
// OmitBody:列表只要元数据(目录树、索引、选择器)时置 true,SQL 不再把正文列读出来(#177:正文是这张表最重的一列,
// 每次开页面列表都带着全文,生产上一个工作流的文档列表解压后 383 KB)。有 Query 过滤时仍要读正文来打分,此时本项不生效,
// 查完由调用方自己清空正文(见 api.ListProjectDocs)。返回的 Body 为空串,不代表文档是空的。
OmitBody bool
}
ProjectDocFilter 列表筛选。
type ProjectDocInput ¶
type ProjectDocInput struct {
WorkflowID string
Path string
Title string
Kind string
Status string
Tags []string
Body string
Summary string
// 项目知识库(#114):空 = 不绑定模块 / 默认渲染。模块必须已在项目里建立。
ModulePath string
Render string
}
ProjectDocInput 新建文档。
type ProjectDocPatch ¶
type ProjectDocPatch struct {
Title *string
Kind *string
Status *string
Tags *[]string
Body *string
Path *string
ModulePath *string // 空串 = 解除模块绑定
Render *string
Summary string
ExpectedRev int // 0 = 不校验
}
ProjectDocPatch 更新文档。
type ProjectDocSaveResult ¶
type ProjectDocSaveResult struct {
Doc *model.ProjectDoc
Changed bool
Unchanged bool
Warnings []string
}
ProjectDocSaveResult 保存结果。
type ProjectInput ¶
ProjectInput 新建项目。
type ProjectPatch ¶
ProjectPatch 修改项目。
type ProjectSearchFilter ¶
type ProjectSearchFilter struct {
ProjectID uint
Query string
ModulePath string
Kinds []string
Statuses []string
Tag string
OwnerIdentityID uint
Render string
UpdatedAfter time.Time
Limit int
}
ProjectSearchFilter 项目范围搜索的条件。
type ProjectSearchHit ¶
type ProjectSearchHit struct {
docs.SearchHit
DocID uint `json:"doc_id"`
WorkflowID string `json:"workflow_id"`
ModulePath string `json:"module_path,omitempty"`
Kind string `json:"kind"`
Status string `json:"status"`
Render string `json:"render,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
ProjectSearchHit 是一条项目范围的命中(在单工作流命中的基础上带上归属信息,让界面能直接打开)。
type ProjectStats ¶
type ProjectStats struct {
Dirs int `json:"dirs"`
Modules int `json:"modules"`
Docs int `json:"docs"`
Workflows int `json:"workflows"`
}
ProjectStats 是项目的几个计数,给列表与详情用。
type ProjectSuggestion ¶
type ProjectSuggestion struct {
HostName string `json:"host_name"`
ProjectDirectory string `json:"project_directory"`
SuggestedName string `json:"suggested_name"`
SuggestedSlug string `json:"suggested_slug,omitempty"`
Workflows []string `json:"workflows"`
Docs int `json:"docs"`
}
ProjectSuggestion 是一个「待确认的项目建议」:一个还没有归属项目的(主机,目录),以及落在那里的工作流与文档数。
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"`
Kind string `json:"kind,omitempty"` // append(默认)| answer(确认项答复,不并入 interactive_feedback 秒回)
}
QueueFeedbackInput 是 Web 上追加一条消息的入参。
type RebindRequest ¶
RebindRequest 描述一次改绑:目标目录必填,目标主机为空表示不改主机。
type RebindResult ¶
type RebindResult struct {
Before WorkflowBinding `json:"before"`
After WorkflowBinding `json:"after"` // 预演时等于 Before
TargetDir string `json:"target_dir"` // 规整后的目标目录
TargetHost string `json:"target_host"` // 规整后的目标主机(空 = 不改)
SessionsToMove int64 `json:"sessions_to_move"` // 需要改写(预演)或已改写(执行)的会话行数
QueuedToMove int64 `json:"queued_to_move"`
Applied bool `json:"applied"`
}
RebindResult 是一次改绑(或预演)的结果。
type ReplyRef ¶
type ReplyRef struct {
Session model.FeedbackSession
// Turn 是它在工作流里按创建时间数的轮次序号(从 1 开始,与界面上的「第 N 轮」一致);
// 进度通知不占轮次,为 0。
Turn int
}
ReplyRef 是一个哈希解析出的会话。
type ResidentParam ¶ added in v2.1.0
type ResidentParam struct {
Text string `json:"text"`
Rev int `json:"rev"`
UpdatedBy string `json:"updated_by,omitempty"` // 最近一次保存常驻规则的操作者(用户登录名或 agent:<主会话>)
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}
ResidentParam 是常驻规则的当前值与来源。
type ResolvedGuiTarget ¶ added in v2.2.0
type ResolvedGuiTarget struct {
Host string
Repo string
TextMode string
// Source 是它从哪来:目标编号,或 "default"。
Source string
}
ResolvedGuiTarget 是为某个工作流解析出来的目标。
type RetractionEvent ¶
type RetractionEvent struct {
ID uint `json:"id"`
RetractedAt time.Time `json:"retracted_at"`
Read bool `json:"read"` // 撤回前它读到过全文;false 表示只是被 hook / 提示行提醒过
}
RetractionEvent 是「智能体知道的追加后来被用户撤回了」的一条记录:只有编号与时间,不含正文(#199)。
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"`
// Delivered:撤回的是一条智能体已经读取过的追加(收件箱),会在它下次读取时被告知忽略。
Delivered bool `json:"delivered,omitempty"`
// AgentNotified:撤回时智能体已经知道这条追加存在(读取过全文,或被 hook / 提示行提醒过),它会被告知忽略这一条(#199)。
// 比 Delivered 宽:只被提醒过、还没读的也算;界面据此提示「已撤回,会告知忽略」。
AgentNotified bool `json:"agent_notified,omitempty"`
}
type RunFilter ¶
type RunFilter struct {
Target string
ThreadKey string
CredentialID uint
// CredentialName 与 Thread 按调用方名字与线程标签精确匹配(内部身份没有凭据编号,靠名字与标签认领自己的运行)。
CredentialName string
Thread string
States []string
BeforeID uint
Limit int
}
RunFilter 是模型运行列表的过滤条件。
type SSHCheck ¶
type SSHCheck struct {
At time.Time
OK bool
Err string // 已净化、不含凭据
KeyMismatch bool // 主机密钥与固定值不一致:置位后保持,直到管理员重新确认指纹
Hostname string
OS string
Arch string
// TermOnly 非 nil 时(仅成功的检查)刷新「只能当人工终端用」标记:目标环境可能被重装成了别的系统。
TermOnly *bool
}
SSHCheck 是一次连接尝试的结果。
type SSHConnUpdate ¶
type SSHConnUpdate struct {
Addr *string
User *string
Auth *string
Secret *string // 已密封
HostKeyType *string
HostKey *string
Fingerprint *string
KeyState *string
Error *string // 最近一次失败的原因;重新固定主机密钥时用它清除旧的错误
Gateway *string // 网关主机的机器码;空串表示改为由 Hub 直连
TermOnly *bool // 经网关接入的主机是否只能当人工终端用(探测不出 POSIX 环境)
}
SSHConnUpdate 是对 SSH 主机连接信息的部分更新:nil 表示不改。
type SearchCandidateQuery ¶ added in v2.2.0
type SearchCandidateQuery struct {
Q string
Kind string // 一次只查一类内容:SearchKinds 之一
// 范围:都不给 = 不限定(页面自己的条件决定最终能看到什么);给了就把候选限定在这个项目 / 工作流名下。两者互斥。
ProjectID uint
WorkflowID string
IncludeArchived bool // 含已归档的文档 / 会话 / 群聊;页面正在显示归档内容时才传
}
SearchCandidateQuery 是一次页面搜索向索引要候选集的请求。
type SearchHintsConfig ¶ added in v2.2.0
type SearchHintsConfig struct {
Enabled bool `json:"enabled"`
Max int `json:"max"`
Threshold float64 `json:"threshold"`
SessionThreshold float64 `json:"session_threshold"`
PerHour int `json:"per_hour"`
}
SearchHintsConfig 是相关线索五项设置的当前值。
func DefaultSearchHintsConfig ¶ added in v2.2.0
func DefaultSearchHintsConfig() SearchHintsConfig
DefaultSearchHintsConfig 是没改过时的值:开 / 3 条 / 0.60(会话类 0.70)/ 每小时 30 次。
func (SearchHintsConfig) QueryFloor ¶ added in v2.2.0
func (c SearchHintsConfig) QueryFloor() float64
QueryFloor 是向语义检索要候选时用的下限:各类下限里最低的那个,保证哪一类的下限调得再低,候选也不会在查询那一层就被截掉; 之后每条命中还要再按自己那一类的下限筛一次(见 internal/mcp/hints.go 的 hintsFromHits)。
func (SearchHintsConfig) ThresholdFor ¶ added in v2.2.0
func (c SearchHintsConfig) ThresholdFor(kind string) float64
ThresholdFor 返回某一类线索要达到的相似度下限:会话汇报类用 SessionThreshold,其余类(文档 / 任务 / 确认项)用 Threshold。 SessionThreshold 不是正数(只会出现在没经过校验、直接写出来的结构里)就当作没单独设,会话类也用 Threshold。
func (SearchHintsConfig) Validate ¶ added in v2.2.0
func (c SearchHintsConfig) Validate() error
Validate 检查各个数都在范围内(开关不需要)。
type SearchHintsFloatRange ¶ added in v2.2.0
SearchHintsFloatRange 是相似度下限允许的范围(含两端)。
type SearchHintsIntRange ¶ added in v2.2.0
SearchHintsIntRange 是整数项允许的范围(含两端)。
type SearchHintsLimits ¶ added in v2.2.0
type SearchHintsLimits struct {
Max SearchHintsIntRange `json:"max"`
Threshold SearchHintsFloatRange `json:"threshold"`
SessionThreshold SearchHintsFloatRange `json:"session_threshold"`
PerHour SearchHintsIntRange `json:"per_hour"`
}
SearchHintsLimits 是各项允许的范围,设置页拿它给输入框标范围、做同样的校验。
func SearchHintsBounds ¶ added in v2.2.0
func SearchHintsBounds() SearchHintsLimits
SearchHintsBounds 返回各项的范围。
type SearchHintsPatch ¶ added in v2.2.0
type SearchHintsPatch struct {
Enabled *bool
Max *int
Threshold *float64
SessionThreshold *float64
PerHour *int
}
SearchHintsPatch 是一次局部修改:nil 表示这一项不动。
func (SearchHintsPatch) Empty ¶ added in v2.2.0
func (p SearchHintsPatch) Empty() bool
Empty 表示一项都没给。
type SearchHit ¶ added in v2.2.0
type SearchHit struct {
Kind string `json:"kind"`
Ref string `json:"ref"`
Title string `json:"title"`
Snippet string `json:"snippet,omitempty"`
WorkflowID string `json:"workflow_id,omitempty"`
ProjectID uint `json:"project_id,omitempty"`
ConversationID string `json:"conversation_id,omitempty"`
Seq int64 `json:"seq,omitempty"`
Path string `json:"path,omitempty"`
Status string `json:"status,omitempty"`
Sub string `json:"sub,omitempty"`
Actor string `json:"actor,omitempty"`
Archived bool `json:"archived,omitempty"`
TitleMatch bool `json:"title_match"`
UpdatedAt time.Time `json:"updated_at"`
// contains filtered or unexported fields
}
SearchHit 是一条命中。字段按类型取用:文档带 Path,任务 / 确认项带 Seq(板内 / 工作流内序号),群消息带会话与会话内序号。
type SearchIndexStatus ¶ added in v2.2.0
type SearchIndexStatus struct {
Enabled bool `json:"enabled"`
Available bool `json:"available"`
Reason string `json:"reason,omitempty"` // 不可用的原因代码:disabled | env_off | unsupported
Detail string `json:"detail,omitempty"`
Building bool `json:"building"` // 还有类型没回填完(结果可能不完整)
Rebuilding bool `json:"rebuilding"`
SchemaVersion int `json:"schema_version"`
Stale int64 `json:"stale"`
Pending int `json:"pending"` // 内存里尚未处理的脏行数
LastSyncMs int64 `json:"last_sync_ms"` // 最近一次完整对账完成的时间
Kinds []SearchKindStatus `json:"kinds"`
// PageIndex 是设置里「页面搜索走全文索引」的开关(#266 / 1c;索引不可用时它也照实回显,只是页面会回退);
// PageIndexPages 是已经接入这个开关的页面(见 PageSearchWired)。
PageIndex bool `json:"page_index"`
PageIndexPages []string `json:"page_index_pages"`
}
SearchIndexStatus 是全文索引的整体状态(运维与 Web 设置页展示用)。
type SearchKindStatus ¶ added in v2.2.0
type SearchKindStatus struct {
Kind string `json:"kind"`
Indexed int64 `json:"indexed"` // 索引里有条目的行数
Source int64 `json:"source"` // 源表里应被索引的行数
// ReadyAt 是这一类完成回填的时间(Unix 毫秒);0 = 还没回填完。
ReadyAt int64 `json:"ready_at"`
}
SearchKindStatus 是一类内容的索引概况。
type SearchQuery ¶ added in v2.2.0
type SearchQuery struct {
Q string
Kinds []string // 空 = 全部类型
ProjectID uint // 限定在一个项目内
WorkflowID string // 限定在一个工作流内(与 ProjectID 互斥)
IncludeArchived bool // 含已归档的文档 / 会话 / 群聊
Limit int // 默认 20,最多 100
Cursor string // 上一页返回的 NextCursor
}
SearchQuery 是一次全文检索请求。ProjectID 与 WorkflowID 都为空表示全库(调用方必须自己确认调用者有全库权限)。
type SearchResult ¶ added in v2.2.0
type SearchResult struct {
Hits []SearchHit `json:"hits"`
NextCursor string `json:"next_cursor,omitempty"`
// Truncated:页没满、而且某个类型的扫描量触顶,结果可能不全;NextCursor 指向没扫完的位置,可以接着扫,也可以缩小范围或换更具体的词。
Truncated bool `json:"truncated,omitempty"`
// Building:还有类型没回填完,结果可能不完整。
Building bool `json:"building,omitempty"`
// TooShort:查询没有可走索引的内容(只剩单个汉字、纯标点……),没有执行。
TooShort bool `json:"too_short,omitempty"`
// Terms 是归一后的查询词,前端用来高亮。
Terms []string `json:"terms,omitempty"`
}
SearchResult 是一页结果。
type SearchUnavailableError ¶ added in v2.2.0
type SearchUnavailableError struct {
}
SearchUnavailableError 表示全文索引现在不能用;Reason 是给调用方分支用的稳定代码。
func (*SearchUnavailableError) Error ¶ added in v2.2.0
func (e *SearchUnavailableError) Error() string
type SecuritySettings ¶
type SemanticKey ¶ added in v2.2.0
type SemanticKey struct{ Kind, Ref string }
SemanticKey 是「类型 + ref」。
type SemanticMessage ¶ added in v2.2.0
SemanticMessage 是一段群消息里的一条消息。
type SemanticRun ¶ added in v2.2.0
type SemanticRun struct {
Enabled bool `json:"enabled"`
Paused bool `json:"paused"`
// PauseReason 非空表示是「自动暂停」(外呼失败等需要人处理的原因,已打码,可直接展示);空 = 用户自己暂停的。
PauseReason string `json:"pause_reason,omitempty"`
Kinds []string `json:"kinds"`
}
SemanticRun 是语义检索的运行设置:总开关、暂停、允许外发的内容类型。 勾选的项目在 embed_projects 表里,不在这里。默认全部关闭(总开关关、没有项目),类型默认五类都发(Q145)。
func DefaultSemanticRun ¶ added in v2.2.0
func DefaultSemanticRun() SemanticRun
DefaultSemanticRun 是从未保存过设置时的值:总开关关,类型是最初的五类(见 semanticDefaultKinds;「用户追加」要自己勾选)。
type SemanticScope ¶ added in v2.2.0
type SemanticScope struct {
// contains filtered or unexported fields
}
SemanticScope 是一次查询解析好的可见范围,与词法检索同一套(项目成员、群的归属)。
func (*SemanticScope) AllowsMeta ¶ added in v2.2.0
func (c *SemanticScope) AllowsMeta(kind, workflowID string, projectID uint, conversationID string) bool
AllowsMeta 按「嵌入时记下的归属快照」判断一个条目在不在范围内(内存里先筛用;最终仍要回源再核)。
type SemanticSet ¶ added in v2.2.0
type SemanticSet map[string]map[string]SemanticSourceInfo
SemanticSet 是 类型 → ref → 信息。
type SemanticSourceInfo ¶ added in v2.2.0
type SemanticSourceInfo struct {
FP string
WorkflowID string
ProjectID uint
ConversationID string
Chars int64 // 标题 + 正文的大致字符数(SQL 里 length 求和,用来估算 token)
// Owners 是这个条目属于哪些项目(升序):设置页据此把条目按项目统计。
// 它只用于统计展示,不参与同意范围的判断(范围由 SemanticEligible 的入参与 ProjectID / WorkflowID / ConversationID 决定)。
// 文档的归属是它的项目;任务是板所属的项目与所在工作流的成员项目;确认项与会话汇报是工作流的成员项目;群消息段是群的成员项目。
Owners []uint
}
SemanticSourceInfo 是一个在范围内的候选条目:版本戳、归属快照、体积。
type SemanticStats ¶ added in v2.2.0
type SemanticStats struct {
Entries int64 `json:"entries"` // 已嵌入的条目(state=ok)
Skipped int64 `json:"skipped"` // 判定为不嵌入的条目(内容太短)
Failed int64 `json:"failed"` // 服务拒绝嵌入的条目(sig 以 failed| 开头)
Chunks int64 `json:"chunks"` // 向量块总数
StaleSig int64 `json:"stale_sig"` // 签名与当前不同的条目(需要重建)
VecBytes int64 `json:"vec_bytes"` // 向量数据体积(按「块数 × 维度」折算,不含索引与行开销)
Truncated int64 `json:"truncated"` // 超长被截断的条目
}
SemanticStats 是向量库的体量。
type SemanticText ¶ added in v2.2.0
type SemanticText struct {
Kind, Ref, FP string
// EmbedTitle 是嵌入时放在每块最前面的标题行(文档含路径与标签,会话汇报可能为空);
// Body 是正文。群消息段没有正文,用 Messages(按 Seq 升序)。
EmbedTitle string
Body string
Messages []SemanticMessage
// 归属与展示字段(与词法检索的命中同口径)。
WorkflowID string
ProjectID uint
ConversationID string
Seq int64
Path string
Status string
Sub string
DisplayTitle string // 群消息段是群名
Archived bool
UpdatedAt time.Time
}
SemanticText 是一个条目回源后的最新原文与归属,嵌入与回源校验共用。
type SessionKindFilter ¶ added in v2.2.0
type SessionKindFilter string
SessionKindFilter 选择按工作流读会话时包含哪些行。
const ( // SessionsAll 汇报轮次与进度通知都要(默认)。 SessionsAll SessionKindFilter = "" // SessionsRounds 只要真正的汇报轮次。 SessionsRounds SessionKindFilter = "round" // SessionsNotices 只要异步模式下发布的进度通知。 SessionsNotices SessionKindFilter = "notice" )
type SessionParamValues ¶ added in v2.1.0
type SessionParamValues struct {
Resident ResidentParam `json:"resident"`
Phase string `json:"phase"`
WakeResume string `json:"wake_resume"` // 会话自己的模板;空串 = 没设,用全局 / 内置默认
WakeNew string `json:"wake_new"`
Title string `json:"title"`
Async AsyncParam `json:"async"`
}
SessionParamValues 是分支各个会话参数的当前值(不含授权档位、凭据、目录与主机——那些永不经这条路径读写)。
type SessionParamsPatch ¶ added in v2.1.0
type SessionParamsPatch struct {
Resident *string // 常驻规则;空串 = 清除
Phase *string // discuss / plan / dev(旧编号会换算)
WakeResume *string // 续聊唤醒词;空串 = 清除,回到全局 / 内置
WakeNew *string // 新开对话唤醒词;非空必须带 %workflow
Title *string // 标题(一行)
Async *bool // 异步对话开关:只能关,或恢复用户开启过的
}
SessionParamsPatch 是主会话要改的参数:只改非 nil 的字段。
func ParseSessionParamsPatch ¶ added in v2.1.0
func ParseSessionParamsPatch(raw map[string]any) (SessionParamsPatch, error)
ParseSessionParamsPatch 把 MCP 传来的 patch 对象翻成 SessionParamsPatch:只做键与类型层面的检查, 取值规则(字数、阶段枚举、%workflow…)与权限在 ApplySessionParams 里统一判定。
func (SessionParamsPatch) Fields ¶ added in v2.1.0
func (p SessionParamsPatch) Fields() []string
Fields 返回这次要改的字段,顺序固定(与 model.BranchParamFields 一致)。
type SessionParamsView ¶ added in v2.1.0
type SessionParamsView struct {
Branch string `json:"branch"`
Parent string `json:"parent"`
Title string `json:"title,omitempty"`
Role string `json:"role"` // main | branch
Level string `json:"level"` // 「改参数」档位:off / resident / resident_phase / all
// Editable 是调用者现在能改的字段;分支本人与 off 档恒为空。
Editable []string `json:"editable"`
// Values 在主会话读 off 档的分支时为空(常驻规则全文可能含用户写给分支的私货);分支读自己的参数恒有。
Values *SessionParamValues `json:"values,omitempty"`
}
SessionParamsView 是 session_params(get) 的结果。
type SidebarOrder ¶ added in v2.2.0
type SidebarOrder struct {
Version int64 `json:"version"`
Keys []string `json:"keys"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}
SidebarOrder 是侧栏的手动顺序。从未写过时 Version 为 0、Keys 为空切片(不是 nil,JSON 里是 [])。
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AckKeyNotice ¶ added in v2.2.0
func (s *Store) AckKeyNotice(ctx context.Context, sessionID string, at time.Time) (*model.FeedbackSession, bool, error)
AckKeyNotice 记下用户在网页上确认了一条重点通知;返回确认之后的会话行,以及这一次是不是真的改了(false = 之前已经确认过)。
只对 kind = notice 且 notice_level = key 的行有效,其余返回 InvalidInput(那条消息没有什么可确认的);会话不存在返回 NotFound。
func (*Store) AckReports ¶
func (*Store) ActivateCredential ¶
ActivateCredential 启用凭据(OAuth 授权码首次兑换后)。
func (*Store) ActiveBranchLinks ¶ added in v2.1.0
ActiveBranchLinks 一次取一个工作流的活动关系;没有任何关系的工作流返回零值(回执头据此一个字都不输出)。
func (*Store) ActiveGrantsFor ¶
func (s *Store) ActiveGrantsFor(ctx context.Context, projectID, identityID uint, groupRefs []string) ([]acl.Grant, error)
ActiveGrantsFor 给判定函数用:这个身份(以及它所在的群)在项目里有效的授权。
func (*Store) ActiveGrantsForCaller ¶
func (s *Store) ActiveGrantsForCaller(ctx context.Context, projectID, identityID uint, workflowID string) ([]acl.Grant, error)
ActiveGrantsForCaller 在 ActiveGrantsFor 的基础上补上调用方所在的群(群共享授权)。
func (*Store) AddArtifactComment ¶
func (s *Store) AddArtifactComment(ctx context.Context, in ArtifactCommentInput) (*model.ArtifactComment, error)
AddArtifactComment 新增一条评论。
func (*Store) AddAuditEvent ¶
AddAuditEvent 写一条审计;返回是否真的写入(被去重则为 false)。
func (*Store) AddConversationEvent ¶
func (s *Store) AddConversationEvent(ctx context.Context, ev model.ConversationEvent) (*model.ConversationEvent, error)
AddConversationEvent 写一条会话系统事件。Text 是给人看的一句话(不超过 400 字,超出会被截断)。
func (*Store) AddGroupMembers ¶
func (s *Store) AddGroupMembers(ctx context.Context, groupID, actor string, workflowIDs []string) error
AddGroupMembers 把工作流拉进群(只有你能做);已离开的成员重新加入时从现在起看消息。
func (*Store) AddPageDiagReport ¶ added in v2.2.0
AddPageDiagReport 新增一条上报,并在同一个事务里把「同一类」里超出 keep 条的旧记录清掉(keep ≤ 0 按这一类的默认条数)。 返回的 r 带上自增编号与创建时间。
func (*Store) AddProjectDir ¶
func (s *Store) AddProjectDir(ctx context.Context, projectID uint, host, dir, branchHint string) (*model.ProjectDir, error)
AddProjectDir 把(主机,目录)归入项目。同一个目录已经在别的项目里 → 冲突并说明在哪个项目。
func (*Store) AddReport ¶
func (s *Store) AddReport(ctx context.Context, input model.AddReportInput) (*model.ReportResult, error)
func (*Store) AdvanceConversationRead ¶
func (s *Store) AdvanceConversationRead(ctx context.Context, conversationID, readerKind, readerRef string, ms, seq int64) (model.ConversationRead, error)
AdvanceConversationRead 把已读游标推到 (ms, seq):两个分量各自只增不减(多设备、乱序请求取最大值)。 返回推进之后的游标。ms、seq 传 0 表示该分量不动。
func (*Store) AdvanceGroupRead ¶
func (s *Store) AdvanceGroupRead(ctx context.Context, groupID, readerKind, readerRef string, seq int64) error
AdvanceGroupRead 把某个读者在群里的已读游标推到 seq(只增不减)。
func (*Store) AgentCursorVersion ¶
AgentCursorVersion 返回工作流最近一个 Agent 会话报告的 cursor 版本(屏幕扫描器的版本闸门要用);不知道返回空串。 先看内存(hook 事件刚推进过的会话),再退到库里最近一行有版本的会话。
func (*Store) AgentLastActivity ¶
AgentLastActivity 返回某个工作流的智能体最近一次调用 RelayMesh 的时间(服务重启后从头记)。
func (*Store) AgentLinkOf ¶
AgentLinkOf 返回某个工作流的智能体最近的运行情况;内存里没有对话编号(比如刚重启过)时,用落库的那一份补上。
func (*Store) AgentSearchAccess ¶ added in v2.2.0
func (s *Store) AgentSearchAccess(ctx context.Context) (AgentSearchAccess, error)
AgentSearchAccess 读开关;没设过(或值认不出)的那一项取默认值。
func (*Store) AgentSearchQuota ¶ added in v2.2.0
func (s *Store) AgentSearchQuota(ctx context.Context) (AgentSearchQuota, error)
AgentSearchQuota 读三项额度;没设过(或值认不出)的那一项取默认值。search 工具每次调用都会读一次,三行主键查询,开销可以忽略。
func (*Store) AnswerConfirmBatch ¶
func (s *Store) AnswerConfirmBatch(ctx context.Context, workflowID string, items []ConfirmBatchItem, adoptRecommended bool) (*ConfirmBatchResult, error)
AnswerConfirmBatch 批量作答,整批原子:只要有一项不合格(不存在 / 已处理 / 选项非法 / 没有可采用的推荐 / L2), 整批都不落库,错误里一次列出全部问题。L2 项永远不进批量:不可逆的决定必须逐条确认。 adoptRecommended=true 时,没写选项的项取各自的推荐选项(单选取第一个、多选取全部)。
func (*Store) AnswerConfirmItem ¶
func (s *Store) AnswerConfirmItem(ctx context.Context, workflowID, ref string, in ConfirmAnswerInput) (*model.ConfirmItem, error)
AnswerConfirmItem 单条作答。第二次作答(并发或重复点击)返回 409;作答与投递在同一事务里。
func (*Store) AppendTerminalAudit ¶
AppendTerminalAudit 追加一条审计记录。
func (*Store) ApplyMigration ¶
func (s *Store) ApplyMigration(ctx context.Context, projectID uint, expectHash string) (*MigrationReport, error)
ApplyMigration 确认迁移:重新计算计划,哈希与 dry-run 的不一致就拒绝;一致才在一个事务里落库。
func (*Store) ApplySessionParams ¶ added in v2.1.0
func (s *Store) ApplySessionParams(ctx context.Context, caller, target string, patch SessionParamsPatch, now time.Time) (*ApplyParamsResult, error)
ApplySessionParams 是 session_params(set):校验—写—事件—审计。caller 必须是 target 的主会话,关系仍然生效, 且开放范围的「改参数」档位够改每一个要改的字段。先校验后写:任何一项不过,整条拒绝、一个字段也不写。
func (*Store) ApplyWorkPlan ¶
func (s *Store) ApplyWorkPlan(ctx context.Context, workflowID string, plan []WorkPlanNode, reorder bool) (*WorkPlanResult, error)
ApplyWorkPlan 把一份规划声明落到工作流所在任务板的规划树上(同一个项目的工作流共用一棵树):
- 不存在的节点新建(追加在同级末尾),已存在的保持原位,所以重复提交同一份计划是幂等的;
- 带 rename 的节点改名,带 remove 的节点移除(必须没有任务也没有剩余功能),description 不为空时更新说明;
- reorder=true 时,计划里列出的同级节点按给定顺序排到前面(没列出的保持原有相对顺序,跟在后面);
- 整个调用在一个事务里:任何一个节点不合法,整份计划都不生效。
func (*Store) ApplyWorkPlanAs ¶ added in v2.2.0
func (s *Store) ApplyWorkPlanAs(ctx context.Context, workflowID string, plan []WorkPlanNode, reorder, appendOnly bool) (*WorkPlanResult, error)
ApplyWorkPlanAs 是 ApplyWorkPlan 的完整形态:appendOnly 为真时这次规划只能追加(#284)—— 别的工作流建的节点只读(改名、移除、改说明都被拒绝,同名节点直接沿用),也不能 reorder(同级顺序是整棵树共有的); 自己建的节点照常能改。MCP 层对「沿用主会话任务板的分支」传 true:它能往主会话的规划树里追加自己的模块 / 功能,但不能动已有的。 人在网页上改规划树走的是节点级的增删改接口,不经这里。
func (*Store) ArchiveFeedbackSession ¶
func (*Store) ArchiveProject ¶
ArchiveProject 归档项目:目录归属保留,文档照常可读;只是从默认列表里消失。
func (*Store) ArchiveProjectDoc ¶
func (s *Store) ArchiveProjectDoc(ctx context.Context, docID uint, actor DocActor) (*model.ProjectDoc, error)
ArchiveProjectDoc 归档(MCP delete 只归档)。
func (*Store) ArtifactDataDelete ¶
ArtifactDataDelete 删除一个键;返回是否真的删了。
func (*Store) ArtifactDataGet ¶
func (s *Store) ArtifactDataGet(ctx context.Context, docID uint, key string) (*model.ArtifactData, error)
ArtifactDataGet 读一个键;不存在返回 NotFound。
func (*Store) ArtifactDataList ¶
ArtifactDataList 列出一篇文档的全部键,按键名排序。
func (*Store) ArtifactDataSet ¶
func (s *Store) ArtifactDataSet(ctx context.Context, in ArtifactDataSetInput) (*model.ArtifactData, error)
ArtifactDataSet 写一个键(不存在则新建),校验 JSON 合法、总量与键数上限。
func (*Store) AsyncWindowTimes ¶
AsyncWindowTimes 返回全局设置里的「每条新消息加多久」与「单次计时器最长等多久」(没设过用默认值)。
func (*Store) BackfillDecisionConfirmItems ¶
BackfillDecisionConfirmItems 启动时给「升级前就存在的文档」补上决策卡对应的确认项(第一波只解析展示,没有确认项)。 幂等,对已经同步过的文档不写库;单篇失败只记日志,不拖垮启动。
func (*Store) BackfillHiddenOAuthCredentialTokens ¶
BackfillHiddenOAuthCredentialTokens 将可预测的 rm-oauth-internal-* 令牌重写为随机值(幂等)。
func (*Store) BeatReplyWindow ¶
func (s *Store) BeatReplyWindow(ctx context.Context, workflowID string, now time.Time) (ReplyWindow, error)
BeatReplyWindow 记一次输入心跳:窗口走动中时,把距上一次心跳的间隔(不超过新鲜期)加进窗口,等于暂停倒计时。 暂停中(有任务)的窗口本来就不走,心跳不改动它。
func (*Store) BoardDigestFor ¶ added in v2.1.0
func (s *Store) BoardDigestFor(ctx context.Context, workflowID string, now time.Time, staleAfter time.Duration) (*BoardDigest, error)
BoardDigestFor 返回工作流 workflowID 在共享任务板上该处理的协作待办。staleAfter ≤ 0 用默认值。 工作流编号为空、或板上没有任何协作指派时返回空的汇总(不是错误)。
func (*Store) BoardGuestOf ¶ added in v2.2.0
func (s *Store) BoardGuestOf(ctx context.Context, workflowID string) (parent string, ended bool, err error)
BoardGuestOf 说明工作流是不是它所在那张板的「客人」(#284):它是(或曾是)某个主会话的分支,用着主会话的板,而它自己的会话目录并不属于这张板—— 活动期间沿用主会话的板(BoardWhyInherited),或者关系结束之后名下的任务仍把它钉在主会话的板上。 客人在这张板上对别人建的任务和规划节点只读(MCP 层据此强制,见 newWorkPolicy),只能新建自己的、接手指派给自己的; 关系结束不收回这条限制,否则「结束分支」会让它在主会话的板上反而比活动时权限更大。
parent 是主会话的工作流编号,ended 表示关系已结束;不是客人返回空串。 按任务数归板的老分支(钉在自己的独立板上、或钉在与主会话不同的板上)不算:那不是主会话的板,碰不到主会话的任务。
func (*Store) BoardKeyOf ¶
BoardKeyOf 返回工作流现在使用的板(见 boardKeyOn)。
func (*Store) BoardOfferedByWorkflow ¶ added in v2.1.0
func (s *Store) BoardOfferedByWorkflow(ctx context.Context) ([]BoardOffered, error)
BoardOfferedByWorkflow 一次查出所有工作流各自的待接取个数与最早派出时间(只返回个数大于 0 的),个数多的在前。 待接取的指派在任何时刻都很少(生产现状个位数),一条查询取出、在 Go 里汇总;不用 SQL 聚合是为了让时间列按类型解析。
func (*Store) BoardWhyOf ¶ added in v2.2.0
BoardWhyOf 返回工作流现在落在哪张板、为什么(见 BoardWhy)。
func (*Store) BoardWorkflowIDs ¶
BoardWorkflowIDs 列出一张板上能被指派的工作流(#175 B2b,详情里「指派」下拉用): 项目板 = 项目里的全部工作流(最近一次汇报会话的目录落在项目目录里的)加上已经在这张板上建过任务的工作流 (它们的会话目录后来即使被移出项目,任务仍在板上,按「粘性归板」仍然属于这张板,checkAssignee 也认), 再加上沿用这张板的活动分支(#284,见 inheritedBoardOn);独立板没有可指派的对象,返回空列表。
func (*Store) BranchAnswer ¶ added in v2.1.0
func (s *Store) BranchAnswer(ctx context.Context, in BranchAnswerInput) (*model.ConfirmItem, error)
BranchAnswer 主会话代为定夺分支里的一条请示。校验见 routedAskTx;平台兜底开关开着时 L2 请示一律拒绝(只能转交); 答复内容与确认卡同一套校验;By=agent:<主会话>;答复行进分支收件箱并带上 actor=main;先到先得(用户先答则返回冲突)。
func (*Store) BranchBriefs ¶ added in v2.1.0
func (s *Store) BranchBriefs(ctx context.Context, rows []model.WorkflowBranch) []BranchBrief
BranchBriefs 给一批关系补上标题、最近活动、是否在等回复、主会话未读数、是否已失效。
func (*Store) BranchEscalate ¶ added in v2.1.0
func (s *Store) BranchEscalate(ctx context.Context, in BranchEscalateInput) (*model.ConfirmItem, error)
BranchEscalate 主会话把分支里一条请示转交给用户:校验同 BranchAnswer(不看兜底开关);addressee 清空、记 escalated_at 与说明。
func (*Store) BranchFeed ¶ added in v2.1.0
BranchFeed 取一个会话页的分支消息流。limit 为每个来源保留的最新条数(默认 100)。 角色:作为分支(有关系行,含已结束)= branch;有分支(含已结束)= main;都没有 = none(历史消息仍会列出)。
func (*Store) BranchSay ¶ added in v2.1.0
func (s *Store) BranchSay(ctx context.Context, in BranchSayInput) (*BranchSayResult, error)
BranchSay 主会话 → 分支(要求开放范围的 say 开)或 分支 → 主会话(恒允许)。一律送达对方收件箱,不需要点名。 限额:同一发送方每小时 BranchSayPerHour 条;同一发送方发给同一接收方、对方未读的最多 BranchUnreadCap 条(防互相回复形成环路)。
func (*Store) BranchScopeOf ¶ added in v2.1.0
func (s *Store) BranchScopeOf(ctx context.Context, parent string) (map[string]WorkBranchScope, error)
BranchScopeOf 返回一个工作流作为主会话时与各个分支(含已结束的)在任务派单上的关系,键是分支工作流编号;没有分支返回 nil(#236 P5)。 入口层(MCP)在进入 store 的写入之前调用,结果放进 WorkActor.Branches:store 的事务里不能再回头查库。
func (*Store) CancelFeedbackSession ¶
func (*Store) CheckFeedback ¶
func (s *Store) CheckFeedback(ctx context.Context, input model.CheckFeedbackInput) (*model.CheckFeedbackResult, error)
func (*Store) ClaimConversation ¶
func (s *Store) ClaimConversation(ctx context.Context, workflowID, conv string, until, now time.Time) ([]string, error)
ClaimConversation 认领一个对话:Hub 发起的非交互运行清楚自己在跑哪个对话(新开对话从输出里学到,续聊的在命令里), 也清楚这次运行是替哪个工作流跑的——而 hook 汇报带的工作流来自项目目录里的 .cursor/relaymesh.json, 同一个仓库的多个工作树共用一份配置时,它写的常常是另一个工作流。认领到 until 之前,这个对话的一切汇报 (智能体状态会话、旧链路的对话编号与活动时间)都归 workflowID,不管汇报自己带的是哪个工作流。
认领的同时把已经建在别的工作流名下的状态会话(库里与内存里)搬过来,并清掉别的工作流上记着这个对话编号的旧「续聊目标」 (见 dropForeignAgentLinks);返回会话原来所在的工作流(去重,不含 workflowID),调用方据此通知 Web 重新取一遍。 同一个认领再来一次(运行监视每轮都会续期,收尾时缩短到收尾期)只改到期时间,不动库。空的工作流 / 对话编号、格式不对的对话编号一律忽略。
func (*Store) ClaimStaleOffers ¶ added in v2.1.0
func (s *Store) ClaimStaleOffers(ctx context.Context, now time.Time, staleAfter time.Duration, maxGroups int) ([]BoardStaleOffer, error)
ClaimStaleOffers 找出「派出已满 staleAfter、这一轮还没提醒过」的待接取指派,打上已提醒标记, 按(任务板、承接者)成组返回,最早派出的组在前;最多返回 maxGroups 组(<= 0 用 BoardStaleMaxGroupsPerScan), 没被选中的留着,下一遍再处理。
「找出」与「打标记」在同一个事务里,所以同一个指派不会被两次扫描各提醒一次;代价是标记打上之后、 通知真正发出之前进程退出的话,那一条就丢了——对「提醒一次」来说,宁可偶尔少一条,也不重复。 打标记只写 offer_reminded_at 这一列:不动 updated_at、不进时间线、不让任务清单的各种缓存失效。
func (*Store) ClearAgentScreen ¶
ClearAgentScreen 在托管终端消失(会话退出、主机离线)时清掉信号。返回之前是否在审批等待。
func (*Store) ClearReplyWindow ¶
ClearReplyWindow 用户回复了:窗口清零(走动中的和攒着的都清),上一轮的「本次放行」也一并复位。没有窗口时什么都不做。
func (*Store) CloseBranch ¶ added in v2.1.0
func (s *Store) CloseBranch(ctx context.Context, branchWorkflowID, by string) (*CloseBranchResult, error)
CloseBranch 把分支关系置为 closed(保留行,历史消息与事件仍可看);幂等。 by:human / agent:<工作流编号>。结束时给「不是结束者」的那一边的收件箱各写一行系统消息,让对方的 Agent 知道。
func (*Store) CommitArchiveBaseline ¶ added in v2.2.0
CommitArchiveBaseline 把一条登记中的基线转为可用,并顺手按保留规则清理(这把令牌在这个项目里多出的旧基线、 过期的、登记中太久的、令牌或项目已不存在的)。基线不存在或不是登记中,返回 ErrArchiveBaselineMissing。
func (*Store) CompactWorkItems ¶
CompactWorkItems 压缩关闭已久的任务:时间线与「最新进度」不再保留,没有结论的从进度里截一段当结论。 标题 / 类型 / 标签 / 日期 / 结论 / 引用 / 关联会话 都保留。可重复执行,返回本次压缩的任务数。
func (*Store) ConfirmView ¶
func (s *Store) ConfirmView(ctx context.Context, item *model.ConfirmItem) (model.ConfirmItemView, error)
ConfirmView 是 ConfirmViews 的单条版本。
func (*Store) ConfirmViews ¶
func (s *Store) ConfirmViews(ctx context.Context, items []model.ConfirmItem) ([]model.ConfirmItemView, error)
ConfirmViews 把确认项转成对外视图,并给绑定了文档的项补上文档路径与标题。
func (*Store) ConversationOwner ¶
ConversationOwner 返回此刻认领这个对话的工作流(没有人认领,或认领已经过期就是空串)。
func (*Store) ConversationReadEpoch ¶
ConversationReadEpoch 返回已读纪元(Unix 毫秒);第一次调用时把当前时刻记下来。
func (*Store) CopyUserNoteToMain ¶ added in v2.1.0
func (s *Store) CopyUserNoteToMain(ctx context.Context, branchWorkflowID, text string, imageCount int) (*model.QueuedFeedback, error)
CopyUserNoteToMain 把用户在分支会话页里的发言抄送给主会话(一行摘要,前 BranchCopyRunes 字)。 不是活动分支、没开抄送、或主会话那边未读的抄送已经堆到上限,都返回 nil, nil(静默跳过,不影响用户的原操作)。
func (*Store) CountAgentMessagesBetween ¶
func (s *Store) CountAgentMessagesBetween(ctx context.Context, workflowID string, from, to time.Time) (int, error)
CountAgentMessagesBetween 数一个工作流里 Agent 在 [from, to) 时间窗内发的消息条数(口径同 CountUnreadAgentMessages,含任务进展); to 为零值表示不设上界。用来回答「某一次运行期间智能体有没有说过话」:窗口外(比如运行结束之后另一个会话发的)不算。
func (*Store) CountBoardWorkItemsByState ¶
func (s *Store) CountBoardWorkItemsByState(ctx context.Context, workflowID string) (map[string]int, error)
CountBoardWorkItemsByState 统计工作流所在任务板的各状态任务数,与按这个工作流列出的任务清单口径一致。
func (*Store) CountFeedbackSessionsByWorkflow ¶
func (s *Store) CountFeedbackSessionsByWorkflow(ctx context.Context, workflowIDs []string) (map[string]int, error)
CountFeedbackSessionsByWorkflow 数每个工作流在库里一共有多少行会话(含已归档),键是工作流编号,没有行的工作流不出现在结果里。 侧栏「N 轮」徽标要的是整个工作流的总数,而不是列表里恰好带出的行数;按工作流分组一次查出(走 idx_fs_wf_created 覆盖索引,不翻正文)。
func (*Store) CountOAuthClients ¶
func (*Store) CountOpenArtifactComments ¶
CountOpenArtifactComments 是未解决评论数(文档列表角标用)。
func (*Store) CountPendingConfirms ¶
CountPendingConfirms 统计待处理的确认项数。
func (*Store) CountPendingConfirmsByWorkflow ¶
func (s *Store) CountPendingConfirmsByWorkflow(ctx context.Context, workflowIDs []string) (map[string]int, error)
CountPendingConfirmsByWorkflow 一次查出多个工作流各自待处理的确认项数(侧栏会话卡用,避免逐个工作流查询;#159)。 返回表里没有的工作流表示 0 条待处理;传入空列表直接返回空表。
func (*Store) CountProjectDocs ¶
CountProjectDocs 工作流内文档数。
func (*Store) CountRecentNotices ¶
func (s *Store) CountRecentNotices(ctx context.Context, workflowID string, since time.Time) (int, error)
CountRecentNotices 统计某个工作流自 since 以来发布的进度通知条数,给发布端做频率上限用。
func (*Store) CountSSHHostsViaGateway ¶
CountSSHHostsViaGateway 统计经某台网关主机接入的 SSH 主机数量(删除网关之前用来拦截)。
func (*Store) CountUnackedKeyNotices ¶ added in v2.2.0
CountUnackedKeyNotices 是单个工作流的 CountUnackedKeyNoticesByWorkflow:事件载荷与单条会话接口顺带给出。
func (*Store) CountUnackedKeyNoticesByWorkflow ¶ added in v2.2.0
func (s *Store) CountUnackedKeyNoticesByWorkflow(ctx context.Context, workflowIDs []string) (map[string]int, error)
CountUnackedKeyNoticesByWorkflow 按工作流统计还没确认的重点通知条数(不含已归档的会话);没有的工作流不出现在结果里。 侧栏会话卡的「重点」徽标要的是整个工作流的总数,而不是列表窗口里恰好带出的行数。
func (*Store) CountUnreadAgentMessages ¶
func (s *Store) CountUnreadAgentMessages(ctx context.Context, workflowID string, afterMs int64, updatesSince time.Time, includeUpdates bool) (int, error)
CountUnreadAgentMessages 数一个工作流里 Agent 在 afterMs(Unix 毫秒)之后发的消息条数(系统行不计): 阻塞式汇报、进度气泡、提问 / 计划卡,以及(includeUpdates 时)任务进展。
func (*Store) CountVisibleCredentials ¶
func (*Store) CountWorkItemsByState ¶
func (s *Store) CountWorkItemsByState(ctx context.Context, workflowID string) (map[string]int, error)
CountWorkItemsByState 统计各状态的任务数(workflowID 为空 = 全部工作流)。 按「创建者工作流」数:这是某个智能体自己的任务量(会话守护、工作流模式用); 要与任务清单对得上(整张板)用 CountBoardWorkItemsByState。
func (*Store) CountWorkModules ¶
CountWorkModules 统计工作流所在任务板的模块 / 功能节点数。
func (*Store) CountWorkflowSessionsBefore ¶ added in v2.2.0
func (s *Store) CountWorkflowSessionsBefore(ctx context.Context, workflowID, beforeID string) (rounds, notices int64, err error)
CountWorkflowSessionsBefore 数一个工作流里比游标更早的会话:rounds 是真正的汇报轮次,notices 是进度通知。 beforeID 为空 = 整个工作流。get_session_history 据此告诉智能体「还有多少没列出来」。
func (*Store) CreateAuthProfile ¶
func (s *Store) CreateAuthProfile(ctx context.Context, in AuthProfileInput) (*model.AuthProfile, error)
CreateAuthProfile 新增一档。名称不能重复,总数有上限;新档位不是默认。
func (*Store) CreateConfirmItem ¶
func (s *Store) CreateConfirmItem(ctx context.Context, in ConfirmCreateInput) (item *model.ConfirmItem, created bool, err error)
CreateConfirmItem 创建一条确认项。created=false 表示命中了「同一问题仍在待处理」的去重,返回的是已有那条(智能体重试不会产生重复项)。
func (*Store) CreateCredential ¶
func (*Store) CreateFeedbackSession ¶
func (s *Store) CreateFeedbackSession(ctx context.Context, input CreateSessionInput) (*model.FeedbackSession, error)
func (*Store) CreateGrant ¶
CreateGrant 新增(或续期)一条授权:同一主体 + 范围已有有效授权时更新角色与有效期,不重复建。
func (*Store) CreateGroup ¶
func (s *Store) CreateGroup(ctx context.Context, in CreateGroupInput) (*model.Conversation, error)
CreateGroup 建一个群:你是 owner,Members 是初始成员,并写入系统行。
func (*Store) CreateHiddenOAuthCredential ¶
func (*Store) CreateNoticeSession ¶
func (s *Store) CreateNoticeSession(ctx context.Context, input CreateSessionInput) (*model.FeedbackSession, error)
CreateNoticeSession 发布一条不阻塞的进度 / 回答气泡(异步对话模式下 interactive_feedback 的 wait:false)。
它与 CreateFeedbackSession 的区别,也是它不复用后者的原因:
- 不取走收件箱里的追加(那是给「等待中的汇报」的秒回,notice 没有在等谁,取走就等于吞掉用户的话);
- 不覆写已有的 pending 汇报,也不把历史上已完成但未消费的轮次批量标成已消费;
- 一建就是 completed + 已被智能体消费 + 没有回复时间:界面上只有 AI 气泡,没有回复框。
workflow_id 必须给定且已被调用方核实(异步模式是按工作流开的,不存在「自动派生新工作流」的情形)。
func (*Store) CreateOAuthClient ¶
func (*Store) CreateOAuthGrant ¶
func (*Store) CreateProject ¶
func (*Store) CreateProjectDoc ¶
func (s *Store) CreateProjectDoc(ctx context.Context, in ProjectDocInput, actor DocActor) (*ProjectDocSaveResult, error)
CreateProjectDoc 新建文档。
func (*Store) CreateSSHHost ¶
CreateSSHHost 创建一台 SSH 主机。调用方已经完成校验与凭据密封;这里只保证 类型正确、数量不超限、机器码不重复(重复返回 ErrTerminalHostExists,调用方可换一个再试)。
func (*Store) CreateTask ¶
func (*Store) CreateTerminalRun ¶
CreateTerminalRun 写入一条新的运行记录。
func (*Store) CreateUserNorm ¶
func (*Store) CreateWebWorkflow ¶
func (s *Store) CreateWebWorkflow(ctx context.Context, input CreateWebWorkflowInput) (*CreateWebWorkflowResult, error)
CreateWebWorkflow 新建一个工作流:落一行占位会话 + 写入自定义标题,返回占位会话与启动提示词。 工作流编号已存在(给定编号撞了)返回冲突错误;名字或编号不合规返回入参错误。
func (*Store) CreateWorkItem ¶
func (s *Store) CreateWorkItem(ctx context.Context, in WorkItemInput, actor WorkActor) (*WorkItemResult, error)
CreateWorkItem 新建任务。
func (*Store) CreateWorkModule ¶
func (s *Store) CreateWorkModule(ctx context.Context, workflowID string, parentID uint, name, description string) (*model.WorkModule, error)
CreateWorkModule 在规划树上新建一个模块(parentID=0)或功能(parentID=某个顶层模块),排在同级最后。
func (*Store) DeactivateCredential ¶
func (*Store) DecisionConfirmsByKey ¶
func (s *Store) DecisionConfirmsByKey(ctx context.Context, docID uint) (map[string]*model.ConfirmItem, error)
DecisionConfirmsByKey 返回文档内各决策 id 对应的最新确认项(序号最大的那条)。
func (*Store) DefaultAllowHostCodes ¶
DefaultAllowHostCodes 返回「对新建模型令牌预先授予」的主机机器码:已启用、默认态为 allow,按机器码排序。
func (*Store) DefaultAuthProfile ¶
DefaultAuthProfile 返回默认档位;没有标记默认的(不应出现)就取排序最靠前的一档并顺手修正标记。
func (*Store) DeleteAllDraftImages ¶
DeleteAllDraftImages 删除一个工作流的全部草稿图片(草稿被整体销毁时)。
func (*Store) DeleteArchiveBaselines ¶ added in v2.2.0
func (s *Store) DeleteArchiveBaselines(ctx context.Context, credentialID, projectID uint) (int64, error)
DeleteArchiveBaselines 删除一把令牌的基线:projectID 为 0 = 它的全部。收回授权(关掉归档位、从名单去掉项目、停用、删除令牌)时调用, 收回之后它不该还留着可以接着增量的起点。
func (*Store) DeleteAuthProfile ¶
DeleteAuthProfile 删除一档。默认档位不能删;选用了这一档的工作流改回「跟随默认」(profile_id = 0)。
func (*Store) DeleteCredential ¶
func (*Store) DeleteDraftImages ¶
func (s *Store) DeleteDraftImages(ctx context.Context, workflowID string, keys []string) (int64, error)
DeleteDraftImages 删除一个工作流里指定的草稿图片,返回实际删除的张数。
func (*Store) DeleteEmbeddingCredential ¶ added in v2.2.0
DeleteEmbeddingCredential 删除已保存的密钥;本来就没有也不算错。
func (*Store) DeleteFeedbackSession ¶
func (s *Store) DeleteFeedbackSession(ctx context.Context, sessionID string) (*model.FeedbackSession, error)
DeleteFeedbackSession 物理删除会话记录,维护工作流状态并级联清理(D-159)
func (*Store) DeleteOAuthAccessTokensForGrant ¶
func (*Store) DeleteProjectModule ¶
DeleteProjectModule 删除模块(及其子模块);挂在这些模块上的文档不删除,只是解除模块绑定。
func (*Store) DeleteTerminalArchivesOfHost ¶
DeleteTerminalArchivesOfHost 删除一台主机上人工会话的归档记录(删除主机时调用;key 以「机器码:」开头)。
func (*Store) DeleteTerminalHost ¶
DeleteTerminalHost 删除记录,返回是否删除了记录。
func (*Store) DeleteTerminalLauncher ¶
func (s *Store) DeleteTerminalLauncher(ctx context.Context, id string) ([]TerminalLauncher, TerminalLauncher, error)
DeleteTerminalLauncher 按编号删除一条预设;返回删除后的全部预设,以及被删掉的那一条(用于审计)。
func (*Store) DeleteTerminalLostDismissalsOfHost ¶
DeleteTerminalLostDismissalsOfHost 删除一台主机的全部忽略记录(删除主机时调用)。
func (*Store) DeleteTerminalRunsOfHost ¶
DeleteTerminalRunsOfHost 删除一台主机的全部运行元数据(删除主机时调用)。
func (*Store) DeleteTerminalSessionsOfHost ¶
DeleteTerminalSessionsOfHost 删除一台主机的全部会话索引(删除主机时调用)。
func (*Store) DeleteUnusedOAuthClient ¶ added in v2.1.0
DeleteUnusedOAuthClient 删除一条从未签发过令牌的登记;不存在或已经被使用过的不删,返回 false。 只删「没用过」的:已授权客户端的刷新要靠这条登记,误删会让它的授权突然失效。
func (*Store) DeleteUserNorm ¶
func (*Store) DeleteWorkItem ¶
DeleteWorkItem 删除任务及其时间线与会话关联;它的子任务变成顶层任务。
func (*Store) DeleteWorkModule ¶
DeleteWorkModule 删除模块(顶层模块连同它的功能)。任务不会被删: 属于被删节点的任务回到它的上一级;顶层模块被删时变成未归类。
func (*Store) DeleteWorkflowDraft ¶
DeleteWorkflowDraft 删除工作流草稿数据
func (*Store) DiagBrowserReportsEnabled ¶ added in v2.2.0
DiagBrowserReportsEnabled 读「接收浏览器自报崩溃」开关;没设过(或值认不出)时默认开: 它只是让首页响应多带两个响应头、并收下匿名的崩溃通知,不外发任何东西,也不改变页面行为。
func (*Store) DiscardArchiveBaseline ¶ added in v2.2.0
DiscardArchiveBaseline 丢弃一条还没转正的基线(包没有完整写出)。已经 ready 的不动。
func (*Store) DismissConfirmItem ¶
func (s *Store) DismissConfirmItem(ctx context.Context, workflowID, ref, reason string) (*model.ConfirmItem, error)
DismissConfirmItem 用户放弃一条待处理的确认项,并告诉智能体「不用再等它」。
func (*Store) DismissTerminalLost ¶
func (s *Store) DismissTerminalLost(ctx context.Context, machineCode string, sids []string, now time.Time) (int64, error)
DismissTerminalLost 忽略一台主机上的若干条「会话已不存在」提示,返回实际新增的条数 (重复忽略同一条不算变化,所以界面重复点击是安全的)。同时顺手清掉过期的忽略记录。
func (*Store) DocACLFacts ¶ added in v2.2.0
DocACLFacts 按文档编号批量取访问判定用的元数据:search 工具在权限档位为 audit / enforce 时,对命中的文档逐条判定读权限。 已删除的文档取不到(调用方按「没有这条」处理,宁可不给)。
func (*Store) DocDecisionExportRows ¶
func (s *Store) DocDecisionExportRows(ctx context.Context, doc *model.ProjectDoc) []docs.DecisionExportRow
DocDecisionExportRows 返回导出时要追加到文档末尾的「决策结果」表的行;没有决策围栏的文档返回 nil。
func (*Store) DocDecisionViews ¶
func (s *Store) DocDecisionViews(ctx context.Context, doc *model.ProjectDoc, body string, historic bool) []confirm.DecisionView
DocDecisionViews 把文档正文里的决策围栏与确认项对齐,给网页和 MCP 读文档时用。 historic=true(看历史修订)时不挂确认项:历史版本里的决策不能作答,也不该显示「现在」的答复。 读确认项失败只记日志、退化为「没挂确认项」,不让一次读文档因此失败。
func (*Store) DocLinks ¶
DocLinks 解析一篇文档的出链与反链(解析 [path] 与相对 .md 链接,见 docs.ExtractLinks)。 解析范围:同一工作流的文档;文档属于项目时再加上同项目的其他文档(同路径时本工作流优先)。 不落库:文档数量有上限(每工作流 500、每项目 2000),按需扫描正文即可,也就不会有「索引与正文不一致」的问题。
func (*Store) EmbeddingUsageDays ¶ added in v2.2.0
func (s *Store) EmbeddingUsageDays(ctx context.Context, fromDay, toDay string) ([]embedding.UsageDay, error)
EmbeddingUsageDays 返回 [fromDay, toDay](含,YYYY-MM-DD)内有记录的每一天,按日期升序。
func (*Store) EmbeddingUsageTotals ¶ added in v2.2.0
EmbeddingUsageTotals 返回保留期内的累计用量。
func (*Store) EnsureEnvMCPCredential ¶
func (s *Store) EnsureEnvMCPCredential(ctx context.Context, envToken string) (*model.MCPCredential, error)
EnsureEnvMCPCredential 确保环境变量 RELAYMESH_MCP_TOKEN 在数据库中存在对应的可管理凭据
func (*Store) EscalateOverdueBranchAsks ¶ added in v2.1.0
func (s *Store) EscalateOverdueBranchAsks(ctx context.Context, now time.Time, after time.Duration, note string, limit int) ([]model.ConfirmItem, error)
EscalateOverdueBranchAsks 把「路由给主会话、仍待处理、创建超过 after」的请示升级给用户(来源 timeout),最多处理 limit 条; 返回被升级的请示(调用方负责发通知)。幂等:已升级 / 已答复的不会再被选中;重启不丢(时间戳在库里)。
func (*Store) ExtendReplyWindow ¶
func (s *Store) ExtendReplyWindow(ctx context.Context, workflowID string, add time.Duration, now time.Time) (ReplyWindow, error)
ExtendReplyWindow 把工作流的回复窗口累加 add(封顶见 asyncmode.WindowMax)。 智能体手头有任务时只往「攒着的时间」里加(窗口不走);没有任务时从当前截止时间累加。 只更新已有的工作流行:没有行说明从未开启过异步,没有窗口可言。
func (*Store) FindAnchoredSessionByCommit ¶
func (s *Store) FindAnchoredSessionByCommit(ctx context.Context, workflowID, commit string) (*model.FeedbackSession, error)
FindAnchoredSessionByCommit 在某工作流里按哈希找到带该锚点的最近一次会话。 哈希允许长短不一(互为前缀即视为同一提交),用于把胶囊的基准关联回具体交付。
func (*Store) FindCredentialByToken ¶
func (*Store) FindOAuthAccessToken ¶
func (s *Store) FindOAuthAccessToken(ctx context.Context, plainToken string) (*model.OAuthAccessToken, *model.OAuthGrant, *model.MCPCredential, error)
func (*Store) FindReplyRefs ¶
func (s *Store) FindReplyRefs(ctx context.Context, workflowID, hash string, limit int) ([]ReplyRef, error)
FindReplyRefs 在一个工作流里按哈希(6~12 位前缀)找回复,旧的在前,最多 limit 条。 只在给定的工作流里找:别的工作流里哈希相同的会话不可见,不能靠引用窥探别的工作流。 哈希不合法或工作流为空时返回空,不报错。
func (*Store) FindTerminalRunByIdempotency ¶
func (s *Store) FindTerminalRunByIdempotency(ctx context.Context, credentialID uint, key string) (*model.TerminalRun, error)
FindTerminalRunByIdempotency 按 (凭据, 幂等键) 查找已有运行;用于 terminal_exec 的重试去重。
func (*Store) GetArchiveBaseline ¶ added in v2.2.0
func (s *Store) GetArchiveBaseline(ctx context.Context, id string, projectID, credentialID uint, now time.Time) (*model.ArchiveBaseline, error)
GetArchiveBaseline 取一条可用的基线(含摘要体)。必须是这把令牌在这个项目里登记的、已经 ready 的: 不存在 / 不是它的 / 还在登记中 → ErrArchiveBaselineMissing;是它的但过了保留期 → ErrArchiveBaselineExpired。
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) GetAuthProfile ¶
GetAuthProfile 取一档;不存在返回 NotFound。
func (*Store) GetBranchParamEvent ¶ added in v2.1.0
func (s *Store) GetBranchParamEvent(ctx context.Context, branch string, id uint) (*model.BranchParamEvent, error)
GetBranchParamEvent 取某个分支的一条事件;不属于这个分支按不存在处理。
func (*Store) GetBranchPrefs ¶ added in v2.1.0
GetBranchPrefs 读取分支全局偏好;从未设置过、或存下来的值已损坏时返回出厂默认(兜底开关关、30 分钟升级)。
func (*Store) GetCheckpointByRevision ¶
func (*Store) GetConfirmItemByRef ¶
func (s *Store) GetConfirmItemByRef(ctx context.Context, workflowID, ref string) (*model.ConfirmItem, error)
GetConfirmItemByRef 取一条确认项(限定工作流,不能跨工作流读取)。
func (*Store) GetConversationRead ¶
func (s *Store) GetConversationRead(ctx context.Context, conversationID, readerKind, readerRef string) (model.ConversationRead, error)
GetConversationRead 取一个读者在一个会话里的已读游标;还没有记录时返回零值(不报错)。
func (*Store) GetCredential ¶
func (*Store) GetCredentialIfManageable ¶ added in v2.2.0
func (s *Store) GetCredentialIfManageable(ctx context.Context, id uint) (*model.MCPCredential, *model.OAuthGrant, error)
GetCredentialIfManageable 按编号读取「MCP 凭据管理」里可见的凭据:非隐藏的,或由 OAuth 授权创建且授权仍然有效的。 第二个返回值是 OAuth 凭据对应的授权(普通凭据为 nil)。其余隐藏凭据一律按「未找到」处理。
令牌的查看与重新生成不走这里,仍用 GetCredentialIfVisible:OAuth 凭据里那串随机值只是占位,从不对外,也不能当 Bearer 用。
func (*Store) GetCredentialIfVisible ¶
GetCredentialIfVisible 按 ID 读取非隐藏凭据;隐藏凭据返回 gorm.ErrRecordNotFound 语义。
func (*Store) GetCurrentFeedbackSession ¶
func (*Store) GetDraftImage ¶
func (s *Store) GetDraftImage(ctx context.Context, workflowID, key string) (*model.DraftImage, error)
GetDraftImage 读取一张草稿图片(含正文);不存在返回 nil, nil。
func (*Store) GetEmbeddingConfig ¶ added in v2.2.0
GetEmbeddingConfig 读取配置;从未保存过时返回默认值。已 Normalize。
func (*Store) GetEmbeddingCredential ¶ added in v2.2.0
GetEmbeddingCredential 读取密封的密钥;没有保存过返回 ok=false。
func (*Store) GetFeedbackRoundsByWorkflow ¶
func (s *Store) GetFeedbackRoundsByWorkflow(ctx context.Context, workflowID string, limit int) ([]model.FeedbackSession, error)
GetFeedbackRoundsByWorkflow 与 GetSessionsByWorkflow 相同,但不含 notice 进度气泡: 检查点的「之后又多了几轮」「之后的用户反馈」按真正的汇报—回复轮次数,进度通知再多也不该让检查点显得过期。
func (*Store) GetFeedbackSession ¶
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) GetGroupMember ¶
func (s *Store) GetGroupMember(ctx context.Context, groupID, memberKind, memberRef string) (*model.ConversationMember, error)
GetGroupMember 取一个成员行(含已离开的)。
func (*Store) GetGuiWakeConfig ¶ added in v2.2.0
func (s *Store) GetGuiWakeConfig(ctx context.Context) (GuiWakeConfig, error)
GetGuiWakeConfig 读出整份目标配置;从没保存过返回空配置(Targets 不是 nil)。
func (*Store) GetInboxConfig ¶
func (s *Store) GetInboxConfig(ctx context.Context) InboxConfig
GetInboxConfig 读取收件箱开关;从未设置过时是全部打开。读不到库时按默认处理(宁可多提醒,不要把功能悄悄关掉)。
func (*Store) GetLatestAnchoredSession ¶
func (s *Store) GetLatestAnchoredSession(ctx context.Context, workflowID, excludeSessionID string) (*model.FeedbackSession, error)
GetLatestAnchoredSession 返回某工作流里最近一次带交付锚点的会话(只读取轻量列)。 excludeSessionID 非空时跳过该会话(用于「与上一次比较」)。没有任何锚点时返回 (nil, nil)。
func (*Store) GetLatestCheckpoint ¶
func (*Store) GetLatestWorkflowFeedbackSession ¶
func (s *Store) GetLatestWorkflowFeedbackSession(ctx context.Context, workflowID string) (*model.FeedbackSession, error)
GetLatestWorkflowFeedbackSession 自动查找某工作流下最近的汇报会话(优先 pending 活跃轮次,其次最新轮次)。 notice 进度气泡不是「一轮对话」——它没有回复框、发布即完成——所以不在这里的候选之内: 守护、continue_feedback_session、Agent 存活判定都靠它找「智能体到底在等谁」,被 notice 顶替就会误判。
func (*Store) GetNoteByKey ¶
func (*Store) GetNotifyPrefs ¶
GetNotifyPrefs 读取通知偏好;从未设置过、或存下来的值已损坏时返回出厂默认。已 Normalize(过期的静音不再出现)。
func (*Store) GetNtfyConfig ¶
GetNtfyConfig 读取 ntfy 推送配置;从未设置过时返回关闭状态的默认值。已 Normalize。
func (*Store) GetOAuthClient ¶
func (*Store) GetOAuthGrant ¶
func (*Store) GetOAuthGrantByRefreshHash ¶
func (*Store) GetOAuthPolicy ¶
func (*Store) GetProject ¶
func (*Store) GetProjectDocByID ¶
GetProjectDocByID 按主键读取。
func (*Store) GetProjectDocByRef ¶
func (s *Store) GetProjectDocByRef(ctx context.Context, workflowID, ref string) (*model.ProjectDoc, error)
GetProjectDocByRef 按 path、seq 或 id 读取。
func (*Store) GetProjectDocInProject ¶
func (s *Store) GetProjectDocInProject(ctx context.Context, projectID uint, ref string) (*model.ProjectDoc, error)
GetProjectDocInProject 在整个项目里按路径或文档编号(全局 id,可带前缀 d)取一篇文档。 项目内路径唯一(只对 project_id>0 的文档由应用层保证),所以按路径取到的是唯一一篇。
func (*Store) GetProjectDocRevision ¶
func (s *Store) GetProjectDocRevision(ctx context.Context, docID uint, rev int) (*model.ProjectDocRevision, error)
GetProjectDocRevision 某一版。
func (*Store) GetProjectModule ¶
func (s *Store) GetProjectModule(ctx context.Context, projectID uint, path string) (*model.ProjectModule, error)
GetProjectModule 取项目里的一个模块;不存在返回 nil, nil。
func (*Store) GetQueuedFeedback ¶
GetQueuedFeedback 按编号取一条追加(含图片全文)。不存在时返回 (nil, nil)。
func (*Store) GetSemanticRun ¶ added in v2.2.0
func (s *Store) GetSemanticRun(ctx context.Context) (SemanticRun, error)
GetSemanticRun 读运行设置;从未保存过返回默认值。
func (*Store) GetSessionParams ¶ added in v2.1.0
func (s *Store) GetSessionParams(ctx context.Context, caller, target string, now time.Time) (*SessionParamsView, error)
GetSessionParams 是 session_params(get):主会话读自己某个分支的参数,分支读自己的。 主会话读 off 档的分支只拿到开放范围与说明,不返回参数值。
func (*Store) GetSessionsByWorkflow ¶
func (*Store) GetSettings ¶
GetSettings 从数据库获取全局配置,若不存在返回默认 map
func (*Store) GetSettingsWithDB ¶
GetSettingsWithDB 从指定 DB (支持事务 tx) 获取全局配置
func (*Store) GetSidebarOrder ¶ added in v2.2.0
func (s *Store) GetSidebarOrder(ctx context.Context) (SidebarOrder, error)
GetSidebarOrder 读取侧栏的手动顺序;从未写过、或存下来的值已损坏时返回「版本 0、没有键」。 损坏的值按「没有」处理:宁可让前端重新按旧规则做一次快照,也不拿一张坏表去排列表。
func (*Store) GetSystemFlag ¶
GetSystemFlag 读取一个布尔系统开关(值 "1" 为真);不存在视为假。
func (*Store) GetTerminalGuardState ¶
func (s *Store) GetTerminalGuardState(ctx context.Context) (GuardStateDoc, error)
GetTerminalGuardState 读取预设运行状态;从未保存过或存档损坏时返回空文档(不是 nil)。
func (*Store) GetTerminalHost ¶
func (s *Store) GetTerminalHost(ctx context.Context, machineCode string) (*model.TerminalHost, error)
GetTerminalHost 按机器码读取主机,不存在返回 (nil, nil)。
func (*Store) GetTerminalPrefs ¶
func (s *Store) GetTerminalPrefs(ctx context.Context) (TerminalPrefs, error)
GetTerminalPrefs 读取终端偏好;从未设置过时返回全部关闭的默认值。
func (*Store) GetTerminalRun ¶
GetTerminalRun 按运行 ID 查询;不存在时返回 (nil, nil)。
func (*Store) GetTerminalSession ¶
func (s *Store) GetTerminalSession(ctx context.Context, machineCode, sid string) (*model.TerminalSession, error)
GetTerminalSession 按主机与会话 ID 读取一行;不存在返回 (nil, nil)。
func (*Store) GetUserNorm ¶
func (*Store) GetWorkItem ¶
GetWorkItem 读取任务详情:含最近的时间线(新的在前)与关联的会话。
func (*Store) GetWorkItemBySeq ¶
func (s *Store) GetWorkItemBySeq(ctx context.Context, workflowID string, seq int) (*model.WorkItem, error)
GetWorkItemBySeq 按序号读取任务(智能体使用):序号在工作流所在的任务板内唯一(#175)。 同一个项目的工作流共用一套 #N;单工作流的板与按工作流取完全一致。 找不到时依次回落:显式合并时改过号的旧 (工作流, 序号) 别名,以及旧版本回滚期间写入、还没归板的行。
func (*Store) GetWorkModule ¶
GetWorkModule 读取单个模块(含完整路径,不含任务汇总)。
func (*Store) GetWorkflowDraft ¶
func (s *Store) GetWorkflowDraft(ctx context.Context, workflowID string) (*model.WorkflowDraft, error)
GetWorkflowDraft 获取工作流对应的草稿数据,若不存在返回 nil, nil
func (*Store) GetWorkflowPhase ¶
func (*Store) GetWorkflowPhaseWithDefaults ¶
func (*Store) GetWorkflowPrompt ¶ added in v2.1.0
func (s *Store) GetWorkflowPrompt(ctx context.Context, workflowID string) (model.WorkflowPrompt, error)
GetWorkflowPrompt 读取某个工作流的提示词设置;没有配置过时返回只有 WorkflowID 的零值(Rev 为 0)。 热路径:每条回执头都会问一次,没配置过的工作流只多一次主键查询。
func (*Store) GlobalWakeTemplates ¶ added in v2.1.0
func (s *Store) GlobalWakeTemplates(ctx context.Context) WakeTemplates
GlobalWakeTemplates 读全局设置里的模板覆盖;读不到、格式不对一律当作没有覆盖(宁可用内置默认,也不让发唤醒词失败)。
func (*Store) GrantHostToTerminalCredentials ¶
func (s *Store) GrantHostToTerminalCredentials(ctx context.Context, machineCode string) (HostGrantResult, error)
GrantHostToTerminalCredentials 把 machineCode 写入所有「带终端能力、不是通配、尚未包含它」的模型令牌的主机名单。 整个过程在同一个事务里完成:要么全部写入,要么都不写。
func (*Store) GroupLastMessage ¶
GroupLastMessage 取群里最新一条文本消息(会话列表的预览);没有返回 nil。
func (*Store) GroupLastSeq ¶
GroupLastSeq 返回群里最新的序号(含系统行)。
func (*Store) GroupMemberCounts ¶ added in v2.2.0
func (s *Store) GroupMemberCounts(ctx context.Context, workflowIDs []string) (map[string]int, error)
GroupMemberCounts 对一批工作流统计:每个群里有几个(还没退出的)成员是这些工作流(群编号 → 个数;没有成员的群不出现)。 项目页「群聊」页签按「群里有项目的成员」过滤用(#291):一次扫描「工作流类、未退出」的成员行,在内存里对照集合, 不把成百上千个工作流编号拼进 IN 子句(SQLite 的变量个数有上限)。群的数量是几十个量级,成员行同样很少。
func (*Store) GroupMentionStates ¶
func (s *Store) GroupMentionStates(ctx context.Context, groupID string, messageIDs []uint) (map[uint]map[string]string, error)
GroupMentionStates 返回群消息对应的提醒行状态(被点名的成员 → 状态),聊天界面给被 @ 的消息标已送达 / 已读 / 已处理。
func (*Store) GroupMessagesAfterSeq ¶
func (s *Store) GroupMessagesAfterSeq(ctx context.Context, groupID string, afterSeq int64, limit int, vis *GroupVisibility) ([]model.ChatMessage, bool, error)
GroupMessagesAfterSeq 取序号大于 afterSeq 的消息(升序,最多 limit 条)。Agent 的 chat read 用它。
func (*Store) GroupReadSeqs ¶
GroupReadSeqs 返回群里每个读者的已读序号:key 是 "<kind>:<ref>"。
func (*Store) GroupRefsOfIdentity ¶
func (s *Store) GroupRefsOfIdentity(ctx context.Context, workflowID string, identityID uint) []string
GroupRefsOfIdentity 是这个身份当前所在的群(群授权的主体):群成员单位是工作流, 所以取「本次调用的工作流」和「这个身份名下所有工作流」里仍在群内的那些。
已归档的群不算(#321,Q209):归档 = 不再活跃,群授权不再发给它的成员;取消归档后自动恢复。 群里的成员关系、对群的授权记录本身都原样保留,只是判定时这个群暂时不出现在调用方的群列表里。
func (*Store) GroupUnread ¶
func (s *Store) GroupUnread(ctx context.Context, groupID, readerKind, readerRef string, since time.Time) (unread, mentioned int, err error)
GroupUnread 是读者在群里的未读数:别人发的文本消息(系统行不计),以及其中点名了读者(或 @all)的条数。 since 是读者可见的起点(入群时间);人读取时传零值。
func (*Store) GroupsOfWorkflow ¶
func (s *Store) GroupsOfWorkflow(ctx context.Context, workflowID string) ([]model.Conversation, error)
GroupsOfWorkflow 列出一个工作流当前所在的(未归档的)群。
func (*Store) HasAnyCredential ¶
func (*Store) HookLastSeen ¶
HookLastSeen 返回某个工作流的编辑器 hook 最近一次来问收件箱的时间(Hub 重启后从库里恢复,见 RestoreHookSeen)。
func (*Store) IdentityLabelOf ¶
IdentityLabelOf 给审计用的身份标签:用户改的名字,没有就用目录名。
func (*Store) IdentityProjectID ¶
IdentityProjectID 是身份所在目录归属的项目;没有归属返回 0。
func (*Store) ImportProjectDocs ¶
func (s *Store) ImportProjectDocs(ctx context.Context, workflowID string, files []ImportDocFile, mode string, dryRun bool, actor DocActor) (*ImportDocResult, error)
func (*Store) InboxAck ¶
func (s *Store) InboxAck(ctx context.Context, workflowID string, ids []uint, now time.Time) ([]uint, error)
InboxAck 确认已读取的追加。ids 为空表示确认这个工作流里全部「已读取未确认」的。 还没被读取的(排队中)不能确认——没读过就谈不上确认。返回实际确认的编号。
func (*Store) InboxGetMessage ¶ added in v2.2.0
func (s *Store) InboxGetMessage(ctx context.Context, workflowID string, id uint) (*model.QueuedFeedback, InboxGetOutcome, error)
InboxGetMessage 按编号取一条人工追加的全文,给 workflow_context(action: "inbox_get") 用。只读:不标已送达、不记提醒、不动任何状态。 只给「智能体已经有权知道」的内容,与「用户追加」的检索口径一致(见 searchMessageLive): 系统投递的行(确认项答复、群聊 @、分支消息)不是追加;还在排队的、撤回的都不返回正文(返回的行为 nil,只给结论)。
func (*Store) InboxPeek ¶
func (s *Store) InboxPeek(ctx context.Context, workflowID string, reminder bool, now time.Time) (InboxPeek, error)
InboxPeek 看一眼收件箱。reminder=false 纯只读;reminder=true 是 hook 在用: 按「立即、5 分钟后、15 分钟后」的节奏判断每条未读该不该再提醒一次,提醒过就记一笔(每条最多 InboxMaxReminders 次), 这样 hook 即使每隔十几秒查一次,也不会反复打扰。
撤回也提醒(#199):智能体读过或被提醒过的追加被用户撤回后,hook 提醒它一次(记在 last_notified_at 上, 每条撤回只提醒一次,不占 notified_count);智能体读过收件箱、被告知撤回之后就不再提醒。
func (*Store) InboxRead ¶
func (s *Store) InboxRead(ctx context.Context, workflowID string, opts InboxReadOptions, now time.Time) (InboxReadResult, error)
InboxRead 是智能体主动读取收件箱:把排队中的追加标为已送达并返回全文。 送达归因:读取前 30 分钟内收到过 hook 提醒 / 回执提示行的,记为那条路径,否则记为主动读取。
func (*Store) InboxSummary ¶
func (s *Store) InboxSummary(ctx context.Context, workflowID string, now time.Time) (InboxSummary, error)
InboxSummary 统计一个工作流收件箱的现状。只读。
func (*Store) IngestAgentEvent ¶
func (s *Store) IngestAgentEvent(ctx context.Context, in AgentIngestInput) (AgentIngestResult, error)
IngestAgentEvent 把一次汇报折进状态核心。没有项目目录(认不出身份)时什么都不记,返回零值结果。 写库失败只丢掉持久化:内存里的状态照常前进,下一次事件会重试写库。
func (*Store) InsertOAuthAccessToken ¶
func (*Store) InvalidateOAuthGrantFamily ¶
func (*Store) IsAsyncEffective ¶
IsAsyncEffective 回答「这个工作流此刻是不是有效的异步模式」。出错一律按同步处理(同步是安全的默认)。
func (*Store) KeepaliveFeedbackSession ¶
func (*Store) LatestUserHints ¶ added in v2.2.0
LatestUserHints 返回工作流里「最近一条用户消息」上的线索:在最近一轮有文字回复的会话与最近一条没被撤回的追加里,取发出得更晚的那条 (同时则取会话——被并进秒回的追加线索已经并在那一轮上)。最近一条消息没有线索就返回 nil,不会退回去拿更早的消息的线索: 线索只对应「那条消息」,拿旧消息的线索来配新消息是误导。get_session_history 的末尾用它给智能体一个「接下来可能要看」的指向。
func (*Store) LatestWorkflowOfIdentity ¶
LatestWorkflowOfIdentity 是身份最近活跃的工作流(给授权提醒找收件箱用);没有返回空串。
func (*Store) LinkBranch ¶ added in v2.1.0
func (s *Store) LinkBranch(ctx context.Context, in LinkBranchInput) (*LinkBranchResult, error)
LinkBranch 建立(或重新打开)一条分支关系,并写审计。
func (*Store) LinkWorkItemSession ¶
LinkWorkItemSession 把一个已存在的会话关联到任务。
func (*Store) ListActiveTerminalRuns ¶
ListActiveTerminalRuns 返回所有尚未终结的运行(待批准或运行中),Hub 启动时据此恢复内存索引。
func (*Store) ListActiveUserNorms ¶
func (*Store) ListAgentIdentities ¶
func (s *Store) ListAgentIdentities(ctx context.Context) ([]AgentIdentityView, error)
ListAgentIdentities 返回全部身份(最近活动的在前),显示名按「改名 ?? 目录名、重名降级」统一计算。
func (*Store) ListAgentSessions ¶
func (s *Store) ListAgentSessions(ctx context.Context, f AgentSessionFilter, now time.Time) ([]AgentSessionView, error)
ListAgentSessions 返回会话的展示状态(最近有动静的在前)。now 由调用方给,便于测试。
func (*Store) ListAllBranches ¶ added in v2.1.0
ListAllBranches 返回全部关系(活动 + 已结束),最新的在前,最多 BranchListMax 行。
func (*Store) ListArchiveBaselines ¶ added in v2.2.0
func (s *Store) ListArchiveBaselines(ctx context.Context, credentialID uint, projectIDs []uint, now time.Time) ([]model.ArchiveBaseline, error)
ListArchiveBaselines 列出这把令牌名下可用且没过期的基线(新的在前,不含摘要体)。projectIDs 非空时只列这些项目。
func (*Store) ListArtifactComments ¶
func (s *Store) ListArtifactComments(ctx context.Context, docID uint, includeResolved bool, limit int) ([]model.ArtifactComment, error)
ListArtifactComments 按时间正序列出评论;默认只含未解决的。
func (*Store) ListAuditEvents ¶
func (s *Store) ListAuditEvents(ctx context.Context, f AuditFilter) ([]model.AuditEvent, error)
ListAuditEvents 按时间倒序返回(新的在前)。
func (*Store) ListAuthProfiles ¶
ListAuthProfiles 按排序列出全部档位(默认档位不一定排第一,由界面决定怎么展示)。
func (*Store) ListBranchParamEventViews ¶ added in v2.1.0
func (s *Store) ListBranchParamEventViews(ctx context.Context, branch string, limit int, now time.Time) ([]BranchParamEventView, error)
ListBranchParamEventViews 返回某个分支最近的参数事件(新的在前),每条带「现在能不能撤销」。 只有存在可撤销候选时才读一次当前值;读不到当前值时跳过「当前值是否仍是它写入的值」这一条(宁可多显示一个按钮, 点下去再得到明确的冲突说明,也不因为读失败把按钮藏掉)。
func (*Store) ListBranchParamEvents ¶ added in v2.1.0
func (s *Store) ListBranchParamEvents(ctx context.Context, branch string, limit int) ([]model.BranchParamEvent, error)
ListBranchParamEvents 返回某个分支的参数事件,新的在前;limit 默认 50、最多 BranchParamEventKeep。
func (*Store) ListCheckpoints ¶
func (*Store) ListConfirmItems ¶
func (s *Store) ListConfirmItems(ctx context.Context, f ConfirmFilter) ([]model.ConfirmItem, error)
ListConfirmItems 列出确认项。
func (*Store) ListCredentialHosts ¶
func (s *Store) ListCredentialHosts(ctx context.Context) ([]CredentialHost, error)
ListCredentialHosts 列出各凭据登记的主机名(只含名称与主机,不含令牌)。
func (*Store) ListCredentials ¶
func (*Store) ListDocWorkflowStats ¶
func (s *Store) ListDocWorkflowStats(ctx context.Context) ([]DocWorkflowStat, error)
ListDocWorkflowStats 各工作流文档数。
func (*Store) ListDraftImages ¶
ListDraftImages 列出一个工作流的草稿图片元数据(不读出正文),按写入时间排序。
func (*Store) ListFeedbackRoundSessions ¶
func (s *Store) ListFeedbackRoundSessions(ctx context.Context, projectDir, status string, limit int) ([]model.FeedbackSession, error)
ListFeedbackRoundSessions 与 ListFeedbackSessions 相同,但在 SQL 里排除「进度通知」(kind=notice)。 通知不是「轮」;若取完 limit 条再在内存里过滤,每发一条通知就会把一轮更早的汇报挤出窗口, 回执里 recent_workflows 的「N 轮」会随通知越变越少(#109)。
func (*Store) ListFeedbackSessions ¶
func (*Store) ListFeedbackSessionsBrief ¶
func (s *Store) ListFeedbackSessionsBrief(ctx context.Context, projectDir, status string, limit int) ([]model.FeedbackSession, error)
ListFeedbackSessionsBrief 获取轻量会话列表(通过字段投影排除大体积正文 summary、response_text、user_messages 和 images,专供小带宽场景下的列表加载)
func (*Store) ListFeedbackSessionsBriefCovering ¶
func (s *Store) ListFeedbackSessionsBriefCovering(ctx context.Context, projectDir, status string, limit int) ([]model.FeedbackSession, error)
ListFeedbackSessionsBriefCovering 在轻量列表「最新 limit 行」之外,再把每个工作流里最新的一行补进来(#173)。
为什么要补:最新 limit 行是按「会话行」数的,一个工作流跑一百轮就是一百行;话痨的工作流多了, 窗口里只剩它们,较早的工作流(哪怕没归档、没删除)一行都不在窗口里,侧栏与归档库就凭空少了它们。 侧栏和归档库要的是「每个工作流一条」,所以窗口之外的工作流各补它最新的一行(同样遵守项目目录与状态过滤)。
约定:
- 结果按创建时间倒序,与 ListFeedbackSessionsBrief 同序,调用方不必改排序;
- 补的行数最多 briefCoverExtraMax,取最近有动静的那些工作流;
- 没有工作流编号的老会话行不补(它们没有「工作流」可言,维持只看最新窗口的老行为);
- 不改 limit 的含义:窗口仍是最新 limit 行,补进来的只是窗口之外的各工作流各一行。
func (*Store) ListGrants ¶
func (s *Store) ListGrants(ctx context.Context, projectID uint, includeInactive bool) ([]model.ACLGrant, error)
ListGrants 列出项目的授权,新的在前;默认只给有效的(没撤销、没过期)。
func (*Store) ListGroupMembers ¶
func (s *Store) ListGroupMembers(ctx context.Context, groupID string, includeLeft bool) ([]model.ConversationMember, error)
ListGroupMembers 列出群成员(先 owner 后 member,按加入先后)。
func (*Store) ListGroupTrash ¶ added in v2.2.0
ListGroupTrash 按删除时间倒序列出群聊回收站(不读快照正文)。
func (*Store) ListGroups ¶
ListGroups 列出群(最近有动静的在前)。
func (*Store) ListInboxItems ¶
func (s *Store) ListInboxItems(ctx context.Context, workflowID string) ([]model.QueuedFeedback, error)
ListInboxItems 返回 Web 上要展示的追加信息(按时间从早到晚)。它们在会话页里是对话中的永久气泡,所以:
- 未确认的(排队中 / 已读取未确认)全部在内;
- 已确认的只保留经提示行 / hook / 主动读取送达的,不再设时间窗口——随「秒回」带走的那些 已经原样出现在对话记录里,不重复展示,而经这三条路径送达的从来不会出现在对话记录里,不留下就查不到了;
- 过期的(保留期内一直没被读到)留一条记录,说明智能体始终没有看到它;
- 已撤回的不在其中。
最多 InboxListMax 条,超出时保留最近的。
func (*Store) ListLiveOAuthGrantsByClient ¶ added in v2.1.0
func (s *Store) ListLiveOAuthGrantsByClient(ctx context.Context, clientID string) ([]model.OAuthGrant, error)
ListLiveOAuthGrantsByClient 返回某个客户端名下还没撤销的授权。
func (*Store) ListLiveOAuthGrantsForClient ¶ added in v2.2.0
func (s *Store) ListLiveOAuthGrantsForClient(ctx context.Context, clientID string) ([]model.OAuthGrant, error)
ListLiveOAuthGrantsForClient 列出同一个应用(client_id)名下还没撤销的授权,新的在前(#294)。 授权页「你之前授权过这个应用」那一栏、批准时对「沿用 / 撤销」目标的校验、签发令牌之后的收尾撤销都靠它认「同一个应用」。
func (*Store) ListManageableCredentials ¶ added in v2.2.0
ListManageableCredentials 返回「MCP 凭据管理」页应当列出的全部凭据: 手动创建的(非隐藏),加上由 OAuth 授权创建且授权仍然有效的那些。其他隐藏凭据(授权已撤销、从未换过令牌)不在其中。
func (*Store) ListOAuthGrants ¶
func (*Store) ListPageDiagReports ¶ added in v2.2.0
func (s *Store) ListPageDiagReports(ctx context.Context, kind string, limit int) ([]model.PageDiagReport, error)
ListPageDiagReports 按时间倒序(最新在前)列出上报,kind 为空 = 两类都要(页面自己交来的与浏览器自报的混在一起按时间排)。 kind 不为空时只列这一种;limit ≤ 0 或超过所在那一类的保留条数时按那一类的保留条数(kind 为空按两类之和的上限)。
func (*Store) ListPendingQueuedFeedbacks ¶
func (s *Store) ListPendingQueuedFeedbacks(ctx context.Context, workflowID string) ([]model.QueuedFeedback, error)
ListPendingQueuedFeedbacks 列出还没有被智能体确认的追加(含已读取未确认的)。保留给旧调用方。
func (*Store) ListProjectDirs ¶
func (*Store) ListProjectDocRevisions ¶
func (s *Store) ListProjectDocRevisions(ctx context.Context, docID uint) ([]model.ProjectDocRevision, error)
ListProjectDocRevisions 修订历史。
func (*Store) ListProjectDocs ¶
func (s *Store) ListProjectDocs(ctx context.Context, f ProjectDocFilter) ([]model.ProjectDoc, error)
ListProjectDocs 列表。
func (*Store) ListProjectModules ¶
func (*Store) ListProjects ¶
ListProjects 按名称排序;默认不含已归档的。
func (*Store) ListPromptRevisions ¶ added in v2.1.0
func (s *Store) ListPromptRevisions(ctx context.Context, workflowID, field string) ([]model.WorkflowPromptRevision, error)
ListPromptRevisions 返回某个会话某个字段的历史版本,新的在前,最多 PromptRevisionKeep 个。
func (*Store) ListRetractionEvents ¶
func (s *Store) ListRetractionEvents(ctx context.Context, workflowID string) ([]RetractionEvent, error)
ListRetractionEvents 列出这个工作流里「智能体知道的追加被撤回」的记录(保留期内、从早到晚、最近 RetractionEventsMax 条), 给 get_session_history 用:经收件箱读到的追加不在历史轮次里,撤回了也就没处留痕。 完全没让智能体知道的撤回(读到之前就撤回、也没提醒过)不在其中;列表只读,不改变任何状态,不带正文与图片。
func (*Store) ListSSHHostCodesViaGateway ¶
ListSSHHostCodesViaGateway 列出经某台网关主机接入的全部 SSH 主机的机器码——**不分状态**(停用的主机也算: 它的凭据仍应保留在网关上,重新启用后要能继续使用)。网关据此回收名单之外的凭据,所以绝不能漏。
func (*Store) ListTerminalArchives ¶
ListTerminalArchives 返回全部已归档条目的 key(最近归档的在前)。
func (*Store) ListTerminalAudit ¶
func (s *Store) ListTerminalAudit(ctx context.Context, limit int, beforeID uint) ([]model.TerminalAuditLog, error)
ListTerminalAudit 按 ID 倒序返回审计记录;beforeID>0 时只返回更早的记录(游标翻页)。
func (*Store) ListTerminalAuditSince ¶
func (s *Store) ListTerminalAuditSince(ctx context.Context, event, result string, since time.Time, limit int) ([]model.TerminalAuditLog, error)
ListTerminalAuditSince 返回某个事件在 since 之后的审计记录,按时间正序排好;result 非空时只取这个结果。 项目管理 Agent 经 MCP 运行预设(#179)的频率账本读它:次数来自审计记录,所以 Hub 重启不会清零。
条数超过 limit(默认 100,上限 500)时留下的是**最新**的 limit 条、丢的是最旧的:账本只关心最近的次数, 反过来(留最旧的)会让一大批被拒绝的尝试把成功的记录挤出窗口,限额就此失效。 事件名带索引;记录总量受 PruneTerminalAudit 的保留条数限制。
func (*Store) ListTerminalHosts ¶
ListTerminalHosts 返回全部主机(按创建时间升序)。
func (*Store) ListTerminalLaunchers ¶
func (s *Store) ListTerminalLaunchers(ctx context.Context) ([]TerminalLauncher, error)
ListTerminalLaunchers 读取全部预设(按保存顺序);从未保存过时返回空列表(不是 nil)。
func (*Store) ListTerminalLostDismissals ¶
func (s *Store) ListTerminalLostDismissals(ctx context.Context) (map[string]map[string]struct{}, error)
ListTerminalLostDismissals 返回全部忽略记录:机器码 → 已忽略的会话 ID 集合。
func (*Store) ListTerminalRuns ¶
ListTerminalRuns 按 ID 倒序返回运行记录(游标翻页)。
func (*Store) ListTerminalRunsByIDs ¶
ListTerminalRunsByIDs 按主键批量读取运行记录(线程汇总取首末两条用)。
func (*Store) ListTerminalSessions ¶
func (s *Store) ListTerminalSessions(ctx context.Context, machineCode string, endedOnly bool, limit int) ([]model.TerminalSession, error)
ListTerminalSessions 返回一台主机的会话索引(最近创建的在前);endedOnly 时只返回已结束的。 记录已被主机清理(RecPurged)的已结束会话不再列出。
func (*Store) ListTerminalThreads ¶
func (s *Store) ListTerminalThreads(ctx context.Context, f ThreadFilter) ([]ThreadStat, error)
ListTerminalThreads 按「最近一次运行」倒序返回线程汇总。只聚合元数据,不读取预览等大字段。
func (*Store) ListUnusedOAuthClients ¶ added in v2.1.0
func (s *Store) ListUnusedOAuthClients(ctx context.Context, since time.Time) ([]model.OAuthClient, error)
ListUnusedOAuthClients 返回从未签发过令牌的 DCR 登记(登记后还没走完授权),新的在前;since 非零时只要这个时间之后登记的。 一旦某个客户端第一次拿到令牌(TouchOAuthClient 写入 last_used_at),它就不再出现在这里,改在授权列表里管理。
func (*Store) ListUserNorms ¶
func (*Store) ListVisibleCredentials ¶
func (*Store) ListWorkItemWorkflows ¶
func (s *Store) ListWorkItemWorkflows(ctx context.Context) ([]WorkflowStat, error)
ListWorkItemWorkflows 列出有任务的工作流及其概况,最近更新的在前。 同一张任务板上的工作流各占一条,数字都是整张板的(见 WorkflowStat)。
func (*Store) ListWorkItems ¶
ListWorkItems 列出任务(不含时间线),最近更新的在前;同时补齐子任务进度、父任务和关联会话数。
func (*Store) ListWorkModules ¶
ListWorkModules 返回工作流所在任务板的规划树(按树的顺序拍平,含任务汇总)与未归类的汇总。
func (*Store) ListWorkflowBindings ¶
func (s *Store) ListWorkflowBindings(ctx context.Context) ([]WorkflowBinding, error)
ListWorkflowBindings 按工作流汇总当前绑定,最近活跃的在前;供运维先看清再改绑。
func (*Store) ListWorkflowFeedbackSessions ¶
func (s *Store) ListWorkflowFeedbackSessions(ctx context.Context, workflowID string) ([]model.FeedbackSession, error)
ListWorkflowFeedbackSessions 获取指定工作流的所有完整会话(按 created_at ASC 升序,包含完整图文正文,按需呈现对话流)
func (*Store) ListWorkflowSessionBodies ¶
func (s *Store) ListWorkflowSessionBodies(ctx context.Context, workflowID string, ids []string) ([]model.FeedbackSession, error)
ListWorkflowSessionBodies 按 id 取一批会话的完整正文(#169 第二期「正文按需」): 只读正文相关的列(summary / response_text / user_messages / images)与定位用的 id / 时间戳,不读其余列。 范围限定在这个工作流里(与 ListWorkflowFeedbackSessions 同一个口径:workflow_id 等于它,或会话 id 就是它), 所以拿别的工作流的 id 来问只会得到空结果,不会越界读到别处的正文。结果按创建时间升序;不存在的 id 直接略过。
func (*Store) ListWorkflowSessionLinks ¶
func (s *Store) ListWorkflowSessionLinks(ctx context.Context, workflowID string) ([]model.WorkItemSessionLink, error)
ListWorkflowSessionLinks 返回一个工作流所在任务板上所有「会话 ↔ 任务」的关联,以及每个会话对每个任务做了什么。 会话页按轮次展开任务时用:一次查询取回整张板,不必为每一轮各查一次。 「做了什么」只依赖任务时间线里还保留的条目(每个任务最近 WorkUpdatesKeep 条)。
func (*Store) ListWorkflowSessionsBefore ¶ added in v2.2.0
func (s *Store) ListWorkflowSessionsBefore(ctx context.Context, workflowID, beforeID string, limit int, filter SessionKindFilter) ([]model.FeedbackSession, error)
ListWorkflowSessionsBefore 按「创建时间新→旧」读一个工作流的会话,可用游标翻页: beforeID 非空时只给比它更早的;filter 选汇报轮次 / 进度通知 / 都要。条数的规整同 GetSessionsByWorkflow(≤ 0 默认 10,上限 200)。 get_session_history 用它按字符预算分批往回翻(#303)。
func (*Store) ListWorkflowSummaries ¶
func (*Store) ListWorkflowTrash ¶ added in v2.2.0
ListWorkflowTrash 按删除时间倒序列出回收站(不读快照正文)。
func (*Store) ListWorkflowUpdates ¶
func (s *Store) ListWorkflowUpdates(ctx context.Context, workflowID string, since time.Time, limit int) ([]WorkflowUpdate, error)
ListWorkflowUpdates 返回一个工作流里「智能体」写下的任务进展,按提交时间升序,最多 limit 条最新的。 人在网页上点状态 / 改进度是自己做的事,不进对话;since 非零时只要这个时间之后的。
func (*Store) MarkBranchParamEventsTold ¶ added in v2.1.0
MarkBranchParamEventsTold 记下「这些事件已经告诉了分支」;已标记过的不改。
func (*Store) MarkGroupMentionsRead ¶
func (s *Store) MarkGroupMentionsRead(ctx context.Context, groupID, workflowID string, messageIDs []uint) error
MarkGroupMentionsRead 把某个成员收件箱里、对应这些群消息的提醒行标为已读取并确认:Agent 用 chat read 读到了它们。
func (*Store) MarkHookInstallHint ¶
MarkHookInstallHint 记下刚刚在回执里提示过安装 hook。
func (*Store) MarkInboxReceiptHint ¶
func (s *Store) MarkInboxReceiptHint(ctx context.Context, workflowID string, now time.Time) (bool, error)
MarkInboxReceiptHint 记下「回执提示行刚刚提醒过」,用于在读取时把送达归因到这条路径。 时间戳至多每分钟写一次。 返回 true 表示这次真的写了库(界面据此决定要不要刷新)。
func (*Store) MarkModeTold ¶
MarkModeTold 记下「已经把当前模式状态告诉了智能体」(签名见 asyncmode.Signature)。
func (*Store) MarkResidentTold ¶ added in v2.1.0
MarkResidentTold 记下「智能体已经见到常驻提示词的第 rev 版」;只往前走,不会把已告知的版本改小。
func (*Store) MarkSessionConsumedByAI ¶
func (*Store) MarkTerminalSessionPurged ¶
MarkTerminalSessionPurged 标记主机上的记录已不存在(过期或被清理)。
func (*Store) MarkWorkflowHistorySessionsConsumed ¶
MarkWorkflowHistorySessionsConsumed 自动将某工作流下所有已完成但未被消费的历史轮次批量打标为已消费(D-159)
func (*Store) MigrationDryRun ¶
MigrationDryRun 只读:报告「如果现在确认,每篇文档会去哪里」。
func (*Store) ModuleOwnerFor ¶
ModuleOwnerFor 返回模块的负责人:模块自己没有就沿父模块往上找最近的一个。没有返回 0。
func (*Store) ModulePage ¶
func (s *Store) ModulePage(ctx context.Context, projectID uint, modulePath string) (*ModulePageView, error)
ModulePage 聚合一个模块(含子模块下的文档)的页面。
func (*Store) MoveWorkModule ¶
MoveWorkModule 在同级里上移(delta<0)或下移(delta>0)一格;已在边界时什么也不做。返回最新的规划树。
func (*Store) NeedsHookInstallHint ¶
NeedsHookInstallHint 判断是否在回执末尾提示安装 hook(无 hook 痕迹或超过 24h,且 6h 内未提示过)。
func (*Store) NewArchiveSource ¶ added in v2.2.0
NewArchiveSource 解析项目的导出范围:
- 最近一条带目录的会话落在项目登记目录里的工作流(via = directory);
- 以及这些工作流名下的分支——分支会话可以建在别的目录里,但它的过程信息属于这个项目(via = branch)。
反过来,项目里的分支如果主会话在别的项目,主会话不会被拖进来,只在分支的记录里留下 parent 编号。
func (*Store) NotifyMainBranchCreated ¶ added in v2.1.0
func (s *Store) NotifyMainBranchCreated(ctx context.Context, rel model.WorkflowBranch) (*model.QueuedFeedback, error)
NotifyMainBranchCreated 在用户于网页里给某个会话建了分支之后,给主会话的收件箱写一行说明(主会话由此知道有了新分支)。
func (*Store) OAuthGrantsByCredentialIDs ¶ added in v2.2.0
func (s *Store) OAuthGrantsByCredentialIDs(ctx context.Context, ids []uint) (map[uint]model.OAuthGrant, error)
OAuthGrantsByCredentialIDs 一次读出一批凭据对应的、仍然有效的 OAuth 授权,键是凭据编号;没有授权的凭据不在结果里。
func (*Store) PageDiagStats ¶ added in v2.2.0
func (s *Store) PageDiagStats(ctx context.Context) (PageDiagStats, error)
PageDiagStats 统计两类上报;BrowserReportsOn 是「接收浏览器自报崩溃」开关当前的值。
func (*Store) PageSearchViaIndex ¶ added in v2.2.0
PageSearchViaIndex 报告设置里「页面搜索走全文索引」是否打开(没设过 = 打开)。
func (*Store) ParamEffects ¶ added in v2.1.0
func (s *Store) ParamEffects(ctx context.Context, branch string, evs []model.BranchParamEvent) []ParamEffect
ParamEffects 给出一次参数写入 / 撤销之后要广播的现有事件:常驻规则与唤醒词弹窗、阶段滑块、会话标题、异步开关 本来就靠这些事件刷新,主会话(session_params)或用户撤销改了它们之后同样要发,否则开着那个分支页面的人要手动刷新才看得到。 evs 里的 NewValue 是写入之后的值;按字段去重(常驻规则与两个唤醒词共用 workflow_prompts_updated),顺序固定。 读会话失败时跳过标题那一条(界面下次拉取也会更新),不影响其它事件。
func (*Store) PeekArchiveBaseline ¶ added in v2.2.0
func (s *Store) PeekArchiveBaseline(ctx context.Context, id string, projectID, credentialID uint, now time.Time) (*model.ArchiveBaseline, error)
PeekArchiveBaseline 与 GetArchiveBaseline 的检查完全相同,但不读摘要体:登记导出时只需要确认「这条基线现在能用」和它的范围。
func (*Store) PendingBranchAsks ¶ added in v2.1.0
func (s *Store) PendingBranchAsks(ctx context.Context, mainWorkflowID string) ([]PendingBranchAsk, error)
PendingBranchAsks 列出路由给这个主会话、仍待处理的请示(最早的在前)。没有时返回空切片(回执头据此一个字都不输出)。
func (*Store) PlanBranchLink ¶ added in v2.1.0
func (s *Store) PlanBranchLink(ctx context.Context, in LinkBranchInput) (*LinkBranchResult, error)
PlanBranchLink 只做预演:跑一遍与 LinkBranch 完全相同的校验,然后回滚,什么都不写。
func (*Store) PostBoardGroupLines ¶ added in v2.1.0
PostBoardGroupLines 把一批协作事件写成群里的系统行,返回写入了新行的群(调用方据此通知网页刷新)。
它在任务写入成功「之后」调用,是尽力而为:失败只影响群里的可见性,不影响任务本身,所以调用方只记日志。 不在 WithTx 里调用它(WithTx 持有存储的全局锁,不可重入)。
func (*Store) PostGroupMessage ¶
func (s *Store) PostGroupMessage(ctx context.Context, in PostGroupInput) (*PostGroupResult, error)
PostGroupMessage 落库一条群消息并按规则表投递(见文件头)。
func (*Store) PreviewGroupTrash ¶ added in v2.2.0
PreviewGroupTrash 只读:算出删除这个群的范围,并检查有没有拦着不让删的原因。
func (*Store) PreviewHostGrant ¶
PreviewHostGrant 返回把 machineCode 授予现有模型令牌时会被改动的令牌名称,不写入任何数据。
func (*Store) PreviewWorkflowTrash ¶ added in v2.2.0
PreviewWorkflowTrash 只读:算出删除这条会话的范围,并检查有没有拦着不让删的原因。
func (*Store) ProjectBlueprint ¶
func (s *Store) ProjectBlueprint(ctx context.Context, projectID uint, withTemplates bool) ([]docs.BlueprintItem, error)
ProjectBlueprint 项目知识库的推荐结构与缺口。
func (*Store) ProjectBoardsOf ¶ added in v2.2.0
ProjectBoardsOf 列出项目相关的任务板:项目自己的板 + 项目成员工作流名下任务所在的其它板。
func (*Store) ProjectOfDir ¶
ProjectOfDir 返回(主机,目录)所属的项目;没有归属返回 nil, nil。host 为空时只按目录匹配(取最早登记的一条)。
func (*Store) ProjectOfWorkflow ¶
ProjectOfWorkflow 返回工作流所属的项目;没有归属(或没有任何汇报会话)返回 nil, nil。
func (*Store) ProjectStatsOf ¶
ProjectStatsOf 统计项目的目录、模块、文档与工作流数量。
func (*Store) ProjectSuggestions ¶
func (s *Store) ProjectSuggestions(ctx context.Context) ([]ProjectSuggestion, error)
ProjectSuggestions 列出还没有归属项目的目录:每个(主机,目录)一条,名字取目录名。 用户可以逐条确认成项目,也可以把几条合并到同一个项目里(比如同一仓库的几个工作树)。
func (*Store) ProjectWorkflowIDs ¶
ProjectWorkflowIDs 列出项目里所有工作流(最近一次汇报会话的目录落在项目目录里的),按编号排序。
func (*Store) PruneArchiveBaselines ¶ added in v2.2.0
PruneArchiveBaselines 做一次全局清理:过期的、登记中太久的、令牌或项目已经不存在的。返回删除的条数。
func (*Store) PruneSemanticProjects ¶ added in v2.2.0
PruneSemanticProjects 去掉已经不存在的项目的勾选(项目被删除后留下的悬空记录),返回被去掉的 ID。
func (*Store) PruneTerminalAudit ¶
PruneTerminalAudit 只保留最近 keep 条审计记录,返回删除条数。
func (*Store) PruneTerminalRuns ¶
PruneTerminalRuns 删除结束时间早于 cutoff 的运行元数据,返回删除条数。
func (*Store) PruneTerminalSessions ¶
PruneTerminalSessions 删除结束时间早于 cutoff 的会话索引,返回删除行数。
func (*Store) PurgeExpiredGroupTrash ¶ added in v2.2.0
func (s *Store) PurgeExpiredGroupTrash(ctx context.Context, now time.Time) ([]model.GroupTrash, error)
PurgeExpiredGroupTrash 彻底清理保留期已满的群聊条目,返回被清理的条目(不含快照正文,供记审计)。
func (*Store) PurgeExpiredWorkflowTrash ¶ added in v2.2.0
func (s *Store) PurgeExpiredWorkflowTrash(ctx context.Context, now time.Time) ([]model.WorkflowTrash, error)
PurgeExpiredWorkflowTrash 彻底清理保留期已满的条目,返回被清理的条目(不含快照正文,供记审计)。
func (*Store) PurgeUnusedOAuthClients ¶
PurgeUnusedOAuthClients 删除从未成功授权且超过 maxAge 的 DCR 客户端。
func (*Store) PutDraftImage ¶
PutDraftImage 保存(或重新确认)一张草稿图片:同一工作流里相同的内容键只存一份,重复上传是幂等的,只刷新写入时间。 超过单张 / 张数 / 总量配额时返回 invalid_input,不写入任何内容。
func (*Store) PutEmbeddingCredential ¶ added in v2.2.0
PutEmbeddingCredential 保存(或替换)密封的密钥。
func (*Store) PutGuiWakeConfig ¶ added in v2.2.0
func (s *Store) PutGuiWakeConfig(ctx context.Context, cfg GuiWakeConfig) (GuiWakeConfig, error)
PutGuiWakeConfig 校验并整份保存目标配置;返回规整后实际保存的内容。校验不通过时不写库,错误可直接展示给用户。
func (*Store) QueueWorkflowFeedback ¶
func (s *Store) QueueWorkflowFeedback(ctx context.Context, input QueueFeedbackInput) (*model.QueuedFeedback, error)
QueueWorkflowFeedback 把一条追加存进收件箱。每条独立一行,不再合并。
func (*Store) ReadBranchHistory ¶ added in v2.1.0
func (s *Store) ReadBranchHistory(ctx context.Context, caller, branchWorkflowID string, limit int) (*BranchHistory, error)
ReadBranchHistory 主会话读自己某个分支最近几轮的汇报,按开放范围裁剪:off 拒绝,summary 每轮标题 + 首行,full 全文(不含图片)。 caller 必须是该分支的主会话,且关系仍然生效。
func (*Store) ReadFeedbacks ¶
func (*Store) ReadReports ¶
func (*Store) RebindWorkflow ¶
func (s *Store) RebindWorkflow(ctx context.Context, req RebindRequest, apply bool) (*RebindResult, error)
RebindWorkflow 把一个工作流改绑到新的项目目录(可同时改主机)。
apply=false 只做预演:返回当前画像与将要改写的行数,不写入任何数据。 apply=true 在单个事务里改写,并在提交前校验结果(目录唯一、主机符合预期),任何一项不符就整体回滚。 改写使用 UpdateColumns:保持 updated_at 不变,避免这个工作流「看起来刚刚活跃过」而打乱最近活跃排序。
func (*Store) RebuildSearchIndex ¶ added in v2.2.0
RebuildSearchIndex 在前台整体重建全文索引(运维与测试用)。
func (*Store) RecentWorkflows ¶
RecentWorkflows 列出有过汇报会话的工作流(最近有动静的在前),每个工作流取最近一条会话的项目目录与主机。
func (*Store) ReconcileReplyWindow ¶
func (s *Store) ReconcileReplyWindow(ctx context.Context, workflowID string, now time.Time) (w ReplyWindow, changed bool, err error)
ReconcileReplyWindow 读出窗口并按任务情况对齐:有任务在做就把走动中的窗口暂停(剩余攒进 BankSec), 任务清零后再从攒着的时间接着走。changed 表示这次对齐改动了数据(调用方据此广播)。 「有任务在做」收尾门开着时按门口径数(本会话名下未完成、不按时间截断),门关着时按老口径(见 windowLoad)。
func (*Store) RecordAgentActivity ¶
RecordAgentActivity 记下某个工作流的智能体刚刚调用过 RelayMesh。
func (*Store) RecordAgentEvent ¶
func (s *Store) RecordAgentEvent(ctx context.Context, workflowID string, ev AgentEvent, at time.Time)
RecordAgentEvent 记下某个工作流的智能体刚汇报的一次事件。对话编号变了才写库,写库失败只丢掉持久化,不影响内存里的记录。
func (*Store) RecordHookSeen ¶
RecordHookSeen 记下某个工作流的编辑器 hook 刚刚来问过一次。 返回值表示要不要通知 Web 刷新:之前从没记过,或距上一次记录已超过 InboxHookSeenBroadcastEvery。 时间同时按 HookSeenPersistEvery 节流落库,Hub 重启后由 RestoreHookSeen 装回来(#103,见 hook_seen.go)。
func (*Store) RecordSSHCheck ¶
RecordSSHCheck 记录一次连接尝试。成功时清除错误并刷新主机自报信息;密钥不一致时置位 mismatch(只升不降)。
func (*Store) RecordTerminalSessionEnds ¶
func (s *Store) RecordTerminalSessionEnds(ctx context.Context, machineCode string, ends []TerminalSessionEnd, now time.Time) error
RecordTerminalSessionEnds 把若干会话标记为已结束并记下(精确的)原因: 不在索引里的补建;尚未结束的记下结束时间;已结束但原因较弱(gone / exit)的改写为这个更精确的原因, 已有精确原因的不会被覆盖。
func (*Store) RecycleOldestUnusedOAuthClient ¶
RecycleOldestUnusedOAuthClient 回收最老的从未使用客户端,成功返回 true。
func (*Store) RefundKeepaliveFeedbackSession ¶ added in v2.2.0
func (s *Store) RefundKeepaliveFeedbackSession(ctx context.Context, sessionID string, extendSec int) error
RefundKeepaliveFeedbackSession 退掉一次 KeepaliveFeedbackSession 的记账(空等次数 -1、累计时长 -extendSec,都不会低于 0)。 Hub 退出时的「排空」把一轮挂起的等待提前叫醒(#307):用户没有来得及发言,这一轮不该算一次空等, 否则每次热更新都会白白用掉一次收尾宽限(默认共 24 轮)。只对还在等待中(pending)的会话生效,其余情况什么都不做; 用单条 UPDATE 带算术表达式,不读出整行再写回,不会盖掉别处刚写入的内容(比如用户恰好提交的回复)。
func (*Store) RegenerateCredentialToken ¶
func (*Store) ReleaseGate ¶ added in v2.1.0
func (s *Store) ReleaseGate(ctx context.Context, workflowID string, now time.Time) (ReplyWindow, error)
ReleaseGate 「本次放行」:这一轮回复窗口不再被任务挡住,立刻恢复倒计时;任务本身一概不动。 下一次用户回复、或窗口走完后重新起算时自动复位。没有窗口在等(或门已关)时放行没有意义,返回冲突并说明。
func (*Store) RemoveGroupMember ¶
RemoveGroupMember 把成员移出群:保留一行(离开之后的消息它看不到),写系统行。
func (*Store) RemoveProjectDir ¶
func (*Store) RenameAgentIdentity ¶
func (s *Store) RenameAgentIdentity(ctx context.Context, id uint, name, by string) (*AgentIdentityView, error)
RenameAgentIdentity 给身份改名(空串 = 恢复用目录名)。改名写一条审计事件,不改变身份编号。
func (*Store) RenameFeedbackSession ¶
func (*Store) RenderWake ¶ added in v2.1.0
func (s *Store) RenderWake(ctx context.Context, in WakeInput) WakeResult
RenderWake 一步到位:选模板、现算「现状」变量、渲染。出错一律宽容(变量缺了显示「(暂无)」), 唤醒词的发送不能因为统计信息读不出来而失败。
func (*Store) ReplaceSidebarOrder ¶ added in v2.2.0
func (s *Store) ReplaceSidebarOrder(ctx context.Context, baseVersion int64, keys []string) (SidebarOrder, error)
ReplaceSidebarOrder 在一个事务里整表替换侧栏顺序:baseVersion 必须等于当前版本,新版本是当前版本 + 1。 键表形状不对返回包装了 ErrInvalidSidebarOrder 的错误(库里保持原样);版本不一致返回 ErrSidebarOrderConflict, 同时把库里当前的顺序一并返回,方便调用方原样交给前端重放。
func (*Store) ReserveEmbeddingTokens ¶ added in v2.2.0
func (s *Store) ReserveEmbeddingTokens(ctx context.Context, day string, estimate, cap int64) (bool, error)
ReserveEmbeddingTokens 原子地检查并预留今天的预算(见 embedding.Persistence)。
func (*Store) ResetAgentSearchQuota ¶ added in v2.2.0
func (s *Store) ResetAgentSearchQuota(ctx context.Context) (AgentSearchQuota, error)
ResetAgentSearchQuota 把三项额度恢复成默认值(删掉存的三行,以后升级改了默认值也会跟着变)。
func (*Store) ResetAuthCredentials ¶
ResetAuthCredentials 删除数据库中的账号密码记录,回退为环境变量值
func (*Store) ResetSearchHintsConfig ¶ added in v2.2.0
func (s *Store) ResetSearchHintsConfig(ctx context.Context) (SearchHintsConfig, error)
ResetSearchHintsConfig 把五项恢复成默认值(删掉存的五行,以后升级改了默认值也会跟着变)。
func (*Store) ResidentWriter ¶ added in v2.1.0
ResidentWriter 返回某个会话「当前这一版常驻规则」的写入者(最近一条常驻规则历史版本的操作者);没有历史返回空串。 回执头据此判断来源:agent:<主会话> = 主会话代写,其它 = 用户本人。 不用 workflow_prompts.updated_by:它在保存唤醒词时也会被覆盖,会把「用户写的常驻规则」误标成别人写的。
func (*Store) ResolveArtifactComment ¶
func (s *Store) ResolveArtifactComment(ctx context.Context, docID, commentID uint, resolved bool) (*model.ArtifactComment, error)
ResolveArtifactComment 把评论标成已解决 / 重新打开。
func (*Store) ResolveAuthProfile ¶
ResolveAuthProfile 取工作流选用的档位:id 为 0 或档位已不存在时回退到默认档位。
func (*Store) ResolveCallerIdentity ¶
func (s *Store) ResolveCallerIdentity(ctx context.Context, workflowID string, credentialID uint, host, dir string, now time.Time) (id uint, asserted bool)
ResolveCallerIdentity 回答「这次调用是谁」:带了 project_directory 的是明确断言(asserted=true); 没带就按工作流绑定的目录推断(asserted=false,审计里标 assumed)。认不出目录返回 0。
func (*Store) ResolveDocModule ¶
func (s *Store) ResolveDocModule(ctx context.Context, projectID uint, docPath, explicit string) string
ResolveDocModule 返回一篇文档(路径 + 可选的显式模块)实际会绑定到的模块路径;没有则空串。
func (*Store) ResolveDraftImages ¶
func (s *Store) ResolveDraftImages(ctx context.Context, workflowID string, keys []string) (map[string]model.DraftImage, error)
ResolveDraftImages 按内容键取回一批草稿图片(含正文),缺失的键不会出现在结果里。
func (*Store) ResolveJWTSecret ¶
func (s *Store) ResolveJWTSecret(ctx context.Context, envSecret string) (JWTSecretResolution, error)
ResolveJWTSecret 决定本次运行使用的 JWT 签名密钥,优先级:
- 强度合格的环境变量(envSecret);
- 数据库中已持久化的强密钥;
- 首次启动自动生成 384 bit 随机密钥并持久化。
无论如何都不会返回内置默认值或弱密钥:数据库不可写时降级为仅本进程有效的随机密钥(重启后需重新登录), 而不是回退到可被公开源码推导出的固定值。只有系统随机数源本身失败才会返回错误。
func (*Store) ResolveWakeTemplate ¶ added in v2.1.0
func (s *Store) ResolveWakeTemplate(ctx context.Context, kind sessionprompt.Kind, workflowID, presetBody string, hasWorkflow bool) (string, WakeLayer)
ResolveWakeTemplate 按分层选出模板。hasWorkflow 影响内置默认的写法(见 sessionprompt.Builtin)。 网页启动提示词的内置默认不在这里(它由 WebWorkflowStartPrompt 生成),builtin 层返回空串,由调用方兜底。
func (*Store) ResolveWorkModule ¶
func (s *Store) ResolveWorkModule(ctx context.Context, workflowID, ref string) (*model.WorkModule, error)
ResolveWorkModule 按路径解析模块(见 moduleForest.resolve)。找不到时错误里带着已有的路径清单。
func (*Store) RestoreFeedbackSession ¶
func (s *Store) RestoreFeedbackSession(ctx context.Context, session *model.FeedbackSession) (*model.FeedbackSession, error)
RestoreFeedbackSession 复原被删除的会话(支持撤销删除)
func (*Store) RestoreGroupTrash ¶ added in v2.2.0
RestoreGroupTrash 把回收站里的一个群原样放回去(群恢复后仍是已归档状态),并删掉回收站条目。 授权不会被恢复;成员工作流已不存在的放回时记为已离开;绑定的项目已不存在的清空绑定。
func (*Store) RestoreHookSeen ¶
RestoreHookSeen 在启动时把库里的 hook 时间装回内存,并清掉太久以前的记录。不会覆盖内存里更新的值。 返回错误只用于测试与排查:启动流程把它当成尽力而为(装不回来就退回「从头记」的旧行为,那是保守的)。
func (*Store) RestoreProjectDocRevision ¶
func (s *Store) RestoreProjectDocRevision(ctx context.Context, docID uint, rev int, actor DocActor) (*ProjectDocSaveResult, error)
RestoreProjectDocRevision 还原为新修订。
func (*Store) RestoreResidentRevision ¶ added in v2.1.0
func (s *Store) RestoreResidentRevision(ctx context.Context, workflowID string, revisionID uint, actor string, now time.Time) (model.WorkflowPrompt, bool, error)
RestoreResidentRevision 把某个历史版本的文字存成新的当前版本(版本号继续往前走,不改写历史)。
func (*Store) RestoreWorkflowTrash ¶ added in v2.2.0
RestoreWorkflowTrash 把回收站里的一条原样放回去(轮次保持归档状态,仍在归档库里),并删掉回收站条目。
func (*Store) RevertBranchParamEvent ¶ added in v2.1.0
func (s *Store) RevertBranchParamEvent(ctx context.Context, branch string, eventID uint, actor string, now time.Time) (*BranchParamRevert, error)
RevertBranchParamEvent 撤销主会话的一次参数写入(只有人能调,网页登录态;权限在 API 层)。 只在「这条事件是该字段最新一条未撤销的主会话写入」且「当前值仍等于它写入的值」时成功,否则返回冲突并写明原因; 撤销与关系状态无关(分支被结束后事件仍在,撤销仍可用)。常驻规则 / 唤醒词用 Save… 存成新版本(历史不改写)。 撤销本身记一条 by=human 的事件,下一次分支回执的 params: 行会告诉它。
func (*Store) RevokeGrant ¶
RevokeGrant 撤销一条授权(幂等:已撤销的再撤销不报错)。
func (*Store) RevokeOAuthGrant ¶
func (*Store) RevokeQueuedFeedback ¶
func (s *Store) RevokeQueuedFeedback(ctx context.Context, queuedID uint) (*RevokedFeedbackResult, error)
RevokeQueuedFeedback 撤回一条追加。智能体完全不知道的(没读过、也没被提醒过)直接作废,什么都不用告诉它; 已被读取、或被 hook / 提示行提醒过但还没读的,标为撤回并记下撤回时间,在下一次读取收件箱时告诉智能体忽略它 (被提醒过但没读的只告知编号,不再给正文)。已确认的不能撤回。
func (*Store) RevokeSessionFeedback ¶
func (s *Store) RevokeSessionFeedback(ctx context.Context, sessionID string) (*RevokedFeedbackResult, *model.FeedbackSession, error)
func (*Store) RotateOAuthGrantRefresh ¶ added in v2.2.0
func (s *Store) RotateOAuthGrantRefresh(ctx context.Context, id uint, newHash string, graceUntil, idleUntil *time.Time) error
RotateOAuthGrantRefresh 在一条语句里完成刷新令牌轮换:当前令牌退为「上一枚」(带宽限期)、写入新令牌、顺延闲置到期时间。 一条语句意味着要么全成要么全不成:旧写法分两条,第二条(闲置到期)失败会留下「新令牌已生效、闲置期限却是旧值」的半截状态; 调用方也必须检查返回的错误——写失败时不能把新令牌交给连接器,否则它手里的令牌库里根本没有,下一次刷新就只能要求重新连接(#310)。
func (*Store) SaveArchiveBaseline ¶ added in v2.2.0
SaveArchiveBaseline 登记一条基线(状态 pending)。同一个编号可以重写:同一张下载票据重试时会重新生成包,也就重新登记; 但只能改写自己(同一项目、同一令牌)还没转正的那一条,已经 ready 的或别人的不能被覆盖。
func (*Store) SaveAuthCredentials ¶
SaveAuthCredentials 保存或更新账号密码至数据库
func (*Store) SaveCheckpoint ¶
func (*Store) SaveOAuthPolicy ¶
func (*Store) SaveResidentPrompt ¶ added in v2.1.0
func (s *Store) SaveResidentPrompt(ctx context.Context, workflowID, text, actor string, now time.Time) (model.WorkflowPrompt, bool, error)
SaveResidentPrompt 保存常驻提示词。内容与现有的一致时什么也不做(changed=false,不涨版本); 否则版本号加一并写一条历史版本(每个会话保留最近 model.PromptRevisionKeep 个)。 空串表示清除:同样涨版本,让智能体下一次回执知道「常驻指令已清除」。从没配置过的会话保存空串仍是什么也不做。
func (*Store) SaveSettings ¶
SaveSettings 保存全局配置至数据库
func (*Store) SaveTerminalHost ¶
SaveTerminalHost 在事务内创建或更新主机状态,并校验公钥一致:
- 不存在:按传入内容创建;
- 已存在:公钥必须逐字节一致,否则返回 ErrTerminalKeyMismatch;更新状态 / 备注 / 自报字段。
enabledAt 非 nil 时写入启用时间。
func (*Store) SaveWakeTemplate ¶ added in v2.1.0
func (s *Store) SaveWakeTemplate(ctx context.Context, workflowID string, kind sessionprompt.Kind, text, actor string, now time.Time) (model.WorkflowPrompt, bool, error)
SaveWakeTemplate 保存会话自己的唤醒词模板(kind 只能是 resume / new)。空串 = 清除,回到全局 / 内置。 内容与现有的一致时什么也不做(changed=false);否则写一条历史版本(每个会话每个字段保留最近 PromptRevisionKeep 个)。 与常驻提示词不同,模板是 Hub 发送时读的,不是智能体在回执里读的,所以不涨 ResidentRev、也不需要「已告知」。
func (*Store) SaveWorkflowDraft ¶
func (s *Store) SaveWorkflowDraft(ctx context.Context, workflowID string, activeIndex int, draftsJSON string) (*model.WorkflowDraft, error)
SaveWorkflowDraft 保存或更新工作流草稿数据
func (*Store) Search ¶ added in v2.2.0
func (s *Store) Search(ctx context.Context, q SearchQuery) (*SearchResult, error)
Search 执行一次全文检索:先把已知的脏行同步进索引(自己刚写完马上搜得到),再取 FTS5 候选、 回源重新加载并校验文本与归属,最后按「标题命中优先、再按新近」排序分页。 不能走索引的查询(只剩单个汉字等)返回 TooShort,调用方自行决定提示或回退。
func (*Store) SearchCandidates ¶ added in v2.2.0
func (s *Store) SearchCandidates(ctx context.Context, q SearchCandidateQuery) *CandidateSet
SearchCandidates 向全文索引要一个范围内的候选引用集。它从不返回错误:不能用索引的情形都表现为 legacy + reason, 由页面走原来的逻辑(索引故障不会让页面搜索失效)。
流程:开关 → 索引是否在工作 → 检索词能否走索引 → 这一类是否回填完 → 解析范围 → 查询前先把已知脏行同步进索引(读己之写) → 取 FTS5 候选(超过上限就回退)→ 用校验器核对(文本与归属以「现在的原文」为准)→ 一条都没有也回退。
func (*Store) SearchHintsConfig ¶ added in v2.2.0
func (s *Store) SearchHintsConfig(ctx context.Context) (SearchHintsConfig, error)
SearchHintsConfig 读相关线索的五项设置。每次给智能体附线索、每次用户发消息都会读一次,五行主键查询,开销可以忽略。
func (*Store) SearchIndexEnabled ¶ added in v2.2.0
SearchIndexEnabled 报告全文索引当前是否在工作(开关打开且引擎可用)。
func (*Store) SearchProject ¶
func (s *Store) SearchProject(ctx context.Context, f ProjectSearchFilter) ([]ProjectSearchHit, error)
SearchProject 在项目的全部文档里搜索(打分排序)。没有关键词时按最近更新排序返回过滤后的文档。
func (*Store) SearchProjectDocs ¶
func (s *Store) SearchProjectDocs(ctx context.Context, workflowID, query string, limit int) ([]docs.SearchHit, error)
SearchProjectDocs 搜索(打分排序)。
func (*Store) SearchStatus ¶ added in v2.2.0
func (s *Store) SearchStatus(ctx context.Context) (*SearchIndexStatus, error)
SearchStatus 汇总全文索引的状态。关闭或不可用时只返回原因,不做任何计数查询。
func (*Store) SearchWorkItems ¶ added in v2.2.0
func (s *Store) SearchWorkItems(ctx context.Context, q WorkSearchQuery) (*WorkSearchResult, error)
SearchWorkItems 在任务板的全部任务里检索(见文件头说明)。检索词为空报「请输入检索词」。
func (*Store) SeedDefaultAuthProfile ¶
SeedDefaultAuthProfile 保证至少有一档默认档位;幂等。
func (*Store) SemanticChunkVectors ¶ added in v2.2.0
func (s *Store) SemanticChunkVectors(ctx context.Context, kind, ref string) (map[string]model.EmbedChunk, error)
SemanticChunkVectors 返回一个条目现有的块,按块哈希索引:重新切块后,哈希相同的块直接复用向量,不再外发。
func (*Store) SemanticClear ¶ added in v2.2.0
SemanticClear 删除全部条目与向量块(不动勾选的项目与运行设置),返回删掉的条目数与块数。
func (*Store) SemanticDeleteEntries ¶ added in v2.2.0
func (s *Store) SemanticDeleteEntries(ctx context.Context, keys []SemanticKey) error
SemanticDeleteEntries 删除条目及其全部向量块(在一个事务里)。
func (*Store) SemanticEligible ¶ added in v2.2.0
func (s *Store) SemanticEligible(ctx context.Context, kinds []string, projectIDs []uint) (SemanticSet, error)
SemanticEligible 列出「已勾选项目的范围 ∩ 允许类型」内的全部候选条目(不含已归档的内容)。 这是同意范围(V2)的唯一来源:流水线只会处理这里出现的条目。
func (*Store) SemanticEntries ¶ added in v2.2.0
func (s *Store) SemanticEntries(ctx context.Context) (map[string]map[string]model.EmbedEntry, error)
SemanticEntries 返回库里全部已处理条目(不含向量),类型 → ref → 条目。
func (*Store) SemanticLoad ¶ added in v2.2.0
func (s *Store) SemanticLoad(ctx context.Context, kind string, refs []string) ([]SemanticText, error)
SemanticLoad 回源读取一批条目的最新原文;找不到(已删除 / 不在了)的 ref 不出现在结果里。
func (*Store) SemanticProjectIDs ¶ added in v2.2.0
SemanticProjectIDs 返回勾选了语义检索的项目 ID(升序)。
func (*Store) SemanticPut ¶ added in v2.2.0
func (s *Store) SemanticPut(ctx context.Context, e model.EmbedEntry, chunks []model.EmbedChunk) error
SemanticPut 在一个事务里换掉一个条目的全部向量块并写入条目(chunks 可以为空,比如 skipped)。
func (*Store) SemanticScan ¶ added in v2.2.0
func (s *Store) SemanticScan(ctx context.Context, sig string, fn func(e model.EmbedEntry, chunks []model.EmbedChunk) error) error
SemanticScan 把某个签名下全部「ok」条目及其向量块按条目分页读出来交给 fn(用于加载内存索引)。 每页只取一小批条目与它们的块,页与页之间释放数据库连接(SQLite 只有一条连接,一次性游标会把整个 Hub 的读写都挡住); 内存占用与页大小成正比,而不是与向量库大小成正比。没有向量块的条目(异常残留)被跳过。
func (*Store) SemanticScopeFor ¶ added in v2.2.0
func (s *Store) SemanticScopeFor(ctx context.Context, q SearchQuery) (*SemanticScope, error)
SemanticScopeFor 解析范围:ProjectID 与 WorkflowID 都为空 = 全库(调用方必须自己确认调用者有全库权限)。
func (*Store) SemanticScopeUnion ¶ added in v2.2.0
SemanticScopeUnion 是若干已勾选项目的范围之并:流水线在外发前用它核对「这条内容此刻仍然属于某个已勾选的项目」(V2)。 没有项目(或项目都已不存在)时,范围什么都不放行。
func (*Store) SemanticStats ¶ added in v2.2.0
SemanticStats 统计向量库;sig 是当前签名(model|dims)。
设置页每隔几秒、全局搜索每次打开都会调它,所以不碰向量表本身的数据页:
- 块总数用 COUNT(*),SQLite 走覆盖索引(实测 10 万块约 1 ms);
- 体积不用 SUM(length(vec))(要扫全表,10 万块、约 140 MB 时实测约 80 ms,还会把系统页缓存冲掉), 改为按签名汇总条目表里的块数,再乘签名里的维度(int8 向量每块正好 dims 字节);条目表比向量表小两三个数量级。
func (*Store) SemanticTouchEntry ¶ added in v2.2.0
SemanticTouchEntry 只更新条目的版本戳与归属快照(源行变了、文本没变:不外发、向量原样保留)。 e.ChunkCap > 0 时一并记下「这个条目已经按这个单条上限处理过」(0 = 不动这一列): 补后半部分被服务拒绝时靠它避免每一轮对账都重试。
func (*Store) SemanticVisible ¶ added in v2.2.0
func (s *Store) SemanticVisible(ctx context.Context, scope *SemanticScope, cands []SemanticKey) (map[string]*SemanticText, error)
SemanticVisible 回源读取候选条目的最新原文,按真实归属再核一遍范围、过滤已归档,只返回现在仍然可见的。 结果按 searchRowKey 风格的键(Kind + "\x00" + Ref,见 SemanticKeyOf)索引。
func (*Store) SendFeedback ¶
func (*Store) SetAgentRunAuthority ¶
SetAgentRunAuthority 标记(或撤销)「这个对话正由 Hub 读非交互运行的输出判定状态」,直到 until: 期间 hook 的汇报只留记录、不改状态——运行输出里的事件是确定的,而 hook 在非交互模式下会漏报 stop、退出时还会报一个 sessionEnd。 until 为零值表示撤销。标记到期自动失效:监视协程没来得及收尾(进程崩了、主机失联)也不会永远挡住 hook。
func (*Store) SetAgentScreen ¶
func (s *Store) SetAgentScreen(workflowID string, in AgentScreenInput, now time.Time) AgentScreenChange
SetAgentScreen 登记一个工作流的最新屏幕信号。
func (*Store) SetAgentSearchAccess ¶ added in v2.2.0
func (s *Store) SetAgentSearchAccess(ctx context.Context, keyword, semantic *bool) (AgentSearchAccess, error)
SetAgentSearchAccess 局部更新开关:nil 表示这一项不动。返回更新后的完整值。
func (*Store) SetAgentSearchQuota ¶ added in v2.2.0
func (s *Store) SetAgentSearchQuota(ctx context.Context, p AgentSearchQuotaPatch) (AgentSearchQuota, error)
SetAgentSearchQuota 局部更新额度:先把改动合并到当前值上,再整体校验(范围 + 合计不小于单令牌),通过了才写,一项也不会写一半。 返回更新后的完整值;不合法返回 InvalidInput,库里不变。
func (*Store) SetDataDir ¶ added in v2.2.0
SetDataDir 改写数据目录(测试给内存库指定一个临时目录用)。
func (*Store) SetDefaultAuthProfile ¶
SetDefaultAuthProfile 把某一档设为默认(原来的默认档位随之变成普通档位,可以删除了)。
func (*Store) SetDiagBrowserReportsEnabled ¶ added in v2.2.0
SetDiagBrowserReportsEnabled 写「接收浏览器自报崩溃」开关。
func (*Store) SetGroupMemberPolicy ¶
func (s *Store) SetGroupMemberPolicy(ctx context.Context, groupID, memberRef, policy string, mutedUntil *time.Time, clearMute bool) error
SetGroupMemberPolicy 改成员的推送策略 / 免打扰截止时间(memberRef 可以是你自己)。
func (*Store) SetPageSearchViaIndex ¶ added in v2.2.0
SetPageSearchViaIndex 打开或关闭「页面搜索走全文索引」(持久化到设置,立即生效)。关掉后各页面立刻回退原来的搜索。
func (*Store) SetQueuedFeedbackHints ¶ added in v2.2.0
func (s *Store) SetQueuedFeedbackHints(ctx context.Context, queuedID uint, hints model.Hints, at time.Time) error
SetQueuedFeedbackHints 把算好的线索并入一条追加(同一条只留相似度高的那份,至多 MaxHintsMax 条)。 追加已经不在了(被清理)或已被撤回:线索无处可挂,静默返回。追加若已被并进某一轮的「秒回」(origin_ref = s:<会话编号>), 同时并入那一轮的回复线索——网页上看到的是那一轮的气泡。
func (*Store) SetSearchHintsConfig ¶ added in v2.2.0
func (s *Store) SetSearchHintsConfig(ctx context.Context, p SearchHintsPatch) (SearchHintsConfig, error)
SetSearchHintsConfig 局部更新:先把改动合并到当前值上,再整体校验,通过了才写,一项也不会写一半。 返回更新后的完整值;不合法返回 InvalidInput,库里不变。
func (*Store) SetSearchIndexEnabled ¶ added in v2.2.0
SetSearchIndexEnabled 打开或关闭全文索引(持久化到设置,立即生效)。 关闭只是停止维护与使用,索引数据保留;再打开时由后台对账补齐关闭期间的变化。 环境变量 RELAYMESH_SEARCH_INDEX=off 强制关闭时,打开会返回错误。
func (*Store) SetSemanticProjectIDs ¶ added in v2.2.0
func (s *Store) SetSemanticProjectIDs(ctx context.Context, ids []uint) (added, removed []uint, err error)
SetSemanticProjectIDs 把勾选的项目整体换成 ids(去重);每个 ID 都必须是存在的项目。返回新增与移除的 ID。
func (*Store) SetSessionReplyHints ¶ added in v2.2.0
func (s *Store) SetSessionReplyHints(ctx context.Context, sessionID string, hints model.Hints, at time.Time) error
SetSessionReplyHints 把算好的线索并入一轮会话的用户回复。这一轮没有回复(还在等用户答 / 回复被撤回了)或已经不在:静默返回。
func (*Store) SetSystemFlag ¶
SetSystemFlag 写入一个布尔系统开关。
func (*Store) SetTerminalArchived ¶
func (s *Store) SetTerminalArchived(ctx context.Context, keys []string, archived bool, now time.Time) (int64, error)
SetTerminalArchived 归档(archived=true)或取消归档一批条目,返回实际发生变化的条数: 重复归档、取消并未归档的条目都不算变化,所以界面上重复点击是安全的。
func (*Store) SetTerminalHostIdle ¶
func (s *Store) SetTerminalHostIdle(ctx context.Context, machineCode string, sec int) (changed bool, err error)
SetTerminalHostIdle 设置主机上会话的默认生命周期(秒,0 = 永久保持),返回是否有变化。
func (*Store) SetTerminalHostModel ¶
func (s *Store) SetTerminalHostModel(ctx context.Context, machineCode string, u HostModelUpdate) (host *model.TerminalHost, changed bool, err error)
SetTerminalHostModel 修改主机的模型访问设置,返回修改后的记录与是否有变化。
func (*Store) SetTerminalHostRecOff ¶
func (s *Store) SetTerminalHostRecOff(ctx context.Context, machineCode string, off bool) (changed bool, err error)
SetTerminalHostRecOff 设置主机的「关闭终端记录」策略,返回是否有变化。
func (*Store) SetTerminalHostRemark ¶
SetTerminalHostRemark 修改备注。
func (*Store) SetTerminalHostStatus ¶
func (s *Store) SetTerminalHostStatus(ctx context.Context, machineCode, status string) (changed bool, err error)
SetTerminalHostStatus 修改状态(enabled / disabled / blocked),返回是否真的发生了变化。
func (*Store) SetWaitPolicy ¶
func (s *Store) SetWaitPolicy(ctx context.Context, input model.SetWaitPolicyInput) (*model.MutationResult, error)
func (*Store) SetWorkflowHost ¶ added in v2.2.0
func (s *Store) SetWorkflowHost(ctx context.Context, req WorkflowHostRequest, apply bool) (*WorkflowHostResult, error)
SetWorkflowHost 设置或清除一个工作流的主机覆盖。
apply=false 只做预演:返回改前画像、将要改写的行数与项目归属的前后对比,不写任何数据。 apply=true 在单个事务里写覆盖并改写行,提交前校验结果(主机唯一为目标值、行数不变),任何一项不符就整体回滚。 改写用 UpdateColumns:保持 updated_at 不变,工作流不会「看起来刚刚活跃过」,最近活跃排序与「最近一次带目录的会话」都不受影响。
func (*Store) SetWorkflowPhase ¶
func (s *Store) SetWorkflowPhase(ctx context.Context, workflowID, phaseID string, isHumanClick bool) error
SetWorkflowPhase 设置工作流当前阶段。旧五段式的阶段 id(assess / verify / done)仍被接受, 落库前统一换成对应的新 id(见 model.CanonicalPhaseID)。
func (*Store) SetWorkflowPhaseConfig ¶
func (*Store) SettleEmbeddingTokens ¶ added in v2.2.0
func (s *Store) SettleEmbeddingTokens(ctx context.Context, day string, estimate, actual int64, failed bool) error
SettleEmbeddingTokens 用真实用量替换预留(见 embedding.Persistence)。
func (*Store) ShelvedAfterAnswer ¶ added in v2.1.0
func (s *Store) ShelvedAfterAnswer(ctx context.Context, workflowID string, now time.Time, limit int) (items []asyncmode.AnsweredTask, total int)
ShelvedAfterAnswer 返回 wf 名下「所挂确认卡已被答复、答复后没人动过、却还在暂缓」的任务(按任务编号升序,最多 limit 个), total 是总数。任务与确认卡的关联有两种:确认卡的 task_seq 指向该任务(计划卡),或任务的进展 / 引用里写了卡号 Q<N>。 一个任务挂着多张已答复的卡时,取最近答复的那一张。查询出错时返回空(提醒是软的,查不出来就不提醒)。
func (*Store) ShelvedUnexplained ¶ added in v2.1.0
func (s *Store) ShelvedUnexplained(ctx context.Context, workflowID string, now time.Time, limit int) (tasks []asyncmode.GateTask, total int)
ShelvedUnexplained 返回 wf 名下、最近 ShelveNagWindow 内置为暂缓、却没写明缘由的任务(按编号升序,最多 limit 个), total 是总数。查询出错时返回空(提醒是软的,查不出来就不提醒)。
func (*Store) SnapshotTo ¶
SnapshotTo 把整个数据库另存为一份一致性快照(VACUUM INTO),不阻塞读写;目标文件必须事先不存在。
func (*Store) SoftDeleteProjectDoc ¶
SoftDeleteProjectDoc 硬删(REST delete)。
func (*Store) StartSearchIndexer ¶ added in v2.2.0
StartSearchIndexer 启动后台索引协程:启动后回填 / 对账一次,之后处理脏集合并周期性对账。幂等。
func (*Store) StopSearchIndexer ¶ added in v2.2.0
func (s *Store) StopSearchIndexer()
StopSearchIndexer 停止后台协程并等它退出。幂等。
func (*Store) StreamAnswerDeliveries ¶
func (s *Store) StreamAnswerDeliveries(ctx context.Context, workflowID string, from, to time.Time) ([]model.QueuedFeedback, error)
StreamAnswerDeliveries 取一个时间窗里的确认项答复投递行(kind=answer、origin_ref 不为空), 聊天据此给「你的答复」消息标上已送达 / 已读 / 已处理。窗口取这一页答复的最早与最晚时间,前后各留 2 秒。
func (*Store) StreamAnswers ¶
func (s *Store) StreamAnswers(ctx context.Context, workflowID string, r StreamRange) ([]model.ConfirmItem, error)
StreamAnswers 取你对提问卡 / 计划卡的答复(已作答或已忽略)。
func (*Store) StreamCards ¶
func (s *Store) StreamCards(ctx context.Context, workflowID string, r StreamRange) ([]model.ConfirmItem, error)
StreamCards 取 Agent 的提问卡与计划确认卡(async_ask / 计划);文档决策卡另按文档汇总,见 StreamDecisionItems。
func (*Store) StreamDecisionItems ¶
func (s *Store) StreamDecisionItems(ctx context.Context, workflowID string) ([]model.ConfirmItem, error)
StreamDecisionItems 取一个工作流里全部文档决策项(最多 500 条,按创建时间升序):它们按文档汇总成卡, 汇总要看到同一文档的全部决策,所以不分页,交给 chat 包按边界裁剪。
func (*Store) StreamEndings ¶
func (s *Store) StreamEndings(ctx context.Context, workflowID string, r StreamRange) ([]model.FeedbackSession, error)
StreamEndings 取「等待超时 / 已取消」的汇报(聊天里显示成一行系统文字),时间是最后更新时间。
func (*Store) StreamEvents ¶
func (s *Store) StreamEvents(ctx context.Context, conversationID string, r StreamRange) ([]model.ConversationEvent, error)
StreamEvents 取会话时间线上的系统事件(Agent 收尾、模式切换…)。
func (*Store) StreamGroupMessages ¶
func (s *Store) StreamGroupMessages(ctx context.Context, groupID string, r StreamRange, vis *GroupVisibility, boundSeq int64, inclusive bool) ([]model.ChatMessage, error)
StreamGroupMessages 取群消息。排序键是(时间,序号);vis 不为空时只取可见范围内的。
翻页边界用序号(boundSeq,0 表示没有边界;Older 方向 inclusive 时包含它本身)而不是毫秒:群消息的序号与时间同序(见 PostGroupMessage), 按序号切边界是精确的,不会像按毫秒那样让「同一毫秒的几条」挤占一页的名额。r.Ms 对群无意义。
func (*Store) StreamInbox ¶
func (s *Store) StreamInbox(ctx context.Context, workflowID string, r StreamRange) ([]model.QueuedFeedback, error)
StreamInbox 取你随时追加的话(收件箱),状态由 DeriveState 推导。
func (*Store) StreamMergedInbox ¶
func (s *Store) StreamMergedInbox(ctx context.Context, workflowID string, sessionIDs []string) (map[string][]model.QueuedFeedback, error)
StreamMergedInbox 取被「秒回」并进指定几轮汇报的追加(origin_ref = s:<会话编号>),按被取走的先后排好。 聊天里它们各是一条独立的消息;那一轮的回复只剩合并之外的部分(见 chat.Builder.ReplyAfterMerge)。
func (*Store) StreamNotices ¶
func (s *Store) StreamNotices(ctx context.Context, workflowID string, r StreamRange) ([]model.FeedbackSession, error)
StreamNotices 取 Agent 的进度气泡(interactive_feedback wait:false 发布的 notice)。
func (*Store) StreamReplies ¶
func (s *Store) StreamReplies(ctx context.Context, workflowID string, r StreamRange) ([]model.FeedbackSession, error)
StreamReplies 取你对各轮汇报的回复(含秒回带走的追加)。时间见 replyTimeSQL。
func (*Store) StreamReports ¶
func (s *Store) StreamReports(ctx context.Context, workflowID string, r StreamRange) ([]model.FeedbackSession, error)
StreamReports 取 Agent 的阻塞式汇报(不含进度气泡)。不取你的回复与图片,免得白读大字段。
func (*Store) StreamRetractions ¶
func (s *Store) StreamRetractions(ctx context.Context, workflowID string, r StreamRange) ([]model.QueuedFeedback, error)
StreamRetractions 取你撤回的追加(聊天里显示成「你撤回了一条消息」,不带正文),时间是撤回的时刻。
func (*Store) StreamTaskUpdates ¶
func (s *Store) StreamTaskUpdates(ctx context.Context, workflowID string, since time.Time, r StreamRange) ([]WorkflowUpdate, error)
StreamTaskUpdates 取 Agent 写下的任务进展;since 非零时只要这个时刻之后的(用来对齐「开启异步之后」的口径)。
func (*Store) SubmitFeedback ¶
func (s *Store) SubmitFeedback(ctx context.Context, input SubmitFeedbackInput) (*model.FeedbackSession, error)
func (*Store) SupersedeOldCheckpoints ¶
func (*Store) SweepDraftImages ¶
SweepDraftImages 清理遗弃的草稿图片:最近一次写入早于 olderThan,并且所在工作流已保存的草稿不再引用它 (没有草稿记录也算不再引用)。这是客户端异常退出、草稿被另一台设备整体覆盖时的兜底,正常路径是客户端在草稿销毁时主动删除。
func (*Store) SwitchLauncherToContinue ¶ added in v2.1.0
func (s *Store) SwitchLauncherToContinue(ctx context.Context, id string) (TerminalLauncher, bool, error)
SwitchLauncherToContinue 把一条「新会话 + 运行成功后切到最近会话」的预设改成「最近会话」(#191,#559)。 它是「比较并交换」:在一个事务里读—判—写,只有预设还在、仍是非交互续聊、对话来源仍是 new 且 after_new 仍是 continue 时才改; 预设被删了、或者期间被人改过(来源 / 去向已经变了),就什么都不做——手动改动永远不被系统覆盖。 返回改完之后的预设;switched 表示这次是不是真的改了。
func (*Store) SyncDecisionConfirmItems ¶
func (s *Store) SyncDecisionConfirmItems(ctx context.Context, doc *model.ProjectDoc, body string) (bool, error)
SyncDecisionConfirmItems 在文档保存后,让「文档里的 decision 围栏」与「确认项」保持一致。返回是否改动了数据。
对每个决策 id,只看它最新的一条确认项(序号最大):
- 没有:新建待处理;
- 待处理:把展示字段(标题、说明、选项、默认值、风险……)更新成文档里的最新内容,原地保留序号;
- 已答复:选项没变就保留答复;选项变了(指纹不同)则旧答复作废(expired)并新建一条待处理——答案是针对旧选项给的,不能套到新选项上;
- 已忽略:选项没变就一直忽略,不会因为再次保存文档而「复活」;选项变了才新建;
- 已撤回 / 已过期:围栏回来了就重新新建一条。
文档里已经没有的围栏,其待处理项撤回;已答复 / 已忽略的历史保留。文档归档或删除时,待处理项全部撤回。 幂等:内容没变的重复保存不写库、不换序号。
func (*Store) SyncSearchIndex ¶ added in v2.2.0
SyncSearchIndex 在前台把索引整体追到最新:处理脏行并对账全部类型(测试、运维命令、查询前的强制同步用)。
func (*Store) SyncTerminalSessions ¶
func (s *Store) SyncTerminalSessions(ctx context.Context, machineCode string, seen []TerminalSessionSeen, now time.Time) (int, error)
SyncTerminalSessions 用一台主机当前的会话清单更新索引:新会话建行、已有会话刷新标签与录制索引、 已退出的会话记下结束;清单里不再有的运行中会话视为已结束(原因 gone,之后可被精确原因覆盖)。 返回写入(新建或更新)的行数。
func (*Store) TouchAgentIdentity ¶
TouchAgentIdentity 记下某个身份刚刚调用过 RelayMesh(以及是不是读类调用)。只更新身份的时间戳,不产生事件; 认不出项目目录就什么都不记。每个 MCP 调用都会走到这里,所以先查内存,写库按 agentIdentityWriteEvery 节流。
func (*Store) TouchCredentialUsage ¶
TouchCredentialUsage 记录令牌最近一次使用的时间与来源,不改动 updated_at。
func (*Store) TouchOAuthClient ¶
func (*Store) TouchTerminalHost ¶
func (s *Store) TouchTerminalHost(ctx context.Context, machineCode string, seen TerminalHostSeen) error
TouchTerminalHost 刷新主机的最近在线信息(握手成功后调用)。主机不存在时返回 ErrTerminalHostNotFound。
func (*Store) TrashGroup ¶ added in v2.2.0
func (s *Store) TrashGroup(ctx context.Context, in GroupTrashInput) (*GroupTrashResult, error)
TrashGroup 把一个已归档的群整个搬进回收站(见本文件开头的不变量)。
func (*Store) TrashWorkflow ¶ added in v2.2.0
func (s *Store) TrashWorkflow(ctx context.Context, in TrashInput) (*model.WorkflowTrash, error)
TrashWorkflow 把一条已归档的会话整个搬进回收站(见本文件开头的不变量)。返回的条目不含快照正文。
func (*Store) UnarchiveFeedbackSession ¶
func (*Store) UnlinkBranch ¶ added in v2.1.0
func (s *Store) UnlinkBranch(ctx context.Context, branchWorkflowID string, dryRun bool, by string) (*model.WorkflowBranch, error)
UnlinkBranch 解除一条关系(删行,不管状态);dryRun 时只返回将被删的那一行。关系不存在返回 NotFound。
func (*Store) UnlinkWorkItemSession ¶
UnlinkWorkItemSession 解除任务与会话的关联(不影响会话本身)。
func (*Store) UntoldBranchParamEvents ¶ added in v2.1.0
func (s *Store) UntoldBranchParamEvents(ctx context.Context, branch string) ([]model.BranchParamEvent, error)
UntoldBranchParamEvents 返回还没告诉分支的事件,旧的在前(回执的 params: 行据此生成,告知后用 MarkBranchParamEventsTold 标记)。
func (*Store) UpdateAuthProfile ¶
func (s *Store) UpdateAuthProfile(ctx context.Context, id uint, in AuthProfileInput) (*model.AuthProfile, error)
UpdateAuthProfile 修改一档(含默认档位):只改入参里给了的字段。
func (*Store) UpdateBranchPrefs ¶ added in v2.1.0
func (s *Store) UpdateBranchPrefs(ctx context.Context, mutate func(cur model.BranchPrefs) (model.BranchPrefs, error)) (model.BranchPrefs, error)
UpdateBranchPrefs 在一个事务里「读—改—写」:mutate 拿到当前偏好、返回新偏好(或返回错误拒绝这次修改)。 新偏好校验不过返回包装了 model.ErrInvalidBranchPrefs 的错误,库里保持原样。
func (*Store) UpdateBranchSettings ¶ added in v2.1.0
func (s *Store) UpdateBranchSettings(ctx context.Context, branchWorkflowID string, in UpdateBranchInput) (*model.WorkflowBranch, error)
UpdateBranchSettings 改开放范围 / 抄送开关(只有人能调;网页)。
func (*Store) UpdateBranchSettingsFull ¶ added in v2.1.0
func (s *Store) UpdateBranchSettingsFull(ctx context.Context, branchWorkflowID string, in UpdateBranchInput) (*model.WorkflowBranch, []model.ConfirmItem, error)
UpdateBranchSettingsFull 同 UpdateBranchSettings,并返回因此被立即转交给用户的请示: 「定夺」从开改成关时,原本路由给主会话、还没答的请示不能继续挂着(主会话已没有权限答),改由用户定夺(调用方据此发通知)。
func (*Store) UpdateCheckpointStatus ¶
func (*Store) UpdateCredential ¶
func (*Store) UpdateEmbeddingConfig ¶ added in v2.2.0
func (s *Store) UpdateEmbeddingConfig(ctx context.Context, mutate func(embedding.Config) embedding.Config, validate func(embedding.Config) error) (embedding.Config, error)
UpdateEmbeddingConfig 在一个事务里「读—改—写」:mutate 拿到当前配置、返回新配置; 新配置经 Normalize 与 validate 之后才写入,校验不过原样返回 validate 的错误(不写库)。
func (*Store) UpdateGroup ¶
func (s *Store) UpdateGroup(ctx context.Context, groupID string, in UpdateGroupInput) (*model.Conversation, error)
UpdateGroup 改群名 / 绑定项目 / 归档(归档后只读保留,可恢复)。
func (*Store) UpdateInboxConfig ¶
func (s *Store) UpdateInboxConfig(ctx context.Context, mutate func(cur InboxConfig) InboxConfig) (InboxConfig, error)
UpdateInboxConfig 在事务里读—改—写收件箱开关。
func (*Store) UpdateNote ¶
func (*Store) UpdateNotifyPrefs ¶
func (s *Store) UpdateNotifyPrefs(ctx context.Context, mutate func(cur notify.Prefs) (notify.Prefs, error)) (notify.Prefs, error)
UpdateNotifyPrefs 在一个事务里「读—改—写」:mutate 拿到当前偏好、返回新偏好(或返回错误拒绝这次修改)。 新偏好经 Normalize 与 Validate 之后才写入;校验不过返回包装了 notify.ErrInvalidPrefs 的错误,库里保持原样。
func (*Store) UpdateNtfyConfig ¶
func (s *Store) UpdateNtfyConfig(ctx context.Context, mutate func(cur ntfy.Config) ntfy.Config) (ntfy.Config, error)
UpdateNtfyConfig 在一个事务里「读—改—写」:mutate 拿到当前配置、返回新配置; 新配置经 Normalize 与校验后才写入,校验不过返回 ntfy.ErrInvalidConfig(不写库)。 启用时主题必填;关闭状态下允许保存只填了一半的配置。
func (*Store) UpdateOAuthGrantCredential ¶
func (*Store) UpdateOAuthGrantRefreshMeta ¶
func (*Store) UpdateProject ¶
func (*Store) UpdateProjectDoc ¶
func (s *Store) UpdateProjectDoc(ctx context.Context, docID uint, patch ProjectDocPatch, actor DocActor) (*ProjectDocSaveResult, error)
UpdateProjectDoc 更新文档(expected_rev 冲突返回 ErrConflict)。
func (*Store) UpdateSSHConn ¶
UpdateSSHConn 更新 SSH 主机的连接信息;记录不存在或不是 SSH 主机时返回 ErrTerminalHostNotFound。
func (*Store) UpdateSemanticRun ¶ added in v2.2.0
func (s *Store) UpdateSemanticRun(ctx context.Context, mutate func(SemanticRun) SemanticRun, validate func(SemanticRun) error) (SemanticRun, error)
UpdateSemanticRun 在一个事务里「读—改—写」;mutate 返回的新值经类型规整后写入,validate 不通过就不写。
func (*Store) UpdateSessionMaxChecks ¶
func (*Store) UpdateSessionPromptWait ¶
func (*Store) UpdateSessionWaitCountdown ¶
func (*Store) UpdateSessionWaitCountdownSeconds ¶
func (s *Store) UpdateSessionWaitCountdownSeconds(ctx context.Context, idOrWorkflow string, seconds int) (*model.FeedbackSession, error)
UpdateSessionWaitCountdownSeconds 按秒设置挂起倒计时(秒回 0 / 30 / 60 …)。 同步写入分钟列(向上取整),旧界面和旧二进制读到的仍然是一个合理的值。
func (*Store) UpdateStages ¶
func (s *Store) UpdateStages(ctx context.Context, input model.UpdateStagesInput) (*model.MutationResult, error)
func (*Store) UpdateTask ¶
func (s *Store) UpdateTask(ctx context.Context, input model.UpdateTaskInput) (*model.MutationResult, error)
func (*Store) UpdateTaskHeartbeat ¶
func (*Store) UpdateTerminalGuardState ¶
func (s *Store) UpdateTerminalGuardState(ctx context.Context, now time.Time, mutate func(*GuardStateDoc)) (GuardStateDoc, error)
UpdateTerminalGuardState 在一个事务里「读—改—写」预设运行状态,并清理过期记录;返回写入后的文档。
func (*Store) UpdateTerminalPrefs ¶
func (s *Store) UpdateTerminalPrefs(ctx context.Context, mutate func(*TerminalPrefs)) (TerminalPrefs, error)
UpdateTerminalPrefs 在一个事务里「读—改—写」终端偏好,避免两个设置项同时保存时互相覆盖。 mutate 只改自己关心的字段;改完的结果必须通过 Validate,否则不写入并返回 ErrInvalidTerminalPrefs。
func (*Store) UpdateTerminalRun ¶
func (s *Store) UpdateTerminalRun(ctx context.Context, runID string, fields map[string]any) (bool, error)
UpdateTerminalRun 无条件更新一条运行记录的指定字段,返回是否命中了记录。
func (*Store) UpdateTerminalRunIf ¶
func (s *Store) UpdateTerminalRunIf(ctx context.Context, runID string, fromStates []string, fields map[string]any) (bool, error)
UpdateTerminalRunIf 只有当记录当前处于 fromStates 之一时才更新,返回是否生效。 终态不会被反向覆盖:服务端据此保证「一次运行只会有一个终态」。
func (*Store) UpdateUserNorm ¶
func (*Store) UpdateWorkItem ¶
func (s *Store) UpdateWorkItem(ctx context.Context, id uint, patch WorkItemPatch, actor WorkActor) (*WorkItemResult, error)
UpdateWorkItem 更新任务。没有任何变化时不写库,Changed 为 false。
func (*Store) UpdateWorkModule ¶
func (s *Store) UpdateWorkModule(ctx context.Context, id uint, patch WorkModulePatch) (*model.WorkModule, error)
UpdateWorkModule 修改模块的名称或说明(不动位置与归属)。
func (*Store) UpdateWorkflowMode ¶
func (s *Store) UpdateWorkflowMode(ctx context.Context, workflowID string, patch ModePatch, now time.Time) (ModeInfo, error)
UpdateWorkflowMode 开关异步对话 / 选档位。
开启不再要求先见过 hook(#271):用户可以提前开着。没见过 hook、或 hook 已过期时,有效模式(asyncmode.Evaluate) 一律是同步,原因记作 no_hook / hook_stale,回执里写「已开启但暂未生效」;hook 一出现就自动转成异步, 不需要再操作一次。关闭永远允许,关掉之后与从没开过时的行为一致。
func (*Store) UpsertProjectModule ¶
func (s *Store) UpsertProjectModule(ctx context.Context, projectID uint, in ModuleInput) (*model.ProjectModule, error)
UpsertProjectModule 按路径创建或修改模块。父级模块不存在会一并补建(标题取路径末段),保证树是连通的。
func (*Store) UpsertTerminalLauncher ¶
func (s *Store) UpsertTerminalLauncher(ctx context.Context, l TerminalLauncher) ([]TerminalLauncher, bool, error)
UpsertTerminalLauncher 新增一条预设,或按编号覆盖已有的那一条;返回保存后的全部预设,以及这次是不是新增。 名字不能与别的预设重名;新增时数量不能超过上限(覆盖已有的不受限)。
func (*Store) WithdrawConfirmItem ¶
func (s *Store) WithdrawConfirmItem(ctx context.Context, workflowID, ref string, agentOnly bool) (*model.ConfirmItem, error)
WithdrawConfirmItem 撤回一条待处理的确认项(智能体撤回自己提的问题)。 agentOnly=true 时只能撤回智能体创建的:文档决策卡由文档内容决定,智能体不能绕过文档去撤销。
func (*Store) WithdrawDocPendingConfirms ¶
WithdrawDocPendingConfirms 文档归档 / 删除时,撤回它所有待处理的决策项。
func (*Store) WorkDigestFor ¶
WorkDigestFor 汇总工作流所在任务板的概况:各状态数量、规划节点数与最近更新的未结束任务。 同一个项目的工作流共用一张板,所以概况是整张板的;单工作流的板与按工作流统计完全一致。
func (*Store) WorkModuleScope ¶
WorkModuleScope 返回一个模块及其下属功能的 ID(任务列表按模块筛选时包含功能里的任务)。
func (*Store) WorkflowBinding ¶
WorkflowBinding 返回工作流上记录的主机与项目目录(最近一个带目录的反馈会话的);没有记录就是两个空串。 网页新建的占位行没有目录,不算数;智能体自己的汇报才带主机与目录。
func (*Store) WorkflowBindingOf ¶
WorkflowBindingOf 返回一个工作流当前的绑定画像;工作流不存在时返回 NotFound。
func (*Store) WorkflowBoundDirectory ¶
WorkflowBoundDirectory 返回这个工作流此刻被绑定的项目目录,口径与汇报路径上的 D-161 所有权校验完全一致: 取这个工作流里 id 最小的那一行,目录去首尾空白后用 filepath.Clean 规整;没有会话行、那一行没有目录、 或规整后是 "." 时返回空串(= 没有绑定,智能体第一次汇报带什么目录都行)。 「启用 Agent」据此提前告诉用户:在主机上选的运行目录与绑定的目录不一致时,智能体的第一次汇报会被拒绝。
func (*Store) WorkflowGate ¶ added in v2.1.0
WorkflowGate 读取某个会话的收尾门状态。没有模式行(从未开启过异步)时全为零值:没有门可言。
func (*Store) WorkflowHostInfoOf ¶ added in v2.2.0
func (s *Store) WorkflowHostInfoOf(ctx context.Context, workflowID string) (*WorkflowHostInfo, error)
WorkflowHostInfoOf 读一个工作流当前的主机画像;工作流不存在返回 NotFound。
func (*Store) WorkflowHostOverride ¶ added in v2.2.0
WorkflowHostOverride 返回一个工作流的主机覆盖;没有设置返回空串。
func (*Store) WorkflowIdentityID ¶
WorkflowIdentityID 是工作流绑定的身份:先看对话会话(agent_sessions),再按最近一次汇报会话的目录找身份。认不出返回 0。
type StreamRange ¶
type StreamRange struct {
Dir StreamDir
// Ms 是边界的 Unix 毫秒;0 表示没有边界。Older 包含这一毫秒(由调用方按完整排序键再裁掉边界之外的),Newer 同理。
Ms int64
// Limit 是每个来源最多取多少条。调用方传「页大小 + 1」:多出来的一条用来判断还有没有更多。
Limit int
// Query 是子串搜索词;空表示不搜。
Query string
}
StreamRange 约束一次取流。
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"`
}
type TerminalHostSeen ¶
type TerminalHostSeen struct {
Hostname string
OS string
Arch string
AgentVersion string
AgentRev string
Privilege string
IP string
At time.Time
}
TerminalHostSeen 是每次握手成功后要刷新的「自报且已净化」字段。
type TerminalLauncher ¶
type TerminalLauncher struct {
// ID 由界面生成,保存后不变;增删改都按它定位,所以两个浏览器同时改不同的预设不会互相覆盖。
ID string `json:"id"`
// Name 同时是新建会话的名字:启动器靠「主机 + 名字」认出这个预设已经在运行的会话(见前端 lib/terminal/launcher.ts),
// 所以预设之间不能重名。
Name string `json:"name"`
// Host 是目标主机的机器码。
Host string `json:"host"`
// Dir 是会话启动时所在的目录;留空表示主机的默认目录。
Dir string `json:"dir,omitempty"`
// Command 是会话就绪后自动输入并回车的命令;留空表示只打开一个终端。它是一整行,不含换行与控制字符。
Command string `json:"command,omitempty"`
// Guard 是可选的「会话守护」:监测这个预设启动的智能体会话有没有意外退出或停摆,并给出一键唤醒。
// nil 表示没配置过(旧存档都是这种)。旧版本读到带 guard 的存档会忽略它——回滚后守护配置会丢,预设本身不受影响。
Guard *LauncherGuard `json:"guard,omitempty"`
// Kind 是预设类型:空串(默认,旧存档都是这种)= 开终端;LauncherKindHeadless = 非交互续聊(见 HeadlessRun)。
// 旧版本读到非交互续聊预设,会把它当成一个没有命令的终端预设——回滚后这种预设的运行配置会丢,其余预设不受影响。
Kind string `json:"kind,omitempty"`
// Run 是非交互续聊的运行配置,只在 Kind == LauncherKindHeadless 时有。
Run *HeadlessRun `json:"run,omitempty"`
}
TerminalLauncher 是一条启动预设。
func (TerminalLauncher) IsHeadless ¶
func (l TerminalLauncher) IsHeadless() bool
IsHeadless 表示这是一条「非交互续聊」预设。
func (TerminalLauncher) Normalize ¶
func (l TerminalLauncher) Normalize() TerminalLauncher
Normalize 规整各字段:名字是单行文本,各种空白(含换行、制表)折叠成一个普通空格;其余字段只去掉首尾空白。 命令里的空白(含中间的空格)一律保持原样。
func (TerminalLauncher) Validate ¶
func (l TerminalLauncher) Validate() error
Validate 检查一条(已规整的)预设;错误信息面向用户,并带上出问题的字段。
type TerminalPrefs ¶
type TerminalPrefs struct {
// FixedCols 大于 0 时开启「宽度保持」:每个会话的终端都固定为这个列数,浏览器窗口再窄也不改变,
// 窗口放不下就缩小字号去适配;0 表示关闭,终端宽度跟随浏览器窗口(默认)。
FixedCols int `json:"fixed_cols"`
// RecordMaxLines 大于 0 时开启「终端限高」:每个会话在主机上的记录至少保留最近这么多行输出,
// 更早的内容按分段滚动丢弃;0 表示不按行数限制(默认,仍受字节配额约束)。
RecordMaxLines int `json:"record_max_lines"`
// AgentAutoUpgrade 是 Hub 的「Agent 自动升级」总闸(默认关):关着时,Hub 对主机 Agent 的版本检查一律回答「不提供」,
// 即使某台主机的所有者已经在本机开启了自动升级。打开它并不会让任何主机自动升级——每台主机仍需要它的所有者在本机同意。
AgentAutoUpgrade bool `json:"agent_auto_upgrade"`
}
TerminalPrefs 是终端的服务端偏好:保存在 Hub 里,所有浏览器共享,换设备查看时保持一致。
type TerminalSessionEnd ¶
type TerminalSessionEnd struct {
SID string
Name string
StartedAt int64
EndedAt time.Time // 零值表示「现在」
Reason string
}
TerminalSessionEnd 描述一个会话已经结束及原因。会话不在索引里时按这里的信息补建一行 (例如主机重启后守护进程报告的「已丢失会话」:它们的记录仍在主机磁盘上,值得保留入口)。
type TerminalSessionSeen ¶
type TerminalSessionSeen struct {
SID string
Name string
Shell string
StartedAt int64
Exited bool
ExitCode *int
Rec string
RecBytes int64
RecFirst int64
RecLast int64
RecGap bool
}
TerminalSessionSeen 是 Agent 报告的一个会话的快照(字段均已净化)。 只含标签与录制索引,不含任何终端内容。
type ThreadFilter ¶
ThreadFilter 是线程汇总的过滤条件。
type ThreadStat ¶
type ThreadStat struct {
ThreadKey string `json:"thread_key"`
Total int64 `json:"total"`
Active int64 `json:"active"`
Awaiting int64 `json:"awaiting"`
FirstID uint `json:"first_id"`
LastID uint `json:"last_id"`
}
ThreadStat 是一个线程(线程键)的汇总:运行总数、进行中与待批准的数量,以及首末两条运行的主键。
type TrashInput ¶ added in v2.2.0
type TrashInput struct {
WorkflowID string
// ConfirmName 是用户手动输入的会话名;必须与 PreviewWorkflowTrash 给出的 ConfirmName 一致。
ConfirmName string
// Now 留空取当前时间(测试用来固定时间)。
Now time.Time
}
TrashInput 是移进回收站的参数。
type TrashPreview ¶ added in v2.2.0
type TrashPreview struct {
WorkflowID string `json:"workflow_id"`
// ConfirmName 是确认框要求手动输入的名字(自定义名 > 最近一轮的标题 > 工作流编号);服务端删除时按它核对。
ConfirmName string `json:"confirm_name"`
Rounds int `json:"rounds"`
Queued int `json:"queued"`
Images int `json:"images"`
// Bytes 是这条会话正文与截图的大致体积(原始文本长度之和,只是估计)。
Bytes int64 `json:"bytes"`
// Blockers 非空表示现在不能删,每条都是写给人看的原因与解决办法。
Blockers []string `json:"blockers"`
RetentionDays int `json:"retention_days"`
}
TrashPreview 是「删除这条会话会发生什么」:确认框据此展示范围与拦截原因。
type TrashRestoreResult ¶ added in v2.2.0
type TrashRestoreResult struct {
WorkflowID string `json:"workflow_id"`
Title string `json:"title"`
Rounds int `json:"rounds"`
Queued int `json:"queued"`
// Merged 为真表示恢复时这个工作流编号已经有新的会话了(例如删除之后智能体又用同一个编号开了新会话):
// 老轮次按原来的时间并回去;已有的阶段状态、草稿、会话名一律保留(不被快照覆盖)。
Merged bool `json:"merged"`
}
TrashRestoreResult 是恢复的结果。
type UpdateBranchInput ¶ added in v2.1.0
type UpdateBranchInput struct {
Preset string
Expose *model.BranchExpose
CopyUserNotes *bool
}
UpdateBranchInput 是改分支设置的入参:预设与显式取值二选一;CopyUserNotes 可单独改。
type UpdateGroupInput ¶
UpdateGroupInput 是改群设置的入参,nil 表示不改。
type UserHints ¶ added in v2.2.0
type UserHints struct {
Hints model.Hints
HintsAt *time.Time
// MessageAt 是这条消息发出的时间(回复取 responded_at,没有就取会话创建时间;追加取创建时间)。
MessageAt time.Time
}
UserHints 是一条用户消息上的线索,连同它是什么时候发出的。
type WakeInput ¶ added in v2.1.0
type WakeInput struct {
Kind sessionprompt.Kind
// WorkflowID 可空(预设没配工作流):为空时不算「现状」变量,默认模板也换成不点名工作流的写法。
WorkflowID string
// PresetBody 是预设自己写的正文(空 = 没写);它排在所有分层的最前面,原样沿用升级前的变量语义。
PresetBody string
// Draft 非空时直接用它当模板(预览界面上还没保存的草稿),不走分层选用;层标成 draft。
Draft *string
// Base 是调用方已知的变量:目录 / 主机(预设里的)、运行时间提醒。Workflow 与「现状」由这里补齐,不必填。
Base sessionprompt.Vars
Now time.Time
}
WakeInput 是渲染一条唤醒词要的输入。
type WakeResult ¶ added in v2.1.0
type WakeResult struct {
Text string
Layer WakeLayer
Template string // 用到的模板原文(未渲染),预览用
Vars sessionprompt.Vars
}
WakeResult 是渲染结果。
type WakeTemplates ¶ added in v2.1.0
type WakeTemplates struct {
Resume string `json:"resume,omitempty"`
New string `json:"new,omitempty"`
WebStart string `json:"webStart,omitempty"`
}
WakeTemplates 是全局设置里的唤醒词模板覆盖(settings.wakeTemplates);空串 = 没覆盖。
func ValidateWakeTemplates ¶ added in v2.1.0
func ValidateWakeTemplates(in WakeTemplates) (WakeTemplates, error)
ValidateWakeTemplates 检查要保存的全局覆盖(规则见 NormalizeWakeTemplate)。返回规整后的值。
func (WakeTemplates) For ¶ added in v2.1.0
func (w WakeTemplates) For(kind sessionprompt.Kind) string
For 返回某类唤醒词的全局覆盖。
type WorkActor ¶
type WorkActor struct {
Kind string // model.WorkActorHuman 或 model.WorkActorAgent
SessionID string // 可选
// 以下三项只对智能体有意义(#175 B2,见 work_assign.go):人在 Web 上写入恒不做任务级判定。
WorkflowID string // 智能体自己的工作流(MCP 的 workflow_id);用来判定「是不是自己的任务」,也记在时间线上
Manager bool // 持有该项目任务板的管理授权(由 MCP 层按授权表判定后填入)
Policy WorkPolicy // 任务级权限策略;零值 = 不检查
// Branches 是这个操作者作为主会话与各个分支的关系(键 = 分支工作流编号;#236 P5,规则见 work_assign.go 的 branchMayAssign)。
// 与 Manager 一样由 MCP 层在进入 store 之前现查后填入(事务里不能回头查库);空 = 没有分支,判定与升级前逐字一致。
Branches map[string]WorkBranchScope
// InheritedFrom 非空 = 这个操作者是主会话任务板上的「客人」(#284,见 BoardGuestOf):沿用主会话任务板的分支,或关系结束后任务仍留在主会话板上的分支。
// 值是主会话的工作流编号。它在这张板上对别人建的任务强制只读(只能新建自己的、接手指派给它的),与项目的访问控制开没开无关。
// 由 MCP 层现查后填入、同时把 Policy 抬到强制档;store 只用它在拒绝文案里把原因说清楚。
InheritedFrom string
// InheritedEnded 说明 InheritedFrom 那条分支关系已经结束(只影响拒绝文案:结束的分支不会再被派单)。
InheritedEnded bool
}
WorkActor 描述一次写入是谁做的、发生在哪个会话里。
type WorkBranchScope ¶ added in v2.1.0
type WorkBranchScope struct {
Active bool // 关系还在(没有被结束)
Assign bool // 关系还在,且分支的开放范围里「任务」= 派单(model.ExposeTasksAssign)
}
WorkBranchScope 是一个主会话与它的某个分支在任务派单上的关系(#236 P5),由入口层现查后放进 WorkActor.Branches。
type WorkDigest ¶
type WorkDigest struct {
Counts map[string]int
Total int
Modules int
// Unassigned 是还没有归入任何模块的未结束任务数(只数叶子任务,与模块汇总的口径一致)。
Unassigned int
// Latest 是最近更新的未结束任务(没有时为 nil)。
Latest *model.WorkItem
}
WorkDigest 是工作流任务清单的一句话概况,供回执头与概览使用。
type WorkItemFilter ¶
type WorkItemFilter struct {
WorkflowID string
States []string
Kinds []string
Stages []string // 阶段;包含空串或 "none" 表示「未标注」
SessionID string // 非空:只要与这个会话关联的任务,并附上这个会话对每条任务做了什么(SessionCtx)
Query string
ParentID *uint
TopLevel bool // 只要顶层任务(没有父任务的)
ModuleID uint // >0:只要这个模块(含它下面各功能)里的任务
Unassigned bool // 只要未归类的任务(优先于 ModuleID)
ClosedDays int // >0:已关闭的任务只保留最近 N 天内关闭的
Limit int // 0 = 默认 500
// Assignee:工作流编号 = 只要指派给它的任务;"none" = 只要没有指派的任务;空 = 不过滤(#175 B2)。
Assignee string
// AssignedBy:只要这个工作流派出的任务(空 = 不过滤)。
AssignedBy string
}
WorkItemFilter 是列表的筛选条件。
type WorkItemInput ¶
type WorkItemInput struct {
WorkflowID string
Title string
Kind string // 空 = feature
Stage string // 空 = 未标注
State string // 空 = todo
Labels []string
Refs []string
// Description 是任务内容的说明(这件事是什么、做到什么算完成);标题和进度都说不清时靠它。
Description string
Progress string
Note string
ParentID uint // 0 = 没有父任务
ModuleID uint // 0 = 未归类
Percent *int // nil = 由状态 / 子任务推导;0–100 = 显式完成度
// Assignee 非空 = 创建时同时指派给这个工作流(管理 Agent / 人;必须是同一张项目板上的工作流)。
Assignee string
}
WorkItemInput 是新建任务的参数。
type WorkItemPatch ¶
type WorkItemPatch struct {
Title *string
Kind *string
Stage *string // 指向空串 = 清除(回到未标注)
State *string
Labels *[]string
Refs *[]string
// Description 指向空串 = 清除;只改描述不动 updated_at、不写时间线(见 model.WorkItem.Description)。
Description *string
Progress *string
Conclusion *string
ParentID *uint // 指向 0 表示解除父任务
ModuleID *uint // 指向 0 表示取消归类
Percent *int // -1 表示清除显式完成度(回到由状态推导)
Note string
// Assignee 指向工作流编号 = 指派 / 改派;指向空串 = 撤销指派;nil = 不变(#175 B2)。
Assignee *string
// Claim 是显式的协作动作:accept / decline / deliver / accept_delivery / reject_delivery;空 = 无。
// 与 Assignee 不能同时给。承接者直接改状态也能隐式表达接取 / 交付,见 work_assign.go。
Claim string
}
WorkItemPatch 是更新任务的参数:指针为 nil 的字段保持不变。
type WorkItemResult ¶
type WorkItemResult struct {
Item *model.WorkItem
// Changed 为 false 表示这次调用没有产生任何变化(没有写库)。
Changed bool
// SessionLinked 表示本次传入的会话已与任务关联(会话不存在时为 false)。
SessionLinked bool
// Violations 只在策略为 audit 时有值:这次写入照常执行了,但若启用强制会被拒绝,每条是一句原因,
// 调用层据此写审计(would_deny)。
Violations []string
// BoardLine 非空表示这次写入产生了一个值得告诉群里的协作事件(派活 / 改派 / 交付 / 拒绝 / 退回 / 验收,
// 且派发者与承接者都是工作流);调用层收集后交给 PostBoardGroupLines 写群里的系统行(#180 B3c)。
BoardLine *BoardLineEvent `json:"-"`
}
WorkItemResult 是一次写入的结果。
type WorkModuleDeleteResult ¶
type WorkModuleDeleteResult struct {
Module model.WorkModule `json:"module"`
MovedTasks int `json:"moved_tasks"`
RemovedFeatures int `json:"removed_features"`
}
WorkModuleDeleteResult 是删除模块的结果。
type WorkModuleList ¶
type WorkModuleList struct {
Modules []model.WorkModule `json:"modules"`
Unassigned model.WorkModuleStats `json:"unassigned"`
}
WorkModuleList 是一个工作流的规划树(按树的顺序拍平)与「未归类」的任务汇总。
type WorkModulePatch ¶
WorkModulePatch 是修改模块的参数:指针为 nil 的字段保持不变。
type WorkPlanNode ¶
type WorkPlanNode struct {
Name string
Description *string // nil = 不改说明
Rename string // 非空 = 把 Name 改成它
Remove bool // 移除这个节点(必须没有任务也没有剩余的功能)
Features []WorkPlanNode
}
WorkPlanNode 是一次「规划」调用里的一个节点(模块或功能)。
type WorkPlanResult ¶
type WorkPlanResult struct {
Created []string `json:"created,omitempty"`
Renamed []string `json:"renamed,omitempty"`
Updated []string `json:"updated,omitempty"`
Removed []string `json:"removed,omitempty"`
Unchanged int `json:"unchanged,omitempty"`
// Reordered 表示 reorder=true 时同级顺序确实发生了变化。
Reordered bool `json:"reordered,omitempty"`
}
WorkPlanResult 是规划调用的结果摘要(节点都用完整路径表示)。
func (*WorkPlanResult) Changed ¶
func (r *WorkPlanResult) Changed() bool
Changed 表示这次规划是否真的改动了规划树(新建 / 改名 / 改说明 / 移除 / 顺序变化)。
type WorkPolicy ¶
type WorkPolicy int
WorkPolicy 是任务级权限的策略档位,零值 = 不检查。
const ( WorkPolicyOff WorkPolicy = iota // 不检查:人在 Web 上、项目没开访问控制、独立板 WorkPolicyAudit // 违规照常执行,原因记进 WorkItemResult.Violations 交给调用层记审计 WorkPolicyEnforce // 违规直接拒绝 )
type WorkSearchFacets ¶ added in v2.2.0
WorkSearchFacets 是检索结果的分面数量。States 的口径与任务页现有的状态按钮一致:受类型筛选影响、不受状态筛选影响,五个状态都有(没有就是 0)。
type WorkSearchHit ¶ added in v2.2.0
type WorkSearchHit struct {
Item model.WorkItem `json:"item"`
// Snippet / SnippetField:第一个带命中词的栏里取出的片段,以及它来自哪一栏;只有标题命中时为空。
Snippet string `json:"snippet,omitempty"`
SnippetField string `json:"snippet_field,omitempty"`
// TitleMatch:标题就满足了全部检索词(或标题含整个检索词)。SeqMatch:检索词就是这条任务的编号(#12 / 12)。
TitleMatch bool `json:"title_match,omitempty"`
SeqMatch bool `json:"seq_match,omitempty"`
}
WorkSearchHit 是一条命中:完整的任务,加上命中片段与命中方式。
type WorkSearchQuery ¶ added in v2.2.0
type WorkSearchQuery struct {
WorkflowID string // 所在的任务板由它解析;空 = 全部任务板
Q string // 检索词(必填)
States []string // 只要这些状态;空 = 全部
Kinds []string // 只要这些类型;空 = 全部
Limit int // 一页多少条:默认 50,上限 100
Offset int // 跳过前多少条
}
WorkSearchQuery 是任务页检索的请求。
type WorkSearchResult ¶ added in v2.2.0
type WorkSearchResult struct {
Hits []WorkSearchHit `json:"hits"`
// Total 是按状态 / 类型筛选之后的命中总数;ScopeTotal 是这张任务板(或全部任务板)一共有多少个任务。
Total int `json:"total"`
ScopeTotal int `json:"scope_total"`
Facets WorkSearchFacets `json:"facets"`
// Terms 是归一后的检索词(界面高亮用)。
Terms []string `json:"terms"`
// Search 说明这次是走索引(index)还是回退成整串子串(legacy),以及回退的原因。
Search PageSearchInfo `json:"search"`
// NextOffset 在还有更多命中时给出下一页的偏移,没有更多时省略。
NextOffset *int `json:"next_offset,omitempty"`
}
WorkSearchResult 是一页检索结果。
type WorkflowBinding ¶
type WorkflowBinding struct {
WorkflowID string `json:"workflow_id"`
Dirs []string `json:"dirs"` // 名下出现过的不同 project_directory,正常只有一个
Hosts []string `json:"hosts"` // 名下出现过的不同 host_name(空值不计)
Sessions int64 `json:"sessions"` // feedback_sessions 行数
Pending int64 `json:"pending"` // 其中仍在等待用户回复的
Queued int64 `json:"queued"` // queued_feedbacks 行数
}
WorkflowBinding 是一个工作流当前绑定的「项目目录 + 主机」画像。
type WorkflowBrief ¶
WorkflowBrief 是一个有过交互的工作流的概况(建群时的候选来源之一)。
type WorkflowHostInfo ¶ added in v2.2.0
type WorkflowHostInfo struct {
WorkflowID string `json:"workflow_id"`
// Host 是最近一轮会话的主机(侧栏与会话头部显示的就是它);Override 是用户设的覆盖(空 = 没有)。
Host string `json:"host"`
Override string `json:"override"`
// CredentialName / CredentialHost 是最近一轮会话所用凭据及其绑定的主机(没用凭据或没绑主机则为空);GlobalHost 是设置里的全局主机名。
// 它们是覆盖被清除之后,下一轮汇报会重新参与计算的来源。
CredentialName string `json:"credential_name,omitempty"`
CredentialHost string `json:"credential_host,omitempty"`
GlobalHost string `json:"global_host,omitempty"`
ProjectDir string `json:"project_dir,omitempty"`
Project *WorkflowProjectRef `json:"project"`
}
WorkflowHostInfo 是主机编辑对话框要看的当前状态:只给事实,不做「来源」推断。
type WorkflowHostRequest ¶ added in v2.2.0
WorkflowHostRequest 描述一次主机覆盖的改动:HostName 为空表示「清除覆盖,回到自动」。
type WorkflowHostResult ¶ added in v2.2.0
type WorkflowHostResult struct {
WorkflowID string `json:"workflow_id"`
Op string `json:"op"` // set | clear
// FromHost 是改前最近一轮会话的主机;FromOverride 是改前已有的覆盖(空 = 没有);ToHost 是改后的覆盖(clear 时为空)。
FromHost string `json:"from_host"`
FromOverride string `json:"from_override"`
ToHost string `json:"to_host"`
// SessionsToMove / QueuedToMove 是需要改写(预演)或已改写(执行)的行数;Pending 是仍在等用户回复的轮次(只提示,不影响改动)。
SessionsToMove int64 `json:"sessions_to_move"`
QueuedToMove int64 `json:"queued_to_move"`
Pending int64 `json:"pending"`
// ProjectDir 是工作流最近一次带目录的汇报所在的目录(空 = 没有目录,也就谈不上项目归属)。
// 项目成员按(主机,目录)认:主机变了,工作流可能移出原来的项目、或加入另一个项目——预览里把改前改后摆出来。
// ProjectAfterKnown 为 false(清除覆盖)时,改后归属取决于下一轮汇报按原来的链算出的主机,现在算不出来。
ProjectDir string `json:"project_dir,omitempty"`
ProjectBefore *WorkflowProjectRef `json:"project_before"`
ProjectAfter *WorkflowProjectRef `json:"project_after"`
ProjectAfterKnown bool `json:"project_after_known"`
// Noop 表示改不改都一样(已经是这个覆盖、行也都是这个主机,或清除一个本来就没有的覆盖)。
Noop bool `json:"noop"`
Applied bool `json:"applied"`
}
WorkflowHostResult 是一次改动(或预演)的结果。
type WorkflowProjectRef ¶ added in v2.2.0
WorkflowProjectRef 是工作流所属项目的简要引用(预览里对比改前改后)。
type WorkflowStat ¶
type WorkflowStat struct {
WorkflowID string `json:"workflow_id"`
BoardKey string `json:"board_key,omitempty"`
Members []string `json:"workflows,omitempty"`
// BoardName 是项目板所属项目的名称,只在多个工作流共用这张板时才带(界面给共享板起名用);
// 独立板与只有一个工作流的板省略,界面照旧用会话标题 / 工作流编号。
BoardName string `json:"board_name,omitempty"`
Total int `json:"total"`
Active int `json:"active"`
// Doing / Review 是会话页头「任务」入口上的计数:进行中的数量,以及验证中的数量(都是智能体手上的活,不需要用户处理)。
Doing int `json:"doing"`
Review int `json:"review"`
UpdatedAt time.Time `json:"updated_at"`
}
WorkflowStat 是某个工作流下任务的概况,供界面做工作流筛选。
同一个项目的工作流共用一张任务板(#175):每个有任务的工作流各占一条,数字是整张板的; BoardKey / Members 说明它在哪张板、板上有哪些工作流(只有一个时省略),界面可据此去重。
type WorkflowUpdate ¶
type WorkflowUpdate struct {
ID uint `json:"id"`
// Seq / Title / State 是任务本身的序号、标题与当前状态(State 不是这次更新当时的状态,当时的在 ToState)。
Seq int `json:"seq"`
Title string `json:"title"`
State string `json:"state"`
// FromState / ToState 只有这次更新改了状态时才有;创建任务那一条只有 ToState。
FromState string `json:"from_state,omitempty"`
ToState string `json:"to_state,omitempty"`
Text string `json:"text,omitempty"`
ActorKind string `json:"actor_kind"`
CreatedAt time.Time `json:"created_at"`
}
WorkflowUpdate 是会话时间线上的一条任务进展:一条更新记录,外加它所属任务的序号 / 标题 / 当前状态。 会话页的进展卡「每次更新一张」,靠它按提交时间排进对话(#105)。
Source Files
¶
- acl.go
- agent_link.go
- agent_live.go
- agent_screen.go
- agent_state.go
- archive_baselines.go
- archive_source.go
- artifact.go
- audit.go
- auth_profiles.go
- board.go
- board_merge.go
- board_reconcile.go
- board_why.go
- branch_params.go
- branch_routing.go
- branch_status.go
- branches.go
- chat_stream.go
- checkpoints.go
- confirm_docs.go
- confirm_items.go
- credentials.go
- credentials_capability.go
- credentials_terminal.go
- draft_images.go
- drafts.go
- embedding.go
- errors.go
- group_trash.go
- groups.go
- gui_wake_targets.go
- headless_paths.go
- hints.go
- hook_seen.go
- host_default_grants.go
- inbox.go
- inbox_config.go
- jwtsecret.go
- key_notices.go
- launcher_exec.go
- norms.go
- notes.go
- notify_prefs.go
- ntfy_config.go
- oauth.go
- oauth_cred_token.go
- oauth_manage.go
- page_diag.go
- phase_migration.go
- phases.go
- project_boards.go
- project_doc_links.go
- project_docs.go
- project_knowledge.go
- project_migration.go
- projects.go
- rebind.go
- reply_refs.go
- search_agent.go
- search_agent_quota.go
- search_candidates.go
- search_hints_config.go
- search_index.go
- search_query.go
- search_reconcile.go
- search_sources.go
- semantic.go
- sessions.go
- settings.go
- sidebar_order.go
- sqltrace.go
- store.go
- tasks.go
- terminal.go
- terminal_archives.go
- terminal_guard.go
- terminal_guard_state.go
- terminal_launcher_run.go
- terminal_launchers.go
- terminal_lost.go
- terminal_prefs.go
- terminal_runs.go
- terminal_sessions.go
- terminal_ssh.go
- validate.go
- wake_prompt.go
- web_workflow.go
- work_assign.go
- work_board_digest.go
- work_board_lines.go
- work_board_remind.go
- work_items.go
- work_modules.go
- work_search.go
- work_updates_feed.go
- workflow_gate.go
- workflow_host.go
- workflow_mode.go
- workflow_prompt.go
- workflow_trash.go