Documentation
¶
Overview ¶
Package core is Godwit's mail engine.
Index ¶
- Constants
- Variables
- func ModelEndpoint(kind, base string) string
- func ModelProviderLogin(p string) string
- func ModelProviderURL(p string) string
- func NormalizeModelBaseURL(raw string) (string, error)
- func ProviderFormats(p string) (gen, judge []string)
- func SerializeKeyringForTest()
- func SignatureEditorHTML(sig string, cids map[string]bool) string
- func SignatureImageURL(data []byte) (string, error)
- func SyncDevDatabase(ctx context.Context, src, dst string) (err error)
- type Account
- type AccountInput
- type AccountPatch
- type ActionInfo
- type ActionResult
- type AppliedLabel
- type Approval
- type AttachmentInfo
- type Avatar
- type CapStatus
- type Card
- type CardButton
- type CardField
- type CheckError
- type CheckReport
- type CheckStep
- type Citation
- type ConfigValue
- type Conversation
- type Draft
- type DraftAttachment
- type EgressApprovalRequired
- type ErrNoRoleFolder
- type Folder
- type Label
- type LabelInput
- type MCPServer
- type MCPServerInput
- type MCPTool
- type Message
- type MessagePage
- type MessageSummary
- type MessageText
- type ModelService
- type ModelServiceInput
- type Op
- type Options
- type OutboxItem
- type PluginInfo
- type PluginInstallProgress
- type Purge
- type QuickReply
- type RegistryEntry
- type RegistrySource
- type RegistryView
- type RunActionOptions
- type RunSpan
- type SearchQuery
- type Security
- type Selection
- type SendBlockedError
- type SendCheck
- type SendWarning
- type SendWarningsError
- type ServerSettings
- type Service
- func (s *Service) AddAccount(ctx context.Context, in AccountInput) (Account, error)
- func (s *Service) AddAttachment(ctx context.Context, draftID int64, srcPath string) (DraftAttachment, error)
- func (s *Service) AddAttachmentAt(ctx context.Context, draftID, revision int64, srcPath string) (DraftAttachment, int64, error)
- func (s *Service) AddMCPServer(ctx context.Context, in MCPServerInput) (MCPServer, error)
- func (s *Service) AddModelService(ctx context.Context, in ModelServiceInput) (ModelService, error)
- func (s *Service) ApplyEditedProposal(ctx context.Context, approvalID int64, edited string) error
- func (s *Service) Ask(ctx context.Context, conversationID int64, input string) (<-chan WitEvent, error)
- func (s *Service) AskWith(ctx context.Context, conversationID int64, input string, quoted []int64) (<-chan WitEvent, error)
- func (s *Service) Assist(ctx context.Context, draftID int64, input string) (<-chan WitEvent, error)
- func (s *Service) AssistSkill(ctx context.Context, draftID int64, skill string, opts SkillOptions) (<-chan WitEvent, error)
- func (s *Service) AssistWith(ctx context.Context, draftID int64, input string, quoted []int64) (<-chan WitEvent, error)
- func (s *Service) AttachmentCacheUsage(ctx context.Context, accountID int64) (int64, error)
- func (s *Service) AuditExternal(ctx context.Context, source, action string, target int64) error
- func (s *Service) AwaitOAuth(ctx context.Context, flowID string) (email string, err error)
- func (s *Service) BeginOAuth(ctx context.Context, providerID, loginHint string) (flowID, authURL string, err error)
- func (s *Service) CancelOAuth(flowID string)
- func (s *Service) CancelRun(ctx context.Context, runID int64) error
- func (s *Service) CheckAccount(ctx context.Context, in AccountInput) (CheckReport, error)
- func (s *Service) CheckModelService(ctx context.Context, id int64, in ModelServiceInput) (ServiceCheck, error)
- func (s *Service) ClearAttachmentCache(ctx context.Context, accountID int64) error
- func (s *Service) ClearImageCache() error
- func (s *Service) Close() error
- func (s *Service) CreateLabel(ctx context.Context, in LabelInput) (Label, error)
- func (s *Service) Delete(ctx context.Context, ids []int64) error
- func (s *Service) DeleteConversation(ctx context.Context, id int64) error
- func (s *Service) DeleteDraft(ctx context.Context, id int64) error
- func (s *Service) DeleteDraftIfEmpty(ctx context.Context, id, revision int64) (deleted bool, err error)
- func (s *Service) DeleteLabel(ctx context.Context, id int64) error
- func (s *Service) DetectProvider(ctx context.Context, email string) (auth.Provider, auth.Source, error)
- func (s *Service) DraftFromQuickReply(ctx context.Context, messageID int64, r QuickReply) (Draft, error)
- func (s *Service) FetchModels(ctx context.Context, id int64) ([]string, error)
- func (s *Service) GetAttachment(ctx context.Context, attachmentID int64) (string, AttachmentInfo, error)
- func (s *Service) GetConversation(ctx context.Context, id int64) (Conversation, error)
- func (s *Service) GetDraft(ctx context.Context, id int64) (Draft, error)
- func (s *Service) GetMessage(ctx context.Context, id int64, loadRemoteImages bool) (Message, error)
- func (s *Service) GetMessageText(ctx context.Context, id int64) (MessageText, error)
- func (s *Service) GetPluginConfig(ctx context.Context, name string) ([]ConfigValue, error)
- func (s *Service) GetRawMessage(ctx context.Context, messageID int64) ([]byte, error)
- func (s *Service) GetSettings(ctx context.Context) (Settings, error)
- func (s *Service) GetThread(ctx context.Context, id int64) (Thread, error)
- func (s *Service) GrantMCPServer(ctx context.Context, id int64) error
- func (s *Service) GrantPermission(ctx context.Context, name string) error
- func (s *Service) ImageCache() *imagecache.Cache
- func (s *Service) ImageCacheSize() int64
- func (s *Service) ImagesAllowed(ctx context.Context, message int64) (bool, error)
- func (s *Service) InlineSignatureImages(ctx context.Context, accountID int64, html string) (string, error)
- func (s *Service) InstallPlugin(ctx context.Context, srcDir string) (PluginInfo, error)
- func (s *Service) InstallPluginFromRegistry(ctx context.Context, name string) (PluginInfo, error)
- func (s *Service) InstallPluginFromRegistryWithProgress(ctx context.Context, name string, progress func(PluginInstallProgress)) (PluginInfo, error)
- func (s *Service) KeychainStatus(ctx context.Context) error
- func (s *Service) LabelModelReady(ctx context.Context) bool
- func (s *Service) ListAccounts(ctx context.Context) ([]Account, error)
- func (s *Service) ListActions(ctx context.Context, kind string) ([]ActionInfo, error)
- func (s *Service) ListApprovals(ctx context.Context, conversationID int64) ([]Approval, error)
- func (s *Service) ListConversations(ctx context.Context, kind string) ([]Conversation, error)
- func (s *Service) ListDrafts(ctx context.Context, accountID int64) ([]Draft, error)
- func (s *Service) ListFolders(ctx context.Context, accountID int64) ([]Folder, error)
- func (s *Service) ListLabels(ctx context.Context) ([]Label, error)
- func (s *Service) ListMCPServers(ctx context.Context) ([]MCPServer, error)
- func (s *Service) ListMessages(ctx context.Context, v View, cursor string, limit int) (MessagePage, error)
- func (s *Service) ListModelServices(ctx context.Context) ([]ModelService, error)
- func (s *Service) ListOutbox(ctx context.Context, accountID int64) ([]OutboxItem, error)
- func (s *Service) ListPluginRegistry(ctx context.Context) (RegistryView, error)
- func (s *Service) ListPlugins(ctx context.Context) ([]PluginInfo, error)
- func (s *Service) ListProviders() []auth.Provider
- func (s *Service) ListSkills(ctx context.Context) ([]SkillInfo, error)
- func (s *Service) ListThreads(ctx context.Context, v View, cursor string, limit int) (ThreadPage, error)
- func (s *Service) ListTranslators(ctx context.Context) ([]TranslatorInfo, error)
- func (s *Service) LoadOlder(ctx context.Context, folderID int64) (more bool, err error)
- func (s *Service) MessageLabels(ctx context.Context, ids []int64) (map[int64][]AppliedLabel, error)
- func (s *Service) ModelServiceAvatar(ctx context.Context, id int64) (Avatar, error)
- func (s *Service) Move(ctx context.Context, ids []int64, folderID int64) error
- func (s *Service) MoveToRole(ctx context.Context, ids []int64, role string) error
- func (s *Service) NewConversation(ctx context.Context, kind string, draftID int64) (Conversation, error)
- func (s *Service) NewDraft(ctx context.Context, accountID int64, mode string, sourceMessageID int64) (Draft, error)
- func (s *Service) PendingLabels(ctx context.Context) (int, error)
- func (s *Service) PendingOps(ctx context.Context, accountID int64) ([]Op, error)
- func (s *Service) PluginCards(ctx context.Context, messageID int64) ([]Card, error)
- func (s *Service) PluginTags(ctx context.Context, messageID int64) ([]Tag, error)
- func (s *Service) Purges(ctx context.Context, accountID int64) (map[string]Purge, error)
- func (s *Service) QuickReplies(ctx context.Context, messageID int64) ([]QuickReply, error)
- func (s *Service) ReadingLanguage(ctx context.Context) string
- func (s *Service) Reauthorize(ctx context.Context, id int64, flowID string) error
- func (s *Service) RebuildSearchIndex(ctx context.Context) error
- func (s *Service) RecentSignInCodes(ctx context.Context, now time.Time) ([]SignInCode, error)
- func (s *Service) RecordCapStatus(ctx context.Context, id, version int64, c string, st CapStatus) error
- func (s *Service) Redact(text string) string
- func (s *Service) RefreshMCPTools(ctx context.Context, id int64) error
- func (s *Service) RefreshPluginRegistry(ctx context.Context) error
- func (s *Service) RemoveAccount(ctx context.Context, id int64) error
- func (s *Service) RemoveAttachment(ctx context.Context, draftID, attachmentID int64) error
- func (s *Service) RemoveAttachmentAt(ctx context.Context, draftID, attachmentID, revision int64) (int64, error)
- func (s *Service) RemoveMCPServer(ctx context.Context, id int64) error
- func (s *Service) RemoveModelService(ctx context.Context, id int64) error
- func (s *Service) ReorderLabels(ctx context.Context, ids []int64) error
- func (s *Service) RescanLabels(ctx context.Context, days int, all bool) (int, error)
- func (s *Service) ResolveAll(ctx context.Context, runID int64, accept bool) error
- func (s *Service) ResolveApproval(ctx context.Context, id int64, accept bool) error
- func (s *Service) ResolveApprovalForConversation(ctx context.Context, id int64) error
- func (s *Service) ResolveOutbox(ctx context.Context, id int64, action string) error
- func (s *Service) RewriteSelection(ctx context.Context, draftID int64, sel Selection, instruction string) (<-chan WitEvent, error)
- func (s *Service) RunAction(ctx context.Context, id string, t Target, opts RunActionOptions) (ActionResult, error)
- func (s *Service) RunSkill(ctx context.Context, name string, t Target) (<-chan ai.Event, error)
- func (s *Service) SaveDraft(ctx context.Context, d Draft) (Draft, error)
- func (s *Service) Search(ctx context.Context, accountID int64, query string, limit int) ([]MessageSummary, error)
- func (s *Service) SearchWith(ctx context.Context, q SearchQuery, limit int) ([]MessageSummary, error)
- func (s *Service) Send(ctx context.Context, draftID int64) error
- func (s *Service) SendAcknowledged(ctx context.Context, draftID int64, digest string) error
- func (s *Service) SendAcknowledgedRevision(ctx context.Context, draftID, revision int64, digest string) error
- func (s *Service) SendRevision(ctx context.Context, draftID, revision int64) error
- func (s *Service) SenderAvatar(ctx context.Context, messageID int64, allowRemote bool) (Avatar, error)
- func (s *Service) SetDraftAccount(ctx context.Context, id, accountID, revision int64) (Draft, error)
- func (s *Service) SetFlags(ctx context.Context, ids []int64, add, remove []string) error
- func (s *Service) SetLabel(ctx context.Context, messageIDs []int64, labelID int64, on bool) error
- func (s *Service) SetMCPServerEnabled(ctx context.Context, id int64, enabled bool) error
- func (s *Service) SetMCPToolTrusted(ctx context.Context, id int64, tool string, trusted bool) error
- func (s *Service) SetNativeHostForTest(env ...string)
- func (s *Service) SetPluginConfig(ctx context.Context, name string, values map[string]json.RawMessage) error
- func (s *Service) SetPluginEnabled(ctx context.Context, name string, enabled bool) error
- func (s *Service) SetPluginNetForTest(n plugins.NetOptions)
- func (s *Service) SetPurge(ctx context.Context, accountID int64, role string, days int) error
- func (s *Service) SetRoleFolder(ctx context.Context, accountID int64, role string, folderID int64) error
- func (s *Service) SetSettings(ctx context.Context, st Settings) (Settings, error)
- func (s *Service) SetSkillEnabled(ctx context.Context, name string, enabled bool) error
- func (s *Service) SignatureEditor(ctx context.Context, accountID int64) (string, error)
- func (s *Service) SignatureImageURLs(ctx context.Context, accountID int64, html string) ([]string, error)
- func (s *Service) StopRescan(ctx context.Context) error
- func (s *Service) Subscribe() (<-chan events.Event, func())
- func (s *Service) SubscribeConversation(id int64) (<-chan WitEvent, func())
- func (s *Service) SyncNow(ctx context.Context, accountID int64) error
- func (s *Service) TaskModel(ctx context.Context, skill string) (string, error)
- func (s *Service) TestAccount(ctx context.Context, in AccountInput) error
- func (s *Service) TestCapability(ctx context.Context, id int64, in ModelServiceInput, c string) (CapStatus, error)
- func (s *Service) ThreadLabels(ctx context.Context, threadIDs []int64) (map[int64][]AppliedLabel, error)
- func (s *Service) TrustImageSender(ctx context.Context, from string) error
- func (s *Service) UndoLastAssist(ctx context.Context, draftID int64) error
- func (s *Service) UninstallPlugin(ctx context.Context, name string) error
- func (s *Service) UntrustImageSender(ctx context.Context, addr string) error
- func (s *Service) UpdateAccount(ctx context.Context, id int64, p AccountPatch) (Account, error)
- func (s *Service) UpdateLabel(ctx context.Context, id int64, in LabelInput) (Label, error)
- func (s *Service) UpdateMCPServer(ctx context.Context, id int64, in MCPServerInput) (MCPServer, error)
- func (s *Service) UpdateModelService(ctx context.Context, id int64, in ModelServiceInput) (ModelService, error)
- func (s *Service) UpdatePassword(ctx context.Context, id int64, password string) error
- type ServiceCheck
- type Settings
- type SignInCode
- type SkillInfo
- type SkillOptions
- type SyncRange
- type Tag
- type Target
- type Thread
- type ThreadPage
- type ThreadSummary
- type TranslatorInfo
- type View
- type WitEvent
Constants ¶
const ( MaxCacheBytes = 2 << 30 // attachment cache budget; oldest files are evicted beyond it MaxMessageBytes = 25 << 20 // largest attachment or message accepted )
const ( WarningPlugin = "plugin_warning" WarningNoResponse = "no_response" )
const ( AuditLocalAPI = "local_api" AuditMCP = "local_mcp" )
External audit sources: the Local API's full role, and its mcp role (the godwit mcp bridge; "local_mcp", unlike the "mcp" of MCP-server tools).
const ( ProviderOpenAI = "openai" ProviderAnthropic = "anthropic" ProviderTypeSafe = "typesafe" ProviderOther = "other" ProviderChatGPT = "chatgpt" ProviderGrok = "grok" )
Providers: which formats a service offers (the add dialog's tiles).
const ( CapGen = "gen" CapJudge = "judge" )
Capabilities, the keys of ModelService.Status.
const ( KeyKeep = "keep" // reuse the stored key; only while kind and address are unchanged KeyReplace = "replace" // use APIKey KeyClear = "clear" // no key )
Key actions for ModelServiceInput.KeyAction.
const ( MinJudgeThreshold = 0.5 MaxJudgeThreshold = 0.95 )
MinJudgeThreshold and MaxJudgeThreshold bound the user-adjustable cutoff.
const ( SignatureImageMax = 512 << 10 SignatureImagesMax = 4 )
Signature images: png, jpeg, gif or webp, sniffed (never named), at most SignatureImageMax bytes each and SignatureImagesMax per signature. They are stored per account, content-addressed, and referenced in the signature as cid:sig-<hash>@godwit; a sent mail carries them as inline parts. Their metadata (EXIF with its GPS, XMP, text) is stripped before storing.
const ( SecurityTLS = conn.TLS SecurityStartTLS = conn.StartTLS SecurityNone = conn.None )
const KindInvalid conn.FailureKind = "invalid"
KindInvalid marks a failed settings step: the input itself is not valid.
const MaxLabelDescription = 500
MaxLabelDescription is the most runes a label description has: every classification sends every description to the model.
const MaxLabelName = 32
MaxLabelName is the most runes a label name has.
const SignInCodesPlugin = "sign-in-codes"
SignInCodesPlugin recognizes sign-in codes and links: the banner, the tray's recent list and the reader's card.
const SignatureHTMLPrefix = "<!--godwit:html-->"
SignatureHTMLPrefix marks a stored signature as the settings editor's HTML; any other signature (the CLI's, the Local API's, an older one) is plain text.
Variables ¶
var ( ErrTooLarge = errors.New("attachment exceeds the size limit") ErrNotOnServerYet = errors.New("message has not reached the server yet") )
var ( ErrNeedsGrant = errors.New("permissions are not granted") ErrPluginNotFound = errors.New("plugin not found") )
var ( ErrAINotConfigured = errors.New("no model configured") ErrModelServiceNotFound = errors.New("model service not found") ErrModelNotFound = errors.New("model not found") ErrTranslatorUnavailable = errors.New("the translation plugin is not running") )
var ( ErrModelAuth = ai.ErrModelAuth ErrBaseURLInvalid = ai.ErrBaseURLInvalid ErrBaseURLScheme = ai.ErrBaseURLScheme ErrKeyNeedsConfirm = errors.New("the address or protocol changed: enter the key again or choose no key") )
var ( ErrRegistryOff = errors.New("no plugin registry is configured") ErrRegistrySignature = errors.New("the plugin registry's signature does not match") ErrRegistryStale = errors.New("the plugin registry is older than the one Godwit has") ErrRegistryMismatch = errors.New("the downloaded file does not match the plugin registry; it was discarded") )
var ( // ErrSignatureImage is an image that is not png, jpeg, gif or webp, or is over SignatureImageMax. ErrSignatureImage = errors.New("a signature image must be a png, jpeg, gif or webp of at most 512 KB") // ErrSignatureImageCount is a signature with more than SignatureImagesMax images. ErrSignatureImageCount = errors.New("a signature has at most 4 images") )
var ( ErrSkillDisabled = errors.New("skill is disabled") ErrSkillNotFound = errors.New("skill not found") )
var DefaultRegistry = func() *RegistrySource { key, err := base64.StdEncoding.DecodeString(registryPublicKey) if err != nil || len(key) != ed25519.PublicKeySize { return nil } return &RegistrySource{URL: registryURL, PublicKey: key} }()
DefaultRegistry is Godwit's own registry, nil while it has no key.
var ErrAccountNotFound = errors.New("account not found")
ErrAccountNotFound is returned for an account id that does not exist.
var ErrClosed = errors.New("service is closed")
ErrClosed is returned by calls made after Close.
var ErrInvalidState = errors.New("item is not waiting for a decision")
ErrInvalidState is returned by ResolveOutbox and ResolveApproval for an item that is not waiting for a decision.
ErrKeychainUnavailable means the system keychain cannot be used (locked, no secret service, access denied). Credentials never fall back to a file.
var ErrLabelExists = errors.New("a label with this name exists")
ErrLabelExists is a label name already taken, ignoring case and outer spaces.
var ErrMCPNotFound = errors.New("MCP server not found")
var ErrModelLogin = errors.New("sign in to add this service")
ErrModelLogin is returned when adding a subscription model service without signing in first.
var ErrModelReauth = errors.New("the model service sign-in is no longer valid; sign in again")
ErrModelReauth is returned when a subscription model service's refresh token has been revoked, expired or lost from the keychain.
var ErrNotGrantable = errors.New("this tool cannot be allowed for the whole conversation")
ErrNotGrantable: the approval's tool cannot be allowed for the whole conversation.
var ErrNotSynced = mailsync.ErrNotSynced
ErrNotSynced is LoadOlder on a folder whose first sync has not completed.
var ErrProviderMismatch = errors.New("signed in with a different provider")
ErrProviderMismatch: AccountInput.Provider names another provider than the one the OAuth flow signed in with.
var ErrRunActive = errors.New("the conversation already has an active run")
ErrRunActive: the conversation has a run that is running, waiting for approvals or resuming.
var ErrStaleApproval = errors.New("the tool changed since this was proposed")
ErrStaleApproval: what an external approval was bound to (plugin code, permissions or config; an MCP server or tool definition) changed since it was proposed; it was not run.
var ErrStaleDraft = errors.New("draft changed since it was loaded")
ErrStaleDraft means the draft changed since the revision the caller saved against.
var ErrUnknownFlow = errors.New("no such sign-in flow")
ErrUnknownFlow: no such flow ID, or it was already awaited, cancelled or expired.
var ErrUseAssist = errors.New("draft skills run through AssistSkill")
ErrUseAssist: skills on drafts run through AssistSkill, which makes proposals.
var ErrWrongAccount = errors.New("signed in with a different account")
ErrWrongAccount: the OAuth sign-in was for another address than the account's.
var LabelColors = []string{"gray", "red", "orange", "amber", "green", "blue", "violet", "pink"}
LabelColors are the colors a label may take, in the picker's order.
var LabelIcons = []string{"shield-keyhole", "bill", "truck", "plane", "calendar-event", "notification-3", "newspaper", "shopping-bag-3",
"folder-3", "money-dollar-circle", "book-2", "graduation-cap", "pencil", "quill-pen", "braces", "terminal-box",
"music-2", "movie-2", "tools", "palette", "stethoscope", "first-aid-kit", "seedling", "briefcase-4",
"bar-chart-box", "run", "sticky-note", "scales-3", "earth", "global", "hammer", "footprint",
"flask", "brain", "heart-3", "plant", "team", "home-4", "key-2", "chat-3"}
LabelIcons are the icons a label may take, in the picker's order; the GUI draws each as "label-<name>".
var PurgeDays = []int{0, 1, 7, 30}
PurgeDays are the purge periods offered: never, a day, a week and a month.
Functions ¶
func ModelEndpoint ¶
ModelEndpoint is the URL requests to a service at base will hit.
func ModelProviderLogin ¶ added in v1.1.0
ModelProviderLogin returns "oauth" if provider p signs in with OAuth, else "".
func ModelProviderURL ¶ added in v1.1.0
ModelProviderURL returns the fixed BaseURL of a subscription model provider, or "".
func NormalizeModelBaseURL ¶
NormalizeModelBaseURL is the address a service is saved with, whatever its formats: ErrBaseURLInvalid or ErrBaseURLScheme says why raw is refused.
func ProviderFormats ¶
ProviderFormats are the generate kinds and judge formats provider p offers, in the dialog's order.
func SerializeKeyringForTest ¶
func SerializeKeyringForTest()
SerializeKeyringForTest makes keychain calls one at a time. Tests only: go-keyring's mock (keyring.MockInit) is not safe for concurrent use, and sync workers read credentials while a test writes them. Call it before any Service starts; later calls do nothing.
func SignatureEditorHTML ¶
SignatureEditorHTML is sig as safe compose HTML, without the draft marker or the "-- " delimiter: a marked one sanitized (user markers stripped, the images in cids kept), a plain one escaped into a paragraph; "" for none.
func SignatureImageURL ¶
SignatureImageURL is data as a data: URL for the signature editor, or ErrSignatureImage.
Types ¶
type Account ¶
type Account struct {
ID int64
Email, Name, Alias, Signature, Username string
IsDefault bool
Sync SyncRange
Folders int // folders synced so far: 0 before the first sync
AuthType, Status string
IMAPHost string
IMAPPort int
IMAPSecurity Security
SMTPHost string
SMTPPort int
SMTPSecurity Security
Provider, StatusDetail string
}
Account is a stored account. The password lives only in the system keychain. Status is ok; reauth_required when the password is missing from the keychain (StatusDetail credentials_missing) or the IMAP or SMTP server refuses it (auth_rejected) or the provider revoked an OAuth grant (token_revoked); or error when the keychain is unavailable (keychain_unavailable). An OAuth account's keychain entry holds its refresh token; access tokens stay in memory.
type AccountInput ¶
type AccountInput struct {
Email, Name, Alias, Signature, Username, Password string
IsDefault bool
Sync *SyncRange // nil: the newest 2000 per folder
IMAPHost string
IMAPPort int
IMAPSecurity Security
SMTPHost string
SMTPPort int
SMTPSecurity Security
Provider string // auth.Provider ID; empty is stored as other
// OAuthFlowID names a finished AwaitOAuth flow: the account signs in with its
// tokens instead of Password, and Email must be the signed-in address.
OAuthFlowID string
}
AccountInput is what the user supplies to add or test an account.
type AccountPatch ¶
type AccountPatch struct {
Name, Alias, Signature *string
IsDefault *bool
Sync *SyncRange
Servers *ServerSettings
}
AccountPatch changes the account settings that are not nil.
type ActionInfo ¶
ActionInfo is an action a running plugin registered; ID is <plugin>/<id>.
type ActionResult ¶
ActionResult is what an action returned: text, HTML sanitized for reading, or a draft it made for the UI to open.
type AppliedLabel ¶ added in v0.3.0
AppliedLabel is a label on a message or thread. Auto: the model set it, and no message of the thread has it set by hand.
type Approval ¶
type Approval struct {
ID, RunID, ConversationID int64
Seq int
CallID, Tool string
Args json.RawMessage
Summary, State, Error string
Destinations []string
// SessionAllow: 本次对话都允许 can approve it (ResolveApprovalForConversation).
SessionAllow bool
}
Approval is a call waiting for the user or decided. State goes pending → executing → done or failed, or pending → rejected or stale. Error is what the model was told for any end state but done. Destinations are the hosts (host[:port]) the call sends data to, if any. CallID is the tool call it answers ("skill" for a skill's proposal).
type AttachmentInfo ¶
AttachmentInfo describes one attachment; its bytes are fetched lazily.
type Avatar ¶ added in v0.3.0
Avatar is a sender image; empty Data means there is no permitted image.
type CapStatus ¶
type CapStatus struct {
State string // "ok" or "fail"
LatencyMs int
HTTPStatus int // the status that failed it, when known
Code string // why it failed: auth, forbidden, no_list, timeout, bad_answer, error, unreachable
At time.Time
}
CapStatus is a capability's last test. It holds codes, never error text: errors can echo a key, a response body or mail.
type Card ¶
type Card struct {
Plugin, Title string
Fields []CardField
Buttons []CardButton
}
Card is a plugin's declarative card for a message.
type CardButton ¶
type CardButton struct{ Label, Kind, Value string }
CardButton: Kind copy (Value is the text), open-url (an http or https URL) or run-action (Value is the action's full ID, <plugin>/<id>).
type CheckError ¶
type CheckError struct {
Report CheckReport
// contains filtered or unexported fields
}
CheckError is returned by TestAccount and AddAccount when a check fails.
func (*CheckError) Error ¶
func (e *CheckError) Error() string
func (*CheckError) Unwrap ¶
func (e *CheckError) Unwrap() error
type CheckReport ¶
Folders is how many selectable folders the imap step listed (0 if LIST failed).
type CheckStep ¶
CheckStep is one item of a connection check. Name is settings, imap or smtp. Detail comes from conn's already redacted errors: no password, token or server text.
type Citation ¶
type Citation struct {
N int
MessageID int64
Subject, From string
Date time.Time
Suspect bool
Quote string // the suspect text, from where it starts (ai.InjectionQuote): show as plain text
RunID int64
CallID string
}
Citation is a message a run's tools showed the model: RunID's call CallID (its tool_result), or its context when CallID is "". N is the message's citation number in the conversation (from 1, by first citation): the model sees it as the mail's "ref" and cites it as [N].
type ConfigValue ¶
type ConfigValue struct {
Key string
Value json.RawMessage
Set bool
}
ConfigValue is a plugin setting as the settings form shows it: the stored value, or with Set false the default. A secret's Value is always empty.
type Conversation ¶
type Conversation struct {
ID int64
Kind, Title, Model string
DraftID int64
Messages []ai.Message
Citations []Citation
Runs []RunSpan
ActiveRunID int64
UpdatedAt time.Time
}
Conversation is a Wit chat: kind "ask" (the mailbox panel) or "assist" (one draft's compose panel, DraftID set). Messages is decoded from the saved model state, for display; Citations are the mail its runs showed the model, in the order they came, each with the run and tool call that showed it (a message shown twice is there twice); Runs are the parts of Messages each run added, in run order; ActiveRunID is its run that is running, resuming or waiting for approvals (0: none). ListConversations leaves those four empty.
type Draft ¶
type Draft struct {
ID, AccountID int64
Mode string
SourceMessageID int64
To, Cc, Bcc []string
ReplyTo, Subject, HTML string
Attachments []DraftAttachment
UpdatedAt time.Time
// Revision grows by one on every update, an attachment added or removed
// included (refetch it after one). SaveDraft with a non-zero Revision
// fails with ErrStaleDraft unless it is still the stored one.
Revision int64
}
Draft is an unsent message. Mode is new, reply, reply_all or forward.
type DraftAttachment ¶
DraftAttachment is a file copied into the draft's directory.
type EgressApprovalRequired ¶
EgressApprovalRequired: the run may send mail content to Hosts (every host the plugin declares); ask the user, then run again with ApproveEgress.
func (*EgressApprovalRequired) Error ¶
func (e *EgressApprovalRequired) Error() string
type ErrNoRoleFolder ¶
type ErrNoRoleFolder struct{ Role string }
ErrNoRoleFolder is MoveToRole's error for an account without a folder of Role.
func (*ErrNoRoleFolder) Error ¶
func (e *ErrNoRoleFolder) Error() string
type Folder ¶
type Folder struct {
ID, AccountID int64
Name, Role string
Delim string // the server's hierarchy delimiter in Name, "" when flat
Unread int
}
Folder is a mailbox of an account. Role is inbox, sent, trash, drafts, junk, archive or empty.
type Label ¶ added in v0.3.0
type Label struct {
ID int64
Slug, Name, Description, Color, Icon string
Builtin bool
Position int
Count, Unread int
}
Label is a mail label. Count is the messages it is on, Unread those unread.
type LabelInput ¶ added in v0.3.0
type LabelInput struct{ Name, Description, Color, Icon string }
LabelInput is what the user sets on a label.
type MCPServer ¶
type MCPServer struct {
ID int64
Name, Transport, Command string
Args, EnvKeys, HeaderKeys []string
URL string
Version int64
Enabled, Granted bool
Tools []MCPTool
Error string
}
MCPServer is a configured server. Granted means the current Version is granted; Tools are the last listed for this version; Error is why it last failed to connect or was stopped.
type MCPServerInput ¶
type MCPServerInput struct {
Name, Transport, Command string
Args []string
Env map[string]string
URL string
Headers map[string]string
}
MCPServerInput configures a server. Transport is "stdio" (Command, Args, Env) or "http" (URL, Headers). Env and Header values go to the keychain; an empty value in an update keeps the stored one, a key left out is removed.
type MCPTool ¶
MCPTool is a tool of a server. ReadOnlyHint is the server's own claim, for display only; Trusted holds while the user trusted this DefinitionHash.
type Message ¶
type Message struct {
MessageSummary
ReplyTo string
HTML, Text string
Truncated bool
RemoteImagesBlocked int
// InJunk: the folder is junk, detected or given (even where another
// folder holds the role), so its sender's images are never trusted.
InJunk bool
Attachments []AttachmentInfo
}
Message is a fully loaded message. HTML is always sanitized. Truncated means HTML and Text hold only the start of the body; GetRawMessage has all of it.
type MessagePage ¶
type MessagePage struct {
Items []MessageSummary
NextCursor string
}
MessagePage is one page of a flat message list.
type MessageSummary ¶
type MessageSummary struct {
ID, ThreadID, FolderID int64
Subject, From, Snippet string
To, Cc []string
Date time.Time
Flags []string
HasAttachments bool
}
MessageSummary is a message as listed.
type MessageText ¶
type MessageText struct {
MessageSummary
AccountID int64
ReplyTo string
Text string
Truncated bool
Attachments []AttachmentInfo
}
MessageText is a message as stored: its plain text and metadata, with the attachments listed but never fetched.
type ModelService ¶
type ModelService struct {
ID int64
Name, Kind, BaseURL string
Provider string // ProviderOpenAI, …: the formats it offers; fixed once added
Slug string // the service part of its "slug/model" references; kept on rename
Models []string
JudgeFormat, JudgeModel string
Email string // OAuth sign-in address (chatgpt, grok); "" for API-key services
HasKey bool
Version int64
// Status is the last test of each capability (CapGen, CapJudge), absent
// when untested or when what it tested changed since.
Status map[string]CapStatus
// contains filtered or unexported fields
}
ModelService is a model service and its two capabilities. Kind is the generate format: ai.KindOpenAI (chat), ai.KindResponses or ai.KindAnthropic (messages); "" turns generate off. JudgeFormat is ai.FormatDecisions or ai.FormatSystemOne; "" turns judge off. BaseURL is one base for both, normalized the same for every format.
func (ModelService) Input ¶
func (m ModelService) Input() ModelServiceInput
Input is m as it is saved, keeping its key.
type ModelServiceInput ¶
type ModelServiceInput struct {
Name, Kind, BaseURL, APIKey string
KeyAction string
OAuthFlowID string
Models []string
Provider string
JudgeFormat, JudgeModel string
// contains filtered or unexported fields
}
ModelServiceInput is a service as the user entered it. An empty KeyAction means replace when APIKey is set, else keep (update) or none (add). Provider "" is the stored one, or for a new service the one its address implies (inferProvider). A capability that is on needs its models.
type Op ¶
type Op struct {
ID int64
Kind, State string // Kind: flags, move or purge. State: pending, awaiting_claim, conflict or failed
Attempts int
LastError string
}
Op is a queued local change that has not reached the server yet, or could not.
type Options ¶
type Options struct {
DataDir string
AutoSync bool // run a background sync worker per account
// LabelMail runs the label classifier in the background (the apps set it;
// tests call it by hand or leave it off so their scripted models stay theirs).
LabelMail bool
// SystemLanguage is the operating system language (BCP 47) the GUI passes in; empty means "en".
SystemLanguage string
// ImageClient downloads remote mail images; nil is imagefetch.NewClient(false)
// (public hosts only). Tests give one that reaches loopback.
ImageClient *http.Client
// Registry is where reviewed plugins are listed; nil turns the plugin
// directory off (DefaultRegistry is Godwit's own). The apps set it.
Registry *RegistrySource
// AppVersion is this build's version, for a release's minGodwit; "" or "dev" takes any.
AppVersion string
}
Options configures a Service.
type OutboxItem ¶
OutboxItem is a message that has not finished sending and archiving. State is queued, sending, sent, archiving, send_uncertain, archive_uncertain or failed.
type PluginInfo ¶
type PluginInfo struct {
Name, Version string
Title plugins.Text // a built-in plugin's display name; others show Name
Builtin bool // ships with Godwit (builtins.go): a switch only
Description plugins.Text
Permissions plugins.Permissions
Enabled, NeedsGrant bool
DisabledReason, Error string
Config []plugins.ConfigField
// Native: a shared library, run with all of Godwit's rights (no
// permissions apply); its grant is for the file LibraryHash names.
Native bool
Trust string // native: "user" once the user allowed the current file, "" not allowed
Capabilities []string
LibraryHash string // native: SHA-256 of the shared library
}
PluginInfo is an installed plugin. Error is why it cannot run (its files are damaged or an update was interrupted); such a plugin is listed, not hidden.
type PluginInstallProgress ¶ added in v1.2.0
type PluginInstallProgress struct {
Stage string // "download", "verify", or "install"
Done, Total int64
}
PluginInstallProgress reports download bytes, then the verify and install stages. Done and Total are set only for download; completing it does not complete installation.
type Purge ¶
Purge is an account's junk or trash purge. Days 0 is never. Blocked is set while the server lacks UIDPLUS, so the purge is skipped.
type QuickReply ¶
type QuickReply struct{ Preview, HTML string }
QuickReply is one suggested reply: sanitized HTML and a plain-text preview.
type RegistryEntry ¶ added in v1.2.0
type RegistryEntry struct {
Name string
Title, Summary plugins.Text
Homepage string
Native, Script bool
RegistryEntry is one registry plugin for this build: Version is the release it would install ("" none, Unavailable says why: "platform", "abi" or "godwit:<min>"); Installed and InstalledTrust describe what is installed under its name; Update is a newer listed release for a listed install. Native and Script are its kind, neither when this build reads no release.
type RegistrySource ¶ added in v1.2.0
type RegistrySource struct {
URL string // registry.json; its signature is URL + ".sig"
PublicKey ed25519.PublicKey
Client *http.Client // nil: a client with registryTimeout
}
RegistrySource is where the registry comes from and the key it is signed with.
type RegistryView ¶ added in v1.2.0
type RegistryView struct {
On bool
Updated time.Time
Stale string
Entries []RegistryEntry
}
RegistryView is what the extensions page shows of the registry. Stale is why the last refresh failed ("" once one succeeds); the entries are then the cached registry's.
type RunActionOptions ¶
type RunActionOptions struct {
// ApproveEgress is the user's approval of the plugin's declared hosts
// (EgressApprovalRequired) for this one run.
ApproveEgress bool
}
type RunSpan ¶
RunSpan is the part of a conversation's Messages that run ID added, its question included: Messages[From:To]. A resume extends its run's span; a run that saved nothing (failed, cancelled while running) has none.
type SearchQuery ¶
type SearchQuery struct {
AccountID int64
Text string
From string // a substring of the From header, any case
Since, Until time.Time // the date from Since, before Until
HasAttachments bool
LabelID int64 // mail with this label on
}
SearchQuery is a search: free text ANDed with the filters set. Zero fields filter nothing; AccountID 0 is every account.
func (SearchQuery) Filtered ¶
func (q SearchQuery) Filtered() bool
Filtered reports whether a filter beyond the account is set: such a query needs no text.
type Selection ¶
Selection is a byte range [Start, End) of the draft's editable HTML (the first value mail.SplitDraft returns) at Revision. Neither end may fall inside a tag or a character reference.
type SendBlockedError ¶
type SendBlockedError struct{ Plugin, Message string }
SendBlockedError: a plugin refused the draft. It cannot be acknowledged; the user edits the draft or disables the plugin.
func (*SendBlockedError) Error ¶
func (e *SendBlockedError) Error() string
type SendCheck ¶
type SendCheck struct {
DraftID, Revision int64
Plugins []string
Warnings []SendWarning
Digest string
}
SendCheck is a draft revision's beforeSend outcome with warnings. Plugins are the checking plugins as name@source_hash@config_version, sorted by name. Digest binds all of it: SendAcknowledged(DraftID, Digest) queues that revision without checking again while the draft and the plugins are unchanged.
type SendWarning ¶
type SendWarning struct{ Plugin, Code, Message string }
SendWarning is a plugin's warning about a draft; the user may still send. Code is WarningPlugin (Message is the plugin's) or WarningNoResponse (the check failed or timed out; Message is a fallback in English).
type SendWarningsError ¶
type SendWarningsError struct{ Check SendCheck }
SendWarningsError: nothing was queued; show the warnings and call SendAcknowledged with Check.Digest to send anyway.
func (*SendWarningsError) Error ¶
func (e *SendWarningsError) Error() string
type ServerSettings ¶
type ServerSettings struct {
Username string
IMAPHost string
IMAPPort int
IMAPSecurity Security
SMTPHost string
SMTPPort int
SMTPSecurity Security
}
ServerSettings replaces an account's username and IMAP and SMTP servers. An empty Username means the email address.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service owns the database and event bus of one Godwit data directory.
func (*Service) AddAccount ¶
AddAccount tests in, stores the account and saves the password in the keychain. With OAuthFlowID it uses up the flow's grant and saves its refresh token instead.
func (*Service) AddAttachment ¶
func (s *Service) AddAttachment(ctx context.Context, draftID int64, srcPath string) (DraftAttachment, error)
AddAttachment copies the file at srcPath into the draft.
func (*Service) AddAttachmentAt ¶
func (s *Service) AddAttachmentAt(ctx context.Context, draftID, revision int64, srcPath string) (DraftAttachment, int64, error)
AddAttachmentAt is AddAttachment for exactly that revision of the draft (else ErrStaleDraft, nothing added); it returns the new revision.
func (*Service) AddMCPServer ¶
AddMCPServer adds a server, disabled and not granted.
func (*Service) AddModelService ¶
func (s *Service) AddModelService(ctx context.Context, in ModelServiceInput) (ModelService, error)
AddModelService stores the service, then its key in the keychain (entry 1); if the keychain fails the row is removed again. A crash between the two leaves a service without a key.
func (*Service) ApplyEditedProposal ¶
ApplyEditedProposal accepts a pending draft proposal with html, the editable part the user settled on in the GUI, in place of the proposed one: markers removed, sanitized, then applied like ResolveApproval (same revision check: a changed draft makes it stale, ErrStaleDraft).
func (*Service) Ask ¶
func (s *Service) Ask(ctx context.Context, conversationID int64, input string) (<-chan WitEvent, error)
Ask runs input in the "ask" conversation with the mailbox tools. Mail the tools show the model comes back as Citations on their tool_result events; create_draft calls become approvals. The first input titles the conversation. The channel ends with done, error or interrupted (see startRun).
func (*Service) AskWith ¶
func (s *Service) AskWith(ctx context.Context, conversationID int64, input string, quoted []int64) (<-chan WitEvent, error)
AskWith is Ask with the mail the user quoted (message IDs, at most maxQuoted after dedupe): the run reads it through mailContext, in its scope, and the model gets it before the question, cited like the tools' mail (a "context" event first). An ID that does not exist fails AskWith.
func (*Service) Assist ¶
Assist runs input in the draft's assist conversation. The model sees the draft's editable part, the email it replies to or forwards, the names of its attachments and the latest mail with its recipients; it can read mail and propose a new editable part (update_draft). A proposal for an empty draft is applied at once (see applyInitial); the others wait for the user. The channel ends with done, error or interrupted, as Ask's.
func (*Service) AssistSkill ¶
func (s *Service) AssistSkill(ctx context.Context, draftID int64, skill string, opts SkillOptions) (<-chan WitEvent, error)
AssistSkill runs a replace-draft skill (tone, length, proofreading, translate-draft) on the draft's editable part, or on opts.Selection of it if the skill runs on selections; the model sees that and nothing else. The skill has no tools, as every skill: the host turns its output into an update_draft proposal in the draft's assist conversation, which the user decides like any other (an empty draft's is applied at once). The conversation's history is left as it is. The channel streams the skill's text and ends with interrupted (the proposal) or error.
func (*Service) AssistWith ¶
func (s *Service) AssistWith(ctx context.Context, draftID int64, input string, quoted []int64) (<-chan WitEvent, error)
AssistWith is Assist with the mail the user quoted, as AskWith.
func (*Service) AttachmentCacheUsage ¶
AttachmentCacheUsage is the bytes the account's downloaded attachments take on disk.
func (*Service) AuditExternal ¶
AuditExternal writes an audit_log row for a call made from outside the app: source (AuditLocalAPI or AuditMCP), the method as action, and the target's ID (0 = none). No content is stored.
func (*Service) AwaitOAuth ¶
AwaitOAuth waits for the browser to come back and returns the signed-in email. The flow is over either way; on success its Grant stays in memory for grantTTL. Cancelling ctx cancels the flow.
func (*Service) BeginOAuth ¶
func (s *Service) BeginOAuth(ctx context.Context, providerID, loginHint string) (flowID, authURL string, err error)
BeginOAuth starts an authorization flow for the provider and returns its ID and the URL to open in the browser. The flow ends after auth.FlowTimeout.
func (*Service) CancelOAuth ¶
CancelOAuth ends the flow (a pending AwaitOAuth returns an error) and drops its grant. Unknown IDs are ignored.
func (*Service) CancelRun ¶
CancelRun ends a run when its panel closes. A run in flight is cancelled; an approved call executing outside the lock (external mode) is waited for; an interrupted one has its pending approvals rejected ("cancelled") and those results added to the conversation state without asking the model, so the conversation can take a new run. A run already over is left as it is.
func (*Service) CheckAccount ¶
func (s *Service) CheckAccount(ctx context.Context, in AccountInput) (CheckReport, error)
CheckAccount runs the settings, imap and smtp checks in order; after a failure the remaining steps are Skipped.
func (*Service) CheckModelService ¶
func (s *Service) CheckModelService(ctx context.Context, id int64, in ModelServiceInput) (ServiceCheck, error)
CheckModelService probes in as service id (0: a new one) would be saved, without saving: the key action decides the key, and a kept key never goes to a changed address or protocol (ErrKeyNeedsConfirm, no request).
func (*Service) ClearAttachmentCache ¶
ClearAttachmentCache deletes the account's downloaded attachments; opening one downloads it again. Other accounts' caches stay.
func (*Service) ClearImageCache ¶ added in v0.1.0
ClearImageCache deletes the cached remote images.
func (*Service) Close ¶
Close refuses new calls with ErrClosed, cancels the explicit network calls and background workers, waits for them (each records its outcome) and releases the database. Concurrent and repeated calls all wait for the same shutdown.
func (*Service) CreateLabel ¶ added in v0.3.0
CreateLabel adds a label at the end; its slug is "u" and its id.
func (*Service) Delete ¶
Delete moves the messages to their account's Trash; ones already there stay.
func (*Service) DeleteConversation ¶
DeleteConversation deletes the conversation with its runs and approvals. A run in flight or an approval executing makes it ErrRunActive; cancel first.
func (*Service) DeleteDraft ¶
DeleteDraft deletes the draft and its attachment files. A draft already queued is in the outbox, not here, and stays.
func (*Service) DeleteDraftIfEmpty ¶
func (s *Service) DeleteDraftIfEmpty(ctx context.Context, id, revision int64) (deleted bool, err error)
DeleteDraftIfEmpty deletes the draft, as DeleteDraft, if it is still at revision and holds nothing the user added: no attachments, no text outside the quote and the signature, and the addresses and subject a new draft of its mode starts with (none for a new one; a reply's own). A draft Wit is working on (an assist run active, or an approval pending) is in use, never empty. deleted reports whether it went.
func (*Service) DeleteLabel ¶ added in v0.3.0
DeleteLabel removes a label and takes it off every message.
func (*Service) DetectProvider ¶
func (s *Service) DetectProvider(ctx context.Context, email string) (auth.Provider, auth.Source, error)
DetectProvider finds the provider for an email address; DNS gets 5 seconds in total.
func (*Service) DraftFromQuickReply ¶
func (s *Service) DraftFromQuickReply(ctx context.Context, messageID int64, r QuickReply) (Draft, error)
DraftFromQuickReply starts a reply draft to messageID with r's HTML, sanitized again, at the start of the editable part, above the quote and signature.
func (*Service) FetchModels ¶
FetchModels lists the service's models, sorted. It saves nothing.
func (*Service) GetAttachment ¶
func (s *Service) GetAttachment(ctx context.Context, attachmentID int64) (string, AttachmentInfo, error)
GetAttachment returns the attachment's cached file, downloading it first if needed.
func (*Service) GetConversation ¶
GetConversation returns the conversation with its messages.
func (*Service) GetDraft ¶
GetDraft returns the draft with its attachments. HTML is sanitized again on read, covering rows stored before SaveDraft sanitized.
func (*Service) GetMessage ¶
GetMessage returns the message with sanitized HTML. Inline images are downloaded first if needed and embedded.
func (*Service) GetMessageText ¶
GetMessageText reads the message's stored text and metadata. Unlike GetMessage it processes no HTML and reads or downloads no attachment or inline image.
func (*Service) GetPluginConfig ¶
GetPluginConfig returns the plugin's settings in declaration order.
func (*Service) GetRawMessage ¶
GetRawMessage downloads the message's full original from the server, for a Truncated message or for saving. Messages over MaxMessageBytes give ErrTooLarge.
func (*Service) GetSettings ¶
GetSettings returns the stored settings, defaults for anything unset. Fields a newer build added are ignored.
func (*Service) GrantMCPServer ¶
GrantMCPServer grants the server's current version: it may then be started.
func (*Service) GrantPermission ¶
GrantPermission grants the plugin's current permissions.
func (*Service) ImageCache ¶ added in v0.1.0
func (s *Service) ImageCache() *imagecache.Cache
ImageCache is the shared disk cache of remote mail images, which the reader's image proxy serves from and prefetch fills.
func (*Service) ImageCacheSize ¶ added in v0.1.0
ImageCacheSize is the bytes the cached remote images take on disk.
func (*Service) ImagesAllowed ¶ added in v0.1.0
ImagesAllowed is whether message's remote images load without asking, by the RemoteImages setting: never in a junk folder (From is unauthenticated); "auto" otherwise; "trusted" for the trusted From addresses; "ask" never.
func (*Service) InlineSignatureImages ¶
func (s *Service) InlineSignatureImages(ctx context.Context, accountID int64, html string) (string, error)
InlineSignatureImages is html (sanitized compose HTML of a draft of the account) with its signature images as data: URLs, for showing only: never save it, as saving drops data: sources.
func (*Service) InstallPlugin ¶
InstallPlugin installs or updates the plugin in srcDir: it snapshots the directory, builds the snapshot (a plugin that does not build is not installed), moves it into a new version directory and points the row at it. An update with other permissions is disabled until they are granted; with the same ones a running plugin restarts on the new code, and is disabled if that fails.
func (*Service) InstallPluginFromRegistry ¶ added in v1.2.0
InstallPluginFromRegistry installs or updates plugin name from the cached registry: the newest release this build can take, its file downloaded and checked against the registry's size and SHA-256 (a mismatch is ErrRegistryMismatch and nothing is installed), then installed as listed.
func (*Service) InstallPluginFromRegistryWithProgress ¶ added in v1.2.0
func (s *Service) InstallPluginFromRegistryWithProgress(ctx context.Context, name string, progress func(PluginInstallProgress)) (PluginInfo, error)
InstallPluginFromRegistryWithProgress is InstallPluginFromRegistry with an optional callback invoked synchronously on the calling goroutine, never after return.
func (*Service) KeychainStatus ¶
KeychainStatus writes, reads back and deletes a fresh probe entry; any failure is ErrKeychainUnavailable. Onboarding calls it before showing the account form.
func (*Service) LabelModelReady ¶ added in v0.3.0
LabelModelReady reports whether a model can classify mail.
func (*Service) ListAccounts ¶
ListAccounts returns all accounts in creation order.
func (*Service) ListActions ¶
ListActions lists the running plugins' actions that run on kind (message, thread, selection or draft; "" for all), by ID.
func (*Service) ListApprovals ¶
ListApprovals returns the conversation's approvals by run and seq, so the cards survive a restart.
func (*Service) ListConversations ¶
ListConversations returns the conversations of kind, most recent first.
func (*Service) ListDrafts ¶
ListDrafts returns the account's drafts, most recently saved first.
func (*Service) ListFolders ¶
ListFolders returns the account's folders with their unread counts. Each role is on one folder at most, the one mailsync.RoleFolder resolves; inbox and Gmail's all, flagged and important are detected only.
func (*Service) ListLabels ¶ added in v0.3.0
ListLabels returns the labels in the user's order.
func (*Service) ListMCPServers ¶
ListMCPServers lists the configured servers by ID.
func (*Service) ListMessages ¶
func (s *Service) ListMessages(ctx context.Context, v View, cursor string, limit int) (MessagePage, error)
ListMessages lists the view's messages as flat rows, newest first.
func (*Service) ListModelServices ¶
func (s *Service) ListModelServices(ctx context.Context) ([]ModelService, error)
ListModelServices lists the services in the order they were added.
func (*Service) ListOutbox ¶
ListOutbox returns the account's unfinished outbox items, oldest first.
func (*Service) ListPluginRegistry ¶ added in v1.2.0
func (s *Service) ListPluginRegistry(ctx context.Context) (RegistryView, error)
ListPluginRegistry is the cached registry as this build sees it.
func (*Service) ListPlugins ¶
func (s *Service) ListPlugins(ctx context.Context) ([]PluginInfo, error)
ListPlugins lists the installed plugins, including ones that cannot run.
func (*Service) ListProviders ¶
func (*Service) ListSkills ¶
ListSkills lists built-in and user skills, including user skills that failed to load.
func (*Service) ListThreads ¶
func (s *Service) ListThreads(ctx context.Context, v View, cursor string, limit int) (ThreadPage, error)
ListThreads lists threads with at least one message in the view, newest first.
func (*Service) ListTranslators ¶ added in v1.2.0
func (s *Service) ListTranslators(ctx context.Context) ([]TranslatorInfo, error)
ListTranslators lists the model and the installed plugins declaring translate, by name.
func (*Service) LoadOlder ¶
LoadOlder imports one page (about 200) of the folder's mail that the sync range left out, newest first, and keeps it. more is false once the server holds nothing more the folder lacks. It takes the account's sync lock, so a sync runs before or after it, never alongside; cancelling ctx stops it.
func (*Service) MessageLabels ¶ added in v0.3.0
MessageLabels returns the labels on each of the messages, in the labels' order.
func (*Service) ModelServiceAvatar ¶ added in v1.1.0
ModelServiceAvatar is the favicon of the site a model service talks to; empty Data when it has none, or the service signs in with a subscription (those have a mark of their own) or runs on a local host.
func (*Service) Move ¶
Move moves the messages to folderID, which must belong to their account. The local message IDs stay the same.
func (*Service) MoveToRole ¶
MoveToRole moves the messages to their account's folder of role (trash, junk or archive); ones already there stay.
func (*Service) NewConversation ¶
func (s *Service) NewConversation(ctx context.Context, kind string, draftID int64) (Conversation, error)
NewConversation starts an empty conversation: kind "ask" without a draft, or "assist" on draftID.
func (*Service) NewDraft ¶
func (s *Service) NewDraft(ctx context.Context, accountID int64, mode string, sourceMessageID int64) (Draft, error)
NewDraft starts and saves a draft. reply and reply_all address the source's sender (and everyone, for reply_all) and quote it; forward quotes it and copies its non-inline attachments, downloading them if needed. The account signature ends the body.
func (*Service) PendingLabels ¶ added in v0.3.0
PendingLabels counts the rescan targets not classified yet.
func (*Service) PendingOps ¶
PendingOps lists the account's ops that are not done (or cancelled), oldest first.
func (*Service) PluginCards ¶
PluginCards runs each running plugin's card on the message, by plugin name: match(message), then render(message) if it matched, within one 5 s budget, read-only and with no egress. A failed, late or invalid card is left out and counts as a plugin failure.
func (*Service) PluginTags ¶ added in v1.5.0
PluginTags are the tags the plugins that are on put after the message's subject. Only built-in plugins contribute tags so far.
func (*Service) QuickReplies ¶
QuickReplies suggests up to three replies to a message with the default model. It returns none, without asking the model, when Settings.QuickReplies is off or the message is from the account itself. Results are cached like RunSkill's; an answer that is not the requested JSON is an error.
func (*Service) ReadingLanguage ¶
ReadingLanguage is the language Wit reads and writes in: the setting, else the UI language, else the system language, else "en".
func (*Service) Reauthorize ¶
Reauthorize gives an OAuth account the tokens of a finished flow, which must have signed in to the account's address with its provider (ErrWrongAccount, ErrProviderMismatch; the old tokens stay). It clears reauth_required and a paused outbox; the worker resumes.
func (*Service) RebuildSearchIndex ¶
RebuildSearchIndex recreates the full-text index from the messages table in one transaction, repairing an index that drifted or was damaged.
func (*Service) RecentSignInCodes ¶ added in v1.5.0
RecentSignInCodes reads the arrival log so a dropped UI event cannot lose a code. Initial imports and backfills never enter that log. Fifteen minutes is a display window, not a claim about the server's validity period. The arrival time bounds recency; a sender's clock running ahead does not hide a code. None while the built-in plugin is off.
func (*Service) RecordCapStatus ¶
func (s *Service) RecordCapStatus(ctx context.Context, id, version int64, c string, st CapStatus) error
RecordCapStatus stores st, a TestCapability result for capability c of what service id now is at version: the dialog tests before it saves.
func (*Service) Redact ¶
Redact replaces every credential and extension secret this Service knows of in text. Not for RPC. Values under 8 characters are skipped (ai.Redact): replacing them would mangle ordinary text, and the ones that matter (keys, tokens) are longer; a short password is a known gap, not leaked by core's own errors, which never carry credentials.
func (*Service) RefreshMCPTools ¶
RefreshMCPTools connects to the server again and lists its tools; a disabled server is disconnected afterwards. Needs the current version granted.
func (*Service) RefreshPluginRegistry ¶ added in v1.2.0
RefreshPluginRegistry fetches the registry, verifies it and, if it is not older than the cached one, caches it and applies it to the installed plugins: files it no longer lists stop (trust_revoked), and files the user allowed that it lists become listed. On any failure the cache and the plugins stay as they were.
func (*Service) RemoveAccount ¶
RemoveAccount deletes the account, its keychain entry and its cache directory. It first cancels the account's explicit calls and worker and waits for them.
func (*Service) RemoveAttachment ¶
RemoveAttachment deletes the attachment from the draft and its file.
func (*Service) RemoveAttachmentAt ¶
func (s *Service) RemoveAttachmentAt(ctx context.Context, draftID, attachmentID, revision int64) (int64, error)
RemoveAttachmentAt is RemoveAttachment for exactly that revision of the draft (else ErrStaleDraft, nothing removed); it returns the new revision.
func (*Service) RemoveMCPServer ¶
RemoveMCPServer stops a server and deletes it with its keychain entries; its pending approvals become stale.
func (*Service) RemoveModelService ¶
func (*Service) ReorderLabels ¶ added in v0.3.0
ReorderLabels puts the labels in the order of ids, which names every label once.
func (*Service) RescanLabels ¶ added in v0.3.0
RescanLabels makes the Inbox mail of the last days (0: all of it) the classifier's targets again: all of it, or only mail with no label on. Model labels are replaced only once the judge answers for that message, so a judge failing or a stop midway loses none; hand-set labels stay. It returns how many.
func (*Service) ResolveAll ¶
ResolveAll resolves the run's pending approvals one by one in seq order.
func (*Service) ResolveApproval ¶
ResolveApproval accepts or rejects a pending approval, exactly once: the call that claims it (pending → executing) decides it; any other gets ErrInvalidState. Accepting applies the recorded arguments and marks it done in one transaction, after checking the target draft's revision (changed → stale, ErrStaleDraft). An external tool's approval runs outside the lock instead and records its outcome afterwards (see decideExternal; a changed binding makes it stale, ErrStaleApproval). The call that ends the run's last open approval resumes the run in the background; SubscribeConversation streams it.
func (*Service) ResolveApprovalForConversation ¶
ResolveApprovalForConversation accepts pending approval id and allows its tool for the rest of its conversation (本次对话都允许): the run's other pending calls of the tool are accepted too, and later ones as soon as they come (applyInitial), audited auto:session. The tool and the conversation come from the approval. Only sessionTools qualify, else ErrNotGrantable.
func (*Service) ResolveOutbox ¶
ResolveOutbox decides an item in send_uncertain, archive_uncertain or failed: confirm_sent treats it as sent (it is archived next), resend queues it again and discard drops it.
func (*Service) RewriteSelection ¶
func (s *Service) RewriteSelection(ctx context.Context, draftID int64, sel Selection, instruction string) (<-chan WitEvent, error)
RewriteSelection rewrites sel of the draft's editable part as instruction says, in a new assist conversation of its own. The model gets only the selected HTML and up to 500 characters of read-only context on each side, and answers with update_selection; the proposal splices its HTML into the range, so nothing outside it can change. A sel made on another revision is ErrStaleDraft.
func (*Service) RunAction ¶
func (s *Service) RunAction(ctx context.Context, id string, t Target, opts RunActionOptions) (ActionResult, error)
RunAction runs action id (<plugin>/<id>) on t. The plugin gets {kind, id} and, for a selection, text: never other mail content (it reads that itself with mail:read). A plugin holding net that may hold mail content (mail:read, or a selection) returns *EgressApprovalRequired unless opts approves. A failed run or an invalid result counts as a plugin failure.
func (*Service) RunSkill ¶
RunSkill runs an enabled skill on t with no tools. The first event is "context": Text is a JSON list of {message_id, suspect} for the mail the model sees, so the UI can flag suspected prompt injection, and Model is the "slug/model" the run uses (skill godwit-model, else SmallModel for the small tier, else DefaultModel). message and thread runs are cached by everything that changes their output; a hit replays context, one text event and done without asking the model. The channel ends with exactly one of done or error and is closed after it; cancel ctx to stop early.
func (*Service) SaveDraft ¶
SaveDraft inserts d (ID 0) or updates its addresses, subject and body. The HTML is sanitized for composing (no scripts, handlers or remote resources). Attachments are changed with AddAttachment and RemoveAttachment.
func (*Service) Search ¶
func (s *Service) Search(ctx context.Context, accountID int64, query string, limit int) ([]MessageSummary, error)
Search finds synced messages; accountID 0 searches every account.
func (*Service) SearchWith ¶
func (s *Service) SearchWith(ctx context.Context, q SearchQuery, limit int) ([]MessageSummary, error)
SearchWith finds synced messages matching q, newest first. A query with neither text nor a filter finds nothing.
func (*Service) Send ¶
Send moves the draft into the outbox; the next sync submits it. Nothing is sent and the draft stays when validation or building fails. Plugins' message.beforeSend handlers check it first (hooks.go): a block returns *SendBlockedError, warnings *SendWarningsError (see SendAcknowledged). A draft changed during the checks is checked again; changed twice in a row, Send returns ErrStaleDraft.
func (*Service) SendAcknowledged ¶
SendAcknowledged sends the draft despite the warnings of the check with digest: if the draft's revision and the checking plugins are still the checked ones it is queued without checking again; otherwise (or with no such check, e.g. expired) it is a plain Send, which may warn again. A block has no check, so it can never be acknowledged.
func (*Service) SendAcknowledgedRevision ¶
func (s *Service) SendAcknowledgedRevision(ctx context.Context, draftID, revision int64, digest string) error
SendAcknowledgedRevision is SendAcknowledged for exactly that revision of the draft: if the stored one differs, nothing is sent and the error is ErrStaleDraft.
func (*Service) SendRevision ¶
SendRevision is Send for exactly that revision of the draft: if the stored one differs, nothing is sent and the error is ErrStaleDraft.
func (*Service) SenderAvatar ¶ added in v0.3.0
func (s *Service) SenderAvatar(ctx context.Context, messageID int64, allowRemote bool) (Avatar, error)
SenderAvatar loads the ordinary sender avatar under the current message's remote-image policy. allowRemote is the user's explicit permission for this message. Missing or unavailable sources are normal empty results.
func (*Service) SetDraftAccount ¶
func (s *Service) SetDraftAccount(ctx context.Context, id, accountID, revision int64) (Draft, error)
SetDraftAccount moves the draft to accountID: the body's signature becomes that account's, attachments and the reply's source stay, and the revision grows by one. revision must be the stored one (ErrStaleDraft).
func (*Service) SetFlags ¶
SetFlags adds then removes flags on the messages locally and queues the change for the server.
func (*Service) SetLabel ¶ added in v0.3.0
SetLabel puts the label on the messages (on) or takes it off, by hand: the classifier leaves these rows alone from then on. All or none are written.
func (*Service) SetMCPServerEnabled ¶
SetMCPServerEnabled starts (connects and lists tools) or stops a server. Starting needs its current version granted (ErrNeedsGrant).
func (*Service) SetMCPToolTrusted ¶
SetMCPToolTrusted trusts (or stops trusting) a tool as listed now: trust is bound to its definition hash, so any change to the definition ends it.
func (*Service) SetNativeHostForTest ¶ added in v1.2.0
SetNativeHostForTest adds env to the environment of native plugins' processes. Tests only: with coretest.NativeChildEnv the test binary serves as plugin-host. Call it right after New, before any plugin starts.
func (*Service) SetPluginConfig ¶
func (s *Service) SetPluginConfig(ctx context.Context, name string, values map[string]json.RawMessage) error
SetPluginConfig saves the settings form. Non-secret fields take the given value; absent, null or "" unsets one (its default applies). A secret absent or "" keeps its value and null clears it. Fields their when hides are ignored and keep what they had. Nothing is written unless every shown field is valid and every shown required one has a value; a write bumps config_version.
func (*Service) SetPluginEnabled ¶
SetPluginEnabled starts or stops a plugin. Starting needs its current permissions granted (ErrNeedsGrant) and intact files; it resets the failure count.
func (*Service) SetPluginNetForTest ¶
func (s *Service) SetPluginNetForTest(n plugins.NetOptions)
SetPluginNetForTest replaces the network plugins and MCP servers over HTTP use (resolver, dialer, plain HTTP and loopback allowed or not). Tests only: it lets fixture plugins reach a local server. Call it right after New, before any plugin or MCP server starts.
func (*Service) SetPurge ¶
SetPurge sets how many days mail stays in the account's junk or trash folder before it is expunged on the server; 0 is never. Any change restarts the clock: only mail that stays that long from now on is purged.
func (*Service) SetRoleFolder ¶
func (s *Service) SetRoleFolder(ctx context.Context, accountID int64, role string, folderID int64) error
SetRoleFolder gives role (drafts, sent, junk, trash or archive) to the folder; 0 leaves the account without a folder of the role. The choice survives sync; once the folder is gone the role follows detection again. INBOX takes no role, and a folder holding another role cannot take this one (junk and trash would purge its mail): that role moves elsewhere first.
func (*Service) SetSettings ¶
SetSettings validates and stores st, then announces settings.changed.
func (*Service) SetSkillEnabled ¶
SetSkillEnabled turns a skill on or off.
func (*Service) SignatureEditor ¶
SignatureEditor is the account's signature as the settings editor's HTML: sanitized, a plain one escaped into a paragraph, its images as data: URLs.
func (*Service) SignatureImageURLs ¶
func (s *Service) SignatureImageURLs(ctx context.Context, accountID int64, html string) ([]string, error)
SignatureImageURLs are the data: URLs of the images html shows, in order: the compose page's read-only signature preview.
func (*Service) StopRescan ¶ added in v0.3.0
StopRescan gives up on the rescan targets not classified yet.
func (*Service) SubscribeConversation ¶
SubscribeConversation streams the events of the conversation's runs, including resumes after approvals, until the returned func is called or the Service closes; either closes the channel and discards what is still queued. A slow reader loses the oldest text but never an event that ends a run. After Close the channel is closed.
func (*Service) SyncNow ¶
SyncNow connects to the account's IMAP server, pushes queued local changes, sends and files the outbox, and fetches new mail. Calls for the same account run one at a time. Afterwards the background worker is woken; if it was parked on reauth_required and this call logged in, it resumes.
func (*Service) TaskModel ¶
TaskModel is the "slug/model" skill runs on (quick replies when skill is ""), resolved as RunSkill and QuickReplies resolve it, without running it. ErrAINotConfigured, ErrModelServiceNotFound or ErrModelNotFound: it has none.
func (*Service) TestAccount ¶
func (s *Service) TestAccount(ctx context.Context, in AccountInput) error
TestAccount runs the connection check; a failure is a *CheckError.
func (*Service) TestCapability ¶
func (s *Service) TestCapability(ctx context.Context, id int64, in ModelServiceInput, c string) (CapStatus, error)
TestCapability tests capability c (CapGen, CapJudge) of in as service id (0: a new one) would be saved, without saving it: generate runs the shortest real generation on its first model (or the first one it lists), judge asks a yes/no about a fixed sample. A failed test returns its status and the error; an invalid in returns no status. When in is service id as saved (same address, stored key, and format), the status is stored, unless the service changed while the test ran.
func (*Service) ThreadLabels ¶ added in v0.3.0
func (s *Service) ThreadLabels(ctx context.Context, threadIDs []int64) (map[int64][]AppliedLabel, error)
ThreadLabels returns the labels on any message of each thread, in the labels' order.
func (*Service) TrustImageSender ¶
TrustImageSender trusts the address of from (a From header) to load remote images; from must parse as an address.
func (*Service) UndoLastAssist ¶
UndoLastAssist puts back the editable part the draft's latest applied proposal (by approval ID, not by clock) replaced. ErrInvalidState: there is none, or the draft changed since it was written (an undo counts as a change).
func (*Service) UninstallPlugin ¶
UninstallPlugin stops the plugin and removes its row (with its config, storage and cursor) and its files.
func (*Service) UntrustImageSender ¶
UntrustImageSender stops trusting addr.
func (*Service) UpdateAccount ¶
UpdateAccount writes p's fields in one transaction. New Servers are first checked with the stored credentials (a failure is a *CheckError and nothing is saved). IsDefault true makes the account the only default; false fails on the default account, as one account is always the default. Sync is a Limit of 1–100000, Months of 1–120, or neither (all).
func (*Service) UpdateLabel ¶ added in v0.3.0
UpdateLabel changes a label's name, description, color and icon; its slug stays.
func (*Service) UpdateMCPServer ¶
func (s *Service) UpdateMCPServer(ctx context.Context, id int64, in MCPServerInput) (MCPServer, error)
UpdateMCPServer changes a server: its version goes up, its connection closes, its grant and tool trust are cleared, it is disabled, and its pending approvals become stale.
func (*Service) UpdateModelService ¶
func (s *Service) UpdateModelService(ctx context.Context, id int64, in ModelServiceInput) (ModelService, error)
UpdateModelService replaces the service's fields, applies the key action and bumps its version. A new key goes to a new keychain entry first; then one transaction switches the address and the entry together; then the old entry is deleted. A crash at any point never pairs a key with an address it was not saved for: the row names the old entry or the new one, never a half-written one, and the next start deletes the other (sweepModelKeys).
func (*Service) UpdatePassword ¶
UpdatePassword checks password against the account's servers and, if both accept it, saves it and clears reauth_required and a paused outbox; the worker resumes and the outbox sends in its next round. A failed check is a *CheckError and leaves the keychain unchanged.
type ServiceCheck ¶
type ServiceCheck struct {
BaseURL, Endpoint string
Models []string
Names map[string]string // model ID -> display name, for the IDs the service names
ListSupported bool // false: the service has no model list; models are typed by hand
NoListStatus int // the HTTP status that said so, when known
JudgeEndpoint string
JudgeModels []string // nil until there is a key, except for ProviderOther
}
ServiceCheck is what probing a service before saving found. Endpoint and Models are generate's ("" and nil when it is off); JudgeEndpoint and JudgeModels judge's.
type Settings ¶
type Settings struct {
Theme, Density string
FontSize, BodyFontSize int // BodyFontSize 0 follows FontSize
UILanguage, ReadingLanguage, ReplyLanguage string
NoTranslate []string
LaunchAtLogin, KeepInBackground, UnreadInMenuBar bool
UnreadOnAppIcon bool
NotifyNewMail, NotifySmartOnly, NotifyPreview bool
QuickReplies, Summary, ThreadView bool
DefaultModel, SmallModel string
// Translator is the reader's translation channel: "" the model, or
// "plugin/<name>" a plugin declaring translate (ListTranslators).
Translator string
// JudgeService is the slug of the service whose judge answers typed
// questions; "" (or one gone or with judge off): the DefaultModel does.
JudgeService string
// JudgeThreshold is the minimum predicate probability treated as yes by
// app features, from MinJudgeThreshold to MaxJudgeThreshold. Raw judge
// answers keep their probabilities.
JudgeThreshold float64
LocalAPI bool // the GUI serves the Local API; off by default
// AutoLabel lets the classifier label new Inbox mail; on by default.
// A rescan runs either way.
AutoLabel bool
// SidebarWidth is the page sidebars' width in DIPs, the user's drag:
// 0 for the default, else 240 to 480.
SidebarWidth int
// ListWidth is the mail list's width in DIPs, the user's drag: 0 for the
// default, else 280 to 560.
ListWidth int
// TrustedImageSenders are the lower-cased From addresses whose remote
// images load at once (始终信任此发件人). Only TrustImageSender and
// UntrustImageSender change it; SetSettings keeps the stored list.
TrustedImageSenders []string
// RemoteImages is when a message's remote images and sender avatars load, through the image
// proxy: "auto" (default, "" too) at once, "trusted" for the trusted
// senders only, "ask" after 加载图片. Mail in Junk never loads them by itself.
RemoteImages string
// DisabledBuiltins are the built-in plugins the user switched off; every
// other one is on. Only SetPluginEnabled changes it; SetSettings keeps
// the stored list.
DisabledBuiltins []string
// SettingsVersion is 2 once the default text grew from 13 to 14 px and a
// stored FontSize was raised by one to keep its sizes; 3 once a stored
// BodyFontSize of 14, the old default, became 0 (follow FontSize).
SettingsVersion int
}
Settings are the app-wide preferences, stored as one JSON row. ReplyLanguage is "match" (the mail's language) or "reading".
type SignInCode ¶ added in v1.5.0
type SignInCode struct {
MessageID int64
Code, Link, From string
LinkKind string // what Link does: mail.LinkSignIn, LinkConfirm or LinkReset
ReceivedAt time.Time
}
SignInCode is a locally extracted sign-in code or sign-in link (or both) from a recent inbox arrival.
type SkillOptions ¶
SkillOptions are AssistSkill's options. Selection, if set, limits the skill to that range; TargetLanguage is translate-draft's target (empty: the reading language).
type SyncRange ¶
type SyncRange struct{ Limit, Months int }
SyncRange is how much of each folder a sync fetches: the newest Limit messages, the mail of the last Months months, or (both 0) all of it. Narrowing it only stops fetching older mail; nothing stored is deleted.
type Tag ¶ added in v1.5.0
Tag is a plugin's small action shown right after a message's subject: copy a value (Kind "copy") or open a link ("open-url"). Text is what the tag shows (a code; a link's host), Value what it copies or opens. A built-in plugin's Label is a key the app words ("signin", "confirm", "reset" for a link); a copy tag needs none.
type Target ¶
type Target struct {
Kind string
ID int64
Text string
// PreserveHTML translates message text nodes for the reader, without rewriting markup.
PreserveHTML bool
}
Target is what a skill runs on: message, thread, selection (ID is the message the text was selected in) or draft.
type Thread ¶
type Thread struct {
ID int64
Subject string
Messages []MessageSummary
}
Thread is a conversation with its messages, oldest first.
type ThreadPage ¶
type ThreadPage struct {
Items []ThreadSummary
NextCursor string
}
ThreadPage is one page of threads.
type ThreadSummary ¶
type ThreadSummary struct {
ID int64
Subject, Snippet string
Participants []string
Count, Unread int
Flagged int // messages starred
LastDate time.Time
HasAttachments bool
}
ThreadSummary is a conversation as listed. Count, Unread and Flagged cover the whole thread.
type TranslatorInfo ¶ added in v1.2.0
TranslatorInfo is a translation channel: ID "" is the model, else "plugin/<name>" for an installed plugin declaring translate.
type View ¶
View selects what a list shows: one folder, a unified view ("inbox", "starred") or one label's mail across accounts. Exactly one is set.
Source Files
¶
- accounts.go
- actions.go
- aiservice.go
- approvals.go
- assist.go
- attachments.go
- avatars.go
- bodytranslation.go
- builtins.go
- cache.go
- check.go
- compose.go
- conversations.go
- credentials.go
- devsync.go
- drafts_extra.go
- extensions.go
- external.go
- hooks.go
- images.go
- labeler.go
- labels.go
- mailbox.go
- mailcontext.go
- mcp.go
- mcp_conn.go
- mcp_proc.go
- mcp_secrets.go
- mcp_tools.go
- mcp_unix.go
- messages.go
- messagetext.go
- models.go
- models_avatar.go
- models_check.go
- models_oauth.go
- models_slug.go
- models_token.go
- oauth.go
- older.go
- outbox.go
- pluginhost.go
- readattachment.go
- registry.go
- secrets.go
- service.go
- settings.go
- signature_images.go
- signincodes.go
- skills.go
- threads.go
- translators.go
- types.go
- wit.go
- worker.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ai talks to model services.
|
Package ai talks to model services. |
|
Package auth holds the provider table and account auto-detection.
|
Package auth holds the provider table and account auto-detection. |
|
Package conn dials and authenticates IMAP and SMTP connections.
|
Package conn dials and authenticates IMAP and SMTP connections. |
|
Package coretest is a real core.Service for tests outside core: a mocked keychain, fake IMAP / SMTP servers per account, a fake model service, a fake MCP server and fixture plugins, all on this machine.
|
Package coretest is a real core.Service for tests outside core: a mocked keychain, fake IMAP / SMTP servers per account, a fake model service, a fake MCP server and fixture plugins, all on this machine. |
|
Package events is a lossy in-process event bus for UI notifications.
|
Package events is a lossy in-process event bus for UI notifications. |
|
Package gateway decides whether an AI tool call may run, needs approval, or is denied, and audits every decision.
|
Package gateway decides whether an AI tool call may run, needs approval, or is denied, and audits every decision. |
|
internal
|
|
|
testllm
Package testllm is a fake model service for tests: the model-list endpoint and a scripted, streaming chat endpoint for each protocol (openai, openai-responses, anthropic).
|
Package testllm is a fake model service for tests: the model-list endpoint and a scripted, streaming chat endpoint for each protocol (openai, openai-responses, anthropic). |
|
testmail
Package testmail provides in-memory IMAP and SMTP servers for tests.
|
Package testmail provides in-memory IMAP and SMTP servers for tests. |
|
testoauth
Package testoauth is a fake OAuth 2.0 authorization and token server for tests, with a stand-in for the user's browser.
|
Package testoauth is a fake OAuth 2.0 authorization and token server for tests, with a stand-in for the user's browser. |
|
Package mail parses MIME messages and sanitizes HTML bodies.
|
Package mail parses MIME messages and sanitizes HTML bodies. |
|
Package mailsync pulls folders and messages from IMAP into the store.
|
Package mailsync pulls folders and messages from IMAP into the store. |
|
Package plugins runs third-party TypeScript plugins (spec 5.3–5.5): manifest validation, the sandbox and the ctx API.
|
Package plugins runs third-party TypeScript plugins (spec 5.3–5.5): manifest validation, the sandbox and the ctx API. |
|
Package send submits messages over SMTP.
|
Package send submits messages over SMTP. |
|
Package skills loads SKILL.md directories (Agent Skills standard).
|
Package skills loads SKILL.md directories (Agent Skills standard). |
|
Package store is Godwit's SQLite storage layer.
|
Package store is Godwit's SQLite storage layer. |