Documentation
¶
Overview ¶
Package hermes connects email to a Hermes agent: it writes the skill and the webhook route script into HERMES_HOME, seeds the triage cron job through the `hermes` CLI, and renders the watch service and the config.yaml snippet. Hermes itself is never modified beyond those files (docs/hermes.md).
Index ¶
- Constants
- func ConfigSnippet(o ConfigOptions) string
- func LaunchdPlist(o ServiceOptions) string
- func ParseLabels(kv []string) (map[string]string, error)
- func RouteSettings(o FilesOptions) ([]byte, error)
- func Skill(notes string) []byte
- func SystemdUnit(o ServiceOptions) string
- func WriteIfChanged(path string, data []byte, mode os.FileMode) (bool, error)
- type ConfigOptions
- type CronJob
- type FileResult
- type FilesOptions
- type SeedOptions
- type SeedResult
- type ServiceOptions
Constants ¶
const ( SkillPath = "skills/comms/email/SKILL.md" RouteScriptPath = "scripts/email-summary.py" RouteSettingsPath = "scripts/email-summary.json" DefaultRouteName = "email" DefaultWebhookPort = 8644 )
Paths inside HERMES_HOME.
const ( SystemdUnitName = "email-watch.service" LaunchdLabel = "io.github.james-tronai.email-watch" NotifyTokenEnv = "EMAIL_WATCH_NOTIFY_TOKEN" )
Service names.
Variables ¶
This section is empty.
Functions ¶
func ConfigSnippet ¶
func ConfigSnippet(o ConfigOptions) string
ConfigSnippet is what goes into $HERMES_HOME/config.yaml. Hermes has no way for a tool to change its config, so the user merges it by hand.
func LaunchdPlist ¶
func LaunchdPlist(o ServiceOptions) string
LaunchdPlist is a launchd user agent. launchd has no EnvironmentFile, so watch reads the token file itself (--notify-token-file).
func ParseLabels ¶
ParseLabels turns ["work=Work mailbox", …] into a map.
func RouteSettings ¶
func RouteSettings(o FilesOptions) ([]byte, error)
RouteSettings is email-summary.json, or nil when there is nothing to say.
func SystemdUnit ¶
func SystemdUnit(o ServiceOptions) string
SystemdUnit is a systemd user unit. The token comes from EnvironmentFile; the home directory is read-only except for the state directory and the account directories (Microsoft 365 and Gmail refresh their tokens there).
Types ¶
type ConfigOptions ¶
ConfigOptions shape the Hermes config.yaml snippet.
type CronJob ¶
type CronJob struct {
Name string `json:"name"`
Schedule string `json:"schedule"`
Skills []string `json:"skills"`
Continuity bool `json:"continuity"`
Prompt string `json:"prompt"`
}
CronJob is contrib/hermes/cron-email-triage.json.
func DefaultCronJob ¶
DefaultCronJob is the released triage job.
type FileResult ¶
type FileResult struct {
Path string `json:"path"`
Changed bool `json:"changed"`
Removed bool `json:"removed,omitempty"`
}
FileResult reports one written file.
func WriteFiles ¶
func WriteFiles(home string, o FilesOptions) ([]FileResult, error)
WriteFiles writes the skill, the route script and its settings into home. Files are replaced atomically and only when their content changes; the released files win over local edits. Without settings, an existing email-summary.json is removed so that a value taken out of the deployment does not linger.
type FilesOptions ¶
type FilesOptions struct {
// Notes are appended to the skill as "## This deployment": accounts,
// house rules, language. The skill's own rules are not changed.
Notes string
// Timezone and Labels go to email-summary.json for the route script.
Timezone string
Labels map[string]string
}
FilesOptions customise what `email hermes files` writes.
type SeedOptions ¶
type SeedOptions struct {
Home string // HERMES_HOME
HermesBin string // the `hermes` CLI
Deliver string // platform:chat_id, origin, local, …
Job CronJob
DryRun bool
// Run executes the hermes CLI; tests replace it.
Run func(ctx context.Context, bin string, args, env []string) (string, error)
}
SeedOptions drive SeedCron.
type SeedResult ¶
type SeedResult struct {
Action string `json:"action"` // created | updated | unchanged
JobID string `json:"job_id,omitempty"`
Name string `json:"name"`
Changed []string `json:"changed,omitempty"`
Paused bool `json:"paused,omitempty"`
DryRun bool `json:"dry_run,omitempty"`
// Command is the hermes command line, with the prompt elided.
Command []string `json:"command,omitempty"`
}
SeedResult says what SeedCron did.
func SeedCron ¶
func SeedCron(ctx context.Context, o SeedOptions) (*SeedResult, error)
SeedCron creates the job, or edits the job of that name so that it matches. A job that matches already is left alone (editing would move its next run), and a job the user paused stays paused.
type ServiceOptions ¶
type ServiceOptions struct {
Bin string // absolute path of the email binary
Accounts []string // -a; empty = every account
NotifyURL string
TokenFile string // KEY=VALUE file holding EMAIL_WATCH_NOTIFY_TOKEN (0600)
ConfigDir string
StateDir string
PolicyFile string // empty = <config dir>/policy.toml
HealthAddr string
LogPath string // launchd only
}
ServiceOptions describe the `email watch` service for a single host.