hermes

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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

func ParseLabels(kv []string) (map[string]string, error)

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 Skill

func Skill(notes string) []byte

Skill returns the skill text, with the deployment notes appended.

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).

func WriteIfChanged

func WriteIfChanged(path string, data []byte, mode os.FileMode) (bool, error)

WriteIfChanged writes data to path atomically unless it already holds exactly that, creating parent directories (0755).

Types

type ConfigOptions

type ConfigOptions struct {
	RouteName string
	CronJob   string
	Port      int
}

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

func DefaultCronJob() (CronJob, error)

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.

Jump to

Keyboard shortcuts

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