folders

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 17 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

Index

Constants

View Source
const (
	Manifest = "HOOK.yaml"
	Root     = "hooks"
)

File a hook folder declares its hook in, and the folder of hook folders inside a profile's folder and inside the folder every profile shares

View Source
const (
	Timeout    = 60
	MaxTimeout = 300
)

Seconds the command of a folder may take when its HOOK.yaml gives none, and the most it may take

View Source
const (
	GatewayStartup  = "gateway:startup"
	SessionStart    = "session:start"
	SessionEnd      = "session:end"
	SessionReset    = "session:reset"
	AgentStart      = "agent:start"
	AgentStep       = "agent:step"
	AgentEnd        = "agent:end"
	ReactionAdded   = "reaction:added"
	ReactionRemoved = "reaction:removed"
	SessionCompress = "session:compress"
	LoginExhausted  = "login:exhausted"
	// Start of the event of a slash command, the command's name after it
	CommandOf = "command:"
)

Events of a hook folder as its HOOK.yaml names them

View Source
const (
	Deny    = "deny"
	Handled = "handled"
	Rewrite = "rewrite"
)

What the hook of a slash command may answer

Variables

View Source
var ErrNone = errors.New("The folder holds no " + Manifest + ".")

A folder of hook folders holds no HOOK.yaml there, so it is no hook folder

Functions

func Context

func Context(fired string, fields map[string]any, chat Chat) map[string]any

The context the event of hook folders carries, made from the fields of the point's event as JSON and the chat the session talks in

func Events

func Events() []string

Every event of a folder, in the order a person is shown them, the command of a slash command written with an example name

func Fired

func Fired(point string, fields map[string]any) (string, bool)

Event of hook folders a firing of the point is, by the fields the point's event holds as JSON: none for a firing that is none of theirs, such as a model request sent again or something a chat app told that is no reaction

Types

type Chat

type Chat struct {
	Platform, User, ID, Thread string
	// Direct, Group or Channel, as icebath names the kinds of chats
	Kind string
}

Where the session a firing names talks, as the events of hook folders tell it: the app, who last wrote there, the chat and its thread and kind; empty for a session no chat talks to

type Decision

type Decision struct {
	// Deny, Handled or Rewrite; empty for an answer that decides nothing
	Verb string
	// What the person is told, empty when the hook said nothing
	Message string
	// Command and the words after it a rewrite turns the command into, the command without its slash
	Command, Args string
}

What the hook of a slash command answered, as hook folders answer it

func Decide

func Decide(answer map[string]any) Decision

What the answer of the hook of a slash command decides: deny, handled or rewrite by its decision, a rewrite naming no command deciding nothing

type Event

type Event struct {
	// As its HOOK.yaml names it: an event of hook folders, one that stands for every event of a part such as agent:*, or a hook point of
	// icebath by its own name
	Name string
	// Hook points it is heard on
	Points []string
	// An event of hook folders, whose command reads the event as hook folders write it and answers as they do; false for a hook point named
	// by its own name, whose command reads and answers as a shell hook of the settings does
	Folder bool
}

One event a folder's hook runs on

func (Event) Runs

func (e Event) Runs(fired string) bool

Whether a firing of the event is one the event a folder names runs on: the event itself, or one of the part it stands for

type Folder

type Folder struct {
	// The folder, and the name it goes by: HOOK.yaml's name, else the folder's
	Dir, Name   string
	Description string
	Events      []Event
	// Command as HOOK.yaml writes it, and the words that run, the first a file of the folder made whole where the command names one
	Command string
	Argv    []string
	// Seconds the command may take
	Timeout int
	// Files whose change asks for consent again: HOOK.yaml, then each file the command names; and the digest of them all, which consent is
	// given to
	Files  []string
	Digest string
	// What was read otherwise than written, such as a time limit out of bounds, each a sentence
	Notes []string
}

A hook folder as its HOOK.yaml declares it: what runs, on which events, for how long

func Read

func Read(dir string, known func(point string) bool) (Folder, error)

Reads a hook folder: its HOOK.yaml, the events it names, each heard on the hook points it stands for, and the command that runs, a file of the folder named by its own name taken from the folder. Known says whether a name is a hook point a shell hook may run on. ErrNone for a folder with no HOOK.yaml; any other error says in a sentence why HOOK.yaml declares no hook a person can use

type Found

type Found struct {
	// The folder, and the name it is found under
	Dir, Base string
	Folder    Folder
	// Why its HOOK.yaml declares no hook a person can use, nil when it does
	Err error
}

One folder of a folder of hook folders, read or refused

func Scan

func Scan(root string, known func(point string) bool) []Found

Reads every folder of the folder of hook folders that holds a HOOK.yaml, by the name of the folder; none when the folder is not there

Jump to

Keyboard shortcuts

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