Skip to content

thrum (Go)

the thrum client for a bee written in Go

A Go bee reaches humd through hum’s own client. Bee runs hum bee link, which enters the bee, signs its hello, reads humd’s verdict, reconnects when humd restarts, and checks every tone against the thrum. Every language gets that same client, so a Go bee behaves exactly as a Rust, TS, Python or C one.

bee := thrum.NewBee(thrum.Options{Hive: "my-hive", As: "main", Role: thrum.RoleNurse,
Hello: map[string]any{"models": []string{"my-model"}}})
bee.On(thrum.ChiPrompt, func(tone thrum.Tone) {
_ = bee.Send(thrum.Tone{"chi": thrum.ChiUnfurl, "sid": tone["sid"], "petal": 0, "kind": thrum.PetalKindText, "text": "hello"})
_ = bee.Send(thrum.Tone{"chi": thrum.ChiWilt, "sid": tone["sid"], "reason": "stop"})
})
if err := bee.Start(ctx); err != nil {
log.Fatal(err)
}
log.Fatal(bee.Wait())
NewBee(Options{Hive, As, Role, Hello})a bee’s client; nothing runs until Start
On(chi, fn), OnSid(sid, fn), OffSid(sid), OnAny(fn)a tone goes to its sid’s handler, else its chi’s, else OnAny
OnNestled(fn), OnAstray(fn), OnAdvisory(fn)humd admitted the bee; humd went away; something to fix
Start(ctx)returns once humd admits the bee, or *Refused, or *LinkError
Send(tone), Hello(patch)send a tone, given a rid if it has none; change the hello
Close(), Wait()close the link; how the link ended

hum is found at $HUM_CLI, else on PATH, else ~/.local/bin/hum.

Every source under thrum/ but the tests is generated by cargo run -p codegen: chi.go and protocol.go from thrum-core, link.go from codegen/templates/go with the link’s constants from hum-thrum. examples/echo_bee is the bee the conformance run (cargo test -p hum --test conform) drives in every language.