Documentation
¶
Overview ¶
Package tomte builds small agents that do one job. An agent is a Go program: it declares its instructions, model, tools and channel, and compiles to one binary. See docs/design.md.
Index ¶
- Variables
- func StateDir() string
- type Agent
- type Channel
- type Incoming
- type Message
- type Option
- func Command(name, description string, fn func(context.Context, Request) (string, error)) Option
- func Cron(spec, task string) Option
- func Instructions(s string) Option
- func Job(spec, name string, fn func(context.Context) (string, error)) Option
- func Log(path string) Option
- func MaxCost(perRun, perDay float64) Option
- func MaxSteps(n int) Option
- func Model(baseURL, name, key string) Option
- func Price(in, out float64) Option
- func ReadsJournal() Option
- func SendTo(cs ...Channel) Option
- func Tool[In, Out any](name, description string, fn func(context.Context, In) (Out, error)) Option
- type Receiver
- type Request
- type Result
- type Usage
Constants ¶
This section is empty.
Variables ¶
var ( ErrCostLimit = errors.New("cost limit reached") ErrDailyLimit = errors.New("daily cost limit reached") )
var ErrStepLimit = errors.New("step limit reached")
ErrStepLimit is returned when a run uses all its steps without replying.
Functions ¶
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func New ¶
New declares an agent. Mistakes in the options are reported when it runs, so the declaration reads as one expression.
type Incoming ¶
Incoming is a message someone wrote to the agent. From is the sender in the channel's own terms; a Message To them answers it.
type Message ¶
Message is what an agent sends: markdown text, from the named agent. To is who gets it, in the channel's own terms (a Telegram chat id); a channel sends a message without one to its usual recipient.
type Option ¶
type Option func(*Agent)
func Command ¶
Command answers "/name …" sent to the agent through its channel, while it's serving. What fn returns goes back to the sender unless it's empty or NOTHING. An error is logged, and the sender only hears it didn't work: errors are written for whoever runs the agent, not for strangers.
func Instructions ¶
Instructions is the agent's system prompt: who it is and what its job is.
func Job ¶
Job runs fn on a schedule while the agent is serving, and from the command line with `run <name>`. What fn returns is sent through the channel unless it's empty or NOTHING; an error is sent as a failure.
func Log ¶
Log sets the file the run log is appended to. It's <name>.jsonl in $STATE_DIRECTORY (set by systemd's StateDirectory=) or else in the working directory.
func MaxCost ¶
MaxCost limits what the agent spends, in dollars, per run and per day (local time). Zero means no limit. It needs Price.
func Model ¶
Model sets the OpenAI-compatible API the agent thinks with, for example Model("https://openrouter.ai/api/v1", "z-ai/glm-4.6", os.Getenv("MODEL_KEY")).
func Price ¶
Price is what the model costs, in dollars per million input and output tokens, as the provider lists it. Runs are priced only when it's given.
func ReadsJournal ¶
func ReadsJournal() Option
ReadsJournal lets the agent read the system journal, sshd's and sudo's lines included, when it's deployed with the tomte command: its user joins the systemd-journal group. Nothing else changes.
type Receiver ¶
Receiver is a channel people can write to. Receive calls handle with each message until ctx is done, and returns then, or earlier when receiving can't work at all. handle may wait while the agent is busy.
type Request ¶
type Request struct {
From string // the sender, in the channel's terms: a Telegram chat id
Args string // what followed the command's name, trimmed
}
Request is a command someone sent.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
channels
|
|
|
telegram
Package telegram sends an agent's results to a Telegram chat through a bot.
|
Package telegram sends an agent's results to a Telegram chat through a bot. |
|
telekinesis
Package telekinesis sends an agent's results to a person through telekinesis (https://telekinesis.berkay.tools), which shows them in its web app with a push notification.
|
Package telekinesis sends an agent's results to a person through telekinesis (https://telekinesis.berkay.tools), which shows them in its web app with a push notification. |
|
cmd
|
|
|
tomte
command
Command tomte deploys and watches Tomte agents on a machine over ssh.
|
Command tomte deploys and watches Tomte agents on a machine over ssh. |
|
examples
|
|
|
dice
command
Dice is the smallest useful tomte: it rolls dice when asked.
|
Dice is the smallest useful tomte: it rolls dice when asked. |
|
hn-digest
command
HN digest sends a short morning digest of the Hacker News stories that match your interests to telekinesis.
|
HN digest sends a short morning digest of the Hacker News stories that match your interests to telekinesis. |
|
ssh-watch
command
SSH watch tells you on Telegram when someone logs in to this machine over ssh as a user, from an address or with a key it hasn't seen before.
|
SSH watch tells you on Telegram when someone logs in to this machine over ssh as a user, from an address or with a key it hasn't seen before. |