agent

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 16 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 person is someone as their database holds them: their life, how they live, their owner's judgment, their skills and their secrets. Only DATABASE_URL and TINIO_KEY are outside it. Files only come in (tinio new, their old self/ folder, tinio self import) and go out (export).

Index

Constants

This section is empty.

Variables

View Source
var ErrNoOne = errors.New("no one lives here yet: start someone with `tinio new`")
View Source
var Files = map[string]string{memory.SectionCharacter: "character.yaml", memory.SectionWork: "work.yaml", memory.SectionJudgment: "judgment.yaml"}

Files are the sections as files, as each character in characters/ has them.

View Source
var Known = []string{"TELEGRAM_BOT_TOKEN", "TELEGRAM_OWNER_ID", "OPENAI_API_KEY", "OPENAI_MODEL", "CONSOLE_TOKEN"}

Known are the secrets every person has: what tinio new asks for.

Functions

func BySection

func BySection(files map[string][]byte) map[string][]byte

BySection is files, by file name (Files, or the names before v0.4.0), by section; a file of neither name is left out.

func CheckName

func CheckName(name string) error

func Env

func Env(ctx context.Context, st Store, key secret.Key) ([]string, error)

Env puts their secrets in this process's environment where it doesn't already set them, so the config's ${VAR}s and their tools' env find them. It returns those the environment sets too, which win.

func ReadFolder

func ReadFolder(dir string) (map[string][]byte, error)

ReadFolder is the sections in dir, by section; a missing file is left out.

func SkillsIn

func SkillsIn(dir string) ([]agentskill.Skill, []string)

SkillsIn reads every skill folder in dir; a missing dir has none.

func Start

func Start(ctx context.Context, st Store, key secret.Key, sections map[string][]byte, secrets map[string]string, skills []agentskill.Skill,
	source string, now time.Time) (string, bool, error)

Start makes the database theirs, all at once: sections are their YAML by section (BySection), checked first. It returns false, changing nothing, if someone lives there already.

Types

type Agent

type Agent struct {
	Life     character.Character // their character
	Work     []byte              // read over the config (config.Load)
	Judgment character.Judgment
	Skills   []agentskill.Skill
	// FromEnv are stored secrets the environment sets too: it wins.
	FromEnv []string
	// Unreadable are stored skills left out, with why.
	Unreadable []string
}

func Load

func Load(ctx context.Context, st Store, key secret.Key) (Agent, error)

Load reads them from their database, their secrets into the environment (Env).

type Imported

type Imported struct {
	Name    string // "" if no one was
	Secrets []string
	Skills  []string
	Skipped []string // folders that aren't skills, with why
}

func Import

func Import(ctx context.Context, st Store, key secret.Key, dir string, now time.Time) (Imported, error)

Import moves someone from their folder into their database, once: dir's sections and skills/, and the secrets the environment sets (Known, and those their tools name). Nothing is imported (Name "") if no one lives in dir or someone lives in the database already.

type Store

type Store interface {
	Start(ctx context.Context, name string, vs []memory.SelfVersion, secrets map[string][]byte, skills []memory.AgentSkill, at time.Time) (bool, error)
	Self(ctx context.Context, section string) (memory.SelfVersion, bool, error)
	Secrets(ctx context.Context) (map[string][]byte, error)
	AgentSkills(ctx context.Context) ([]memory.AgentSkill, error)
}

Jump to

Keyboard shortcuts

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