Documentation
¶
Overview ¶
Package inbox projects Today cards into the two stable user-facing columns.
Index ¶
- Constants
- Variables
- func CallerTokenCards(src CallerSource, lang i18n.Lang, now time.Time) ([]today.Card, error)
- func Cards(subjects []Subject) []today.Card
- func ChildWakeCards(src ChildWakeSource, lang i18n.Lang, allow func(string) bool) ([]today.Card, error)
- func Column(card today.Card, cfg *config.InboxConfig) string
- func EffectiveRules(cfg *config.InboxConfig) ([]config.InboxRule, string)
- func HealthCards(lang i18n.Lang, items []HealthItem) []today.Card
- func Label(lang i18n.Lang, c Category) string
- func Rank(c Category) int
- func RulesVersion(cfg *config.InboxConfig) string
- func SchedulePausedCards(src ScheduleSource, lang i18n.Lang, allow func(string) bool) ([]today.Card, error)
- func TerminalCard(lang i18n.Lang, j jobstore.JobRecord, kind string) today.Card
- func TerminalCards(src TerminalSource, lang i18n.Lang, allow func(string) bool) (failed, fyi []today.Card, err error)
- func UnreadCount(items []Item) int
- func Waiting(lang i18n.Lang, cards []today.Card) []today.Card
- type CallerSource
- type Category
- type ChildWakeSource
- type EventInfo
- type HealthItem
- type Item
- type KindInfo
- type RuleDirectory
- type ScheduleSource
- type Signals
- type State
- type Subject
- type TerminalSource
- type WaitingInput
- type WaitingStore
Constants ¶
const ( ColumnAction = "action" ColumnFYI = "fyi" )
const ( SourceDefault = "default" SourceConfig = "config" )
Rule sources reported by the rule directory.
const ( SubjectSession = "session" // a terminal session (Ref = session id) SubjectJob = "job" // a job, including a managed ACP / suga session job (Ref = job id) )
Subject types: the part of a subject key before the first colon.
const CallerTokenWarnWindow = 7 * 24 * time.Hour
CallerTokenWarnWindow is how long before the expiry the card appears.
const HealthLink = "/settings"
HealthLink is the web target the card's 「看详情」 action opens: the settings page, where the self-check items and their threshold live.
const KindCallerTokenExpiring = today.KindCallerTokenExpiring
KindCallerTokenExpiring is the card kind of a stored caller whose token expires soon or already has (design 2026-11-14 §4, plan R9).
const KindChildWakeFailed = today.KindChildWakeFailed
KindChildWakeFailed is the card kind of a child job whose result can no longer reach the resident parent job that submitted it (design 2026-11-03 告警).
const KindJobFailed = today.KindJobFailed
KindJobFailed is the card kind of a failed job a person submitted.
const KindSchedulePaused = today.KindSchedulePaused
KindSchedulePaused is the card kind of a schedule gofer paused after too many consecutive failed runs (design 2026-11-12 §1, plan R6).
const KindServerHealth = today.KindServerHealth
KindServerHealth is the card kind of a server self-check item that stayed broken past its consecutive-failure threshold (design 2026-11-14 §5).
Variables ¶
var Categories = []Category{CatApproval, CatAnswer, CatReview, CatAwaitingMerge, CatPlanStuck, CatFailed, CatAttention, CatDelivery}
Categories is the judgement order: first match wins.
Functions ¶
func CallerTokenCards ¶ added in v0.215.0
CallerTokenCards builds the cards of stored callers whose token expires within CallerTokenWarnWindow of now, or is already past its expiry. A disabled or taken-over caller never shows (nothing is left to rotate for it), and a caller with no expiry neither. The wording changes once the expiry has passed: 「expires within N days」 before, 「has expired」 from the expiry on. Soonest expiry first. Rotating the token (which resets the expiry unless the operator keeps it) or disabling the caller removes the card.
func ChildWakeCards ¶ added in v0.210.0
func ChildWakeCards(src ChildWakeSource, lang i18n.Lang, allow func(string) bool) ([]today.Card, error)
ChildWakeCards builds the cards of child receipts that will never reach their resident parent (job.child_wake_failed): the parent ended, or the receipt expired before the child produced an outcome. Each card is about the PARENT job — that is where the child list and the reason live — and uses the same 72-hour window as the failed-job cards: an older alert is history, not something to act on now. allow, when non-nil, is the caller's project scope. Newest first.
func Column ¶
func Column(card today.Card, cfg *config.InboxConfig) string
Column applies first-match-wins rules. Empty rules mean the built-in policy.
func EffectiveRules ¶ added in v0.208.0
func EffectiveRules(cfg *config.InboxConfig) ([]config.InboxRule, string)
EffectiveRules returns the rules in force: server.inbox.rules, else the built-in table.
func HealthCards ¶ added in v0.215.0
func HealthCards(lang i18n.Lang, items []HealthItem) []today.Card
HealthCards builds one card per failing self-check item. The card carries no project and no reference to a row: the item's own name is the whole subject, and the card is keyed by it (`server.health:<name>`), so it disappears by itself as soon as the item's next run succeeds — there is no row to clear and nothing to acknowledge.
func Rank ¶ added in v0.208.0
Rank is the position of c in Categories (lower = earlier); unknown sorts last.
func RulesVersion ¶ added in v0.208.0
func RulesVersion(cfg *config.InboxConfig) string
RulesVersion is a short stable digest of the effective rules (not of enabled).
func SchedulePausedCards ¶ added in v0.214.0
func SchedulePausedCards(src ScheduleSource, lang i18n.Lang, allow func(string) bool) ([]today.Card, error)
SchedulePausedCards builds the cards of schedules gofer stopped by itself because max_failures consecutive runs failed. The condition is read from the schedule row — paused_reason=failures AND still disabled — so enabling the schedule (which clears the reason) removes the card, and a schedule someone disabled by hand never shows. allow, when non-nil, is the caller's project scope. Newest first.
func TerminalCard ¶ added in v0.208.0
TerminalCard is the card of a finished job. The key is the same for both kinds so a job's read / cleared state follows it when it moves between columns (the revision changes, so it resurfaces).
func TerminalCards ¶ added in v0.208.0
func TerminalCards(src TerminalSource, lang i18n.Lang, allow func(string) bool) (failed, fyi []today.Card, err error)
TerminalCards builds the person's own terminal-job cards:
- failed: a failed / timed-out job a person submitted themselves (job.HumanSubmitted) that nothing continued (no auto-resume, no failover, no job naming it as its source). It is a "job.failed" card and enters the 「等我」 list.
- fyi: a done job a person submitted themselves. It is a "job.terminal" card, the only terminal an inbox shows besides the failures above.
Jobs of an agent, a session, a job credential or the system produce neither: their result already went back to whoever started them. allow, when non-nil, is the caller's project scope. Failures are ordered newest first.
func UnreadCount ¶ added in v0.208.0
UnreadCount counts the items of a column that are unread.
func Waiting ¶ added in v0.208.0
Waiting folds the candidate cards into THE 「等我」 list. Cards whose kind carries no structured waiting fact (work items, suggestions, merges, memory, capture, ...) are left out. Cards about one subject collapse to one entry under the first matching Category, which keeps the position of the subject's first card; the input order is otherwise kept. Each returned card carries Waiting (the category id) and WaitingLabel (in lang). The result is never nil.
Types ¶
type CallerSource ¶ added in v0.215.0
type CallerSource interface {
ListStoredCallers() ([]jobstore.StoredCaller, error)
}
CallerSource is the slice of the job store the token-expiry cards read.
type Category ¶ added in v0.208.0
type Category string
Category is one class of the 「等我」 (waiting on me) list. The classes are mutually exclusive and exhaustive over what may call a person (design 2026-11-01 §4.1): a subject falls into the FIRST class whose structured fact holds, in the order of Categories.
const ( CatApproval Category = "approval" // 待你批准 CatAnswer Category = "answer" // 待你回答 CatReview Category = "review" // 待你验收 CatAwaitingMerge Category = "awaiting_merge" // 待你收尾 CatPlanStuck Category = "plan_stuck" // 计划卡住 CatFailed Category = "failed" // 你提交的任务失败了 CatAttention Category = "attention" // 需要你处理(gofer 自己停掉的定时任务、即将到期的 token) CatDelivery Category = "delivery" // 投递待你确认 )
type ChildWakeSource ¶ added in v0.210.0
type ChildWakeSource interface {
ListJobEventsByType(eventType string, sinceAt int64) ([]jobstore.JobEvent, error)
GetJob(id string) (jobstore.JobRecord, bool, error)
UnixNow() int64
}
ChildWakeSource is the slice of the job store the child-receipt alerts read: the cross-job event query plus the parent job row (for the project scope and the link).
type EventInfo ¶ added in v0.208.0
type EventInfo struct {
Key string `json:"key"`
Group string `json:"group"`
Zh string `json:"zh"`
En string `json:"en"`
Kinds []string `json:"kinds"`
Default bool `json:"default"`
DesktopDefault bool `json:"desktop_default"`
}
EventInfo is a notify catalog event with the inbox kinds it announces. Kinds is empty for events that never reach the inbox. Default / DesktopDefault are the channels' own default subscriptions, unchanged by the inbox rules.
type HealthItem ¶ added in v0.215.0
type HealthItem struct {
// Name is the stable check identifier ("storage", "disk", "sweep", "notification").
Name string
// Failures counts the consecutive failed runs.
Failures int
// LastError is the latest failure's message.
LastError string
// At is the unix second of the latest run.
At int64
}
HealthItem is one FAILING self-check item as the card needs it — the slice of healthcheck.Result a card reads, declared here so the inbox (business layer) does not import the self-check loop (orchestration layer, G022). The caller passes only the items whose ConsecutiveFailures reached the threshold.
type Item ¶
type Item struct {
Key string `json:"key"`
Column string `json:"column"`
Kind string `json:"kind"`
Title string `json:"title"`
Summary string `json:"summary"`
SourceRevision string `json:"source_revision"`
State string `json:"state"`
Actions []today.Action `json:"actions"`
Refs today.Refs `json:"refs"`
DeepLink string `json:"deep_link,omitempty"`
ProjectKey string `json:"project_key,omitempty"`
ActivityAt int64 `json:"activity_at"`
// Waiting / WaitingLabel are the 「等我」 category of an action item (see Category) and its
// label in the request language; empty on a fyi item.
Waiting string `json:"waiting,omitempty"`
WaitingLabel string `json:"waiting_label,omitempty"`
}
type KindInfo ¶ added in v0.208.0
type KindInfo struct {
Kind string `json:"kind"`
DefaultColumn string `json:"default_column"`
// Column is the effective column for a card of this kind with no project; "" means no
// rule classifies it, so the item is not shown. Project-scoped rules are not applied
// here (they depend on the card's project).
Column string `json:"column"`
// Source is "config" when server.inbox.rules decides, "default" for the built-in table.
Source string `json:"source"`
RuleID string `json:"rule_id,omitempty"`
Events []string `json:"events"`
}
KindInfo is one inbox kind in the rule directory: where the built-in policy puts it, where the effective rules put it now, and which notify events announce it.
type RuleDirectory ¶ added in v0.208.0
type RuleDirectory struct {
Enabled bool `json:"enabled"`
// Version changes whenever the effective rules change; clients drop caches on a change.
Version string `json:"version"`
// Source is "config" when server.inbox.rules is set, else "default".
Source string `json:"source"`
Rules []config.InboxRule `json:"rules"`
Defaults []config.InboxRule `json:"defaults"`
Kinds []KindInfo `json:"kinds"`
Events []EventInfo `json:"events"`
}
RuleDirectory is the GET /v1/inbox/rules body.
func Directory ¶ added in v0.208.0
func Directory(cfg *config.InboxConfig) RuleDirectory
Directory builds the rule directory for the effective config. Only keys, columns and catalog descriptions are exposed: no webhook, path or secret.
type ScheduleSource ¶ added in v0.214.0
type ScheduleSource interface {
ListSchedules(projectFilter string, enabledOnly bool) ([]jobstore.ScheduleRecord, error)
}
ScheduleSource is the slice of the job store the paused-schedule cards read.
type Signals ¶ added in v0.208.0
type Signals struct {
// HeldForApproval: job status awaiting_approval (a push hold included).
HeldForApproval bool
// ApprovalInteraction: a pending interaction of type permission / confirmation, or a
// terminal tool-permission prompt.
ApprovalInteraction bool
// Question: a gofer_ask_human decision, a pending question / choice interaction, an
// AskUserQuestion, or a session relay turn awaiting the person's reply.
Question bool
// NeedsReview: job status needs_review.
NeedsReview bool
// AwaitingMerge: a todo of a complete_on=merge plan whose job ended done and whose
// deliverable has not landed (today.KindTodoAwaitingMerge).
AwaitingMerge bool
// PlanBlocked: plan status blocked.
PlanBlocked bool
// TodoNeedsReview: a plan todo whose job waits in needs_review.
TodoNeedsReview bool
// FailedBySelf: terminal failed / timeout, submitted by a person (job.HumanSubmitted),
// with no follow-up job.
FailedBySelf bool
// DeliveryHeld: a letter held for nobody to receive, or bounced.
DeliveryHeld bool
// Attention: something gofer itself stopped or is about to stop that only a person can
// put right (a schedule paused by its failure streak, a caller token about to expire).
Attention bool
}
Signals are the structured facts about ONE subject (a job, a session, a plan, a decision). Every field is read from a store row or a server-stamped marker, never from a model's summary or inferred work-item status.
type Subject ¶ added in v0.217.0
type Subject struct {
// Key is the subject key (the one Waiting collapses cards by), e.g. "job:<id>".
Key string
Category Category
// Type is SubjectSession / SubjectJob, or the other key prefix (decision, todo, plan ...).
Type string
// Ref is the id after the prefix: the terminal session id or the job id.
Ref string
Card today.Card
}
Subject is one entry of the 「等我」 list seen by what it is about: the stable key the subject files under, its category, the kind of thing it is and that thing's id. The seat status and the notice record read this form; the cards behind the HTTP lists are Card.
func SubjectsOf ¶ added in v0.217.0
SubjectsOf is Waiting with the subject spelled out: the same folding and order, one Subject per waiting entry. The result is never nil.
func WaitingSubjects ¶ added in v0.217.0
func WaitingSubjects(in WaitingInput, queue []today.Card) (waiting []Subject, fyi []today.Card, err error)
WaitingSubjects is the one 「等我」 judgement: the structured-fact cards of the today queue plus the caller-visible failures of jobs a person submitted, child receipts that could not be delivered and schedules gofer paused, folded by Waiting. fyi is the person's own finished jobs (the inbox's second column). Every input is a store fact, so the answer does not change when the server restarts.
type TerminalSource ¶ added in v0.208.0
TerminalSource is the slice of the job store the terminal-job sources read.
type WaitingInput ¶ added in v0.217.0
type WaitingInput struct {
Store WaitingStore
Lang i18n.Lang
// Allow is the caller's project scope (nil = unrestricted).
Allow func(string) bool
Extra []today.Card
}
WaitingInput carries what the caller decides: language and project scope. Store may be nil (no store sources then); Extra holds the cards of sources that need the caller's own permissions (an expiring token, the server health list), appended after the store ones.
type WaitingStore ¶ added in v0.217.0
type WaitingStore interface {
TerminalSource
ChildWakeSource
ScheduleSource
}
WaitingStore is the part of the job store the 「等我」 sources read.