memory

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: 4 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 memory holds what the agent remembers: conversations, facts, the people it knows, and what it means to do.

Index

Constants

View Source
const (
	KnownFromBirth = "born" // known from the start, like a parent; never overwritten by a claim
	KnownByMeeting = "met"
	KnownByTelling = "told"
)
View Source
const (
	IntentionRemind   = "remind"
	IntentionTask     = "task"
	IntentionActivity = "activity"
)
View Source
const (
	IntentionPending   = "pending"
	IntentionDone      = "done"
	IntentionMissed    = "missed"   // could not be done in time
	IntentionAwaiting  = "awaiting" // waiting for the owner's approval (the autonomy gate)
	IntentionCancelled = "cancelled"
)
View Source
const (
	ReadBook    = "book"    // a public-domain book, read over many days
	ReadArticle = "article" // a Wikipedia article, read at once
)
View Source
const (
	ProjectActive  = "active"
	ProjectDone    = "done"
	ProjectDropped = "dropped"
)
View Source
const (
	ActionProposed = "proposed" // waiting for the owner
	ActionApproved = "approved" // runs on the next tick
	ActionDone     = "done"
	ActionFailed   = "failed"
	ActionDenied   = "denied" // the owner said no, or didn't answer
)
View Source
const (
	ApprovalPending  = "pending"
	ApprovalApproved = "approved"
	ApprovalDenied   = "denied"
	ApprovalExpired  = "expired" // not answered in time: denied
)
View Source
const (
	LabelFromChat    = "chat"
	LabelFromConsole = "console"
)
View Source
const (
	DreamActive    = "active"
	DreamDropped   = "dropped"
	DreamFromLife  = "life"
	DreamFromSelf  = "self"
	DreamFromOwner = "owner" // its owner asked it to take on a goal no dream of its own covered
)
View Source
const (
	PlanActive  = "active"
	PlanDone    = "done"
	PlanDropped = "dropped"
)
View Source
const (
	ResourceTodo = "todo"
	ResourceDone = "done"
)
View Source
const (
	GoalProposed = "proposed" // waiting for its owner's answer before it's set
	GoalActive   = "active"
	GoalDone     = "done"
	GoalDropped  = "dropped"
)
View Source
const (
	EvidenceSystem1 = "system1"
	EvidenceOwner   = "owner"
	EvidenceLife    = "life" // the level its life story starts it at: a first score, outweighed as real evidence comes
)
View Source
const (
	LessonFromOwner  = "owner"
	LessonFromSelf   = "self"
	LessonFromOthers = "others"
)
View Source
const (
	TasteFromTelegram = "telegram"
	TasteFromConsole  = "console"
)
View Source
const (
	PrincipleRule  = "principle"
	PrincipleRank  = "priority" // what matters most, in order: the higher wins when rules clash
	PrincipleLimit = "boundary" // never, whatever the gain
)
View Source
const (
	JudgmentProposed = "proposed" // waiting for the owner's review; not used
	JudgmentApproved = "approved"
	JudgmentRejected = "rejected"

	JudgmentFromSeed   = "seed"   // the owner's judgment file
	JudgmentFromReview = "review" // drawn by its weekly review from where the owner chose differently
)
View Source
const (
	StakesLow    = "low"    // little lost if it's wrong: an afternoon, a draft
	StakesMedium = "medium" // days of work, a goal, someone's expectations
	StakesHigh   = "high"   // money, reputation, a relationship, something public
)
View Source
const (
	OutcomeWell  = "went_well"
	OutcomeMixed = "mixed"
	OutcomeBadly = "went_badly"
)
View Source
const (
	VerdictGood    = "good_call" // a good decision, and it went well
	VerdictLucky   = "lucky"     // it went well despite the decision
	VerdictUnlucky = "unlucky"   // a good decision that went badly anyway
	VerdictBad     = "bad_call"  // it went badly because of the decision

	OutcomeBySelf  = "self"
	OutcomeByOwner = "owner" // its owner, which its review never overrides
)
View Source
const (
	CallFocus    = "focus" // what to work on today (the day plan)
	CallStart    = "start" // starting something new rather than going on (the day plan)
	CallNewGoal  = "new_goal"
	CallDropGoal = "drop_goal"
)
View Source
const (
	CallAfter  = "after"  // it acts on its pick; the owner grades it later
	CallBefore = "before" // it waits for the owner's answer; unanswered, it goes with its pick

	CallLogged   = "logged" // made, not asked: graded in the console, if ever
	CallAsked    = "asked"
	CallAnswered = "answered"
	CallExpired  = "expired"

	CallWaitingReason = "reason" // the owner chose differently: their next message says why
	CallWaitingAnswer = "answer" // the owner chose something else: their next message says what, and why

	AnsweredOnTelegram = "telegram"
	AnsweredInConsole  = "console"
	AnsweredByApproval = "approval" // answering an approval: a yes or no to what it wanted
)
View Source
const (
	PublicBySystem1 = "system1"  // the daily check (public_work question set)
	PublicByOwner   = "owner"    // its owner, which the daily check never overrides
	PublicByGate    = "gate"     // the autonomy gate: forbidden, or the owner didn't answer
	PublicAwaiting  = "awaiting" // judged public, waiting for the owner's approval
)
View Source
const (
	SectionCharacter = "character"
	SectionWork      = "work"
	SectionJudgment  = "judgment"
)
View Source
const (
	SelfImported   = "import" // from files: their old self/ folder, or tinio agent import
	SelfNew        = "new"    // tinio new
	SelfEdited     = "edit"
	SelfRolledBack = "rollback"
)
View Source
const CircleStranger = "stranger"
View Source
const KindAction = "action"

KindAction marks an approval as one for an Action (its Ref).

View Source
const SubjectSelf = "self"

Variables

StakesLevels are lowest first.

Functions

func CallCaseType

func CallCaseType(callType string) string

Types

type Action

type Action struct {
	ID         ulid.ULID
	Tool       string // "server.tool"
	Class      string // the autonomy class, e.g. "write"
	Args       string // its arguments as JSON, checked when proposed
	Why        string
	Status     string // ActionProposed, ActionApproved, ActionDone, ActionFailed, ActionDenied
	Result     string // what the tool said, or why it failed or didn't run
	PerceptID  ulid.ULID
	ProposedAt time.Time
	DoneAt     time.Time
}

Action is a tool that changes things, proposed by the agent. It runs only once approved: by the gate (auto) or by the owner (ask).

type AgentSkill

type AgentSkill struct {
	Name        string
	Description string
	Files       map[string][]byte
	AddedAt     time.Time
}

AgentSkill is a skill as stored: every file in it by its slash-separated path, SKILL.md included.

type Agreement

type Agreement struct {
	Type     string
	Answered int
	Agreed   int
}

Agreement is over the latest calls of one type the owner answered.

type Approval

type Approval struct {
	ID        ulid.ULID
	Class     string // the action class, e.g. "reach_out"
	Person    string
	What      string
	Text      string    // reach_out: the message it would send
	Kind      string    // reach_out: the percept kind, e.g. "reminder"
	Ref       ulid.ULID // the intention or work it is about
	Status    string    // ApprovalPending, ApprovalApproved, ApprovalDenied or ApprovalExpired
	AskedAt   time.Time
	SentAt    time.Time // when the owner was asked; zero until then
	DecidedAt time.Time
	Message   json.RawMessage // where the request was sent, to update it after; nil until sent
}

type Call

type Call struct {
	ID          ulid.ULID
	Type        string // CallFocus, CallStart, ...
	Mode        string // CallAfter or CallBefore
	Situation   string
	Options     []string
	Pick        int
	Why         string
	Confidence  float64 // how sure it is the owner would agree, 0 to 1; 0 unknown
	Stakes      string  // StakesLow, StakesMedium or StakesHigh; "" unknown
	Reversible  bool
	Ref         ulid.ULID
	Status      string // CallLogged, CallAsked, CallAnswered or CallExpired
	Waiting     string // CallWaitingReason or CallWaitingAnswer: what the owner's next message is; "" nothing
	WaitingAt   time.Time
	OwnerPick   int // an index into Options; -1 their own answer (OwnerChoice)
	OwnerChoice string
	OwnerReason string
	Agreed      *bool // nil until answered
	AnsweredBy  string
	Message     json.RawMessage
	CaseID      ulid.ULID
	CreatedAt   time.Time
	AskedAt     time.Time
	AnsweredAt  time.Time
	// Looked back on later; empty until then.
	Outcome     string // OutcomeWell, OutcomeMixed or OutcomeBadly
	Verdict     string // VerdictGood, VerdictLucky, VerdictUnlucky or VerdictBad
	OutcomeNote string
	OutcomeBy   string // OutcomeBySelf or OutcomeByOwner
	OutcomeAt   time.Time
}

Call is a decision where it predicted what its owner would choose. The owner's answer, when they give one, says whether they agree.

func (Call) AtStake

func (c Call) AtStake() float64

type Conversation

type Conversation struct {
	Person       string
	Source       string
	Thread       string          // e.g. the Telegram chat ID
	Payload      json.RawMessage // the channel's details from their last message, used to address a message
	LastActivity time.Time
}

Conversation is where the agent last talked with a person, so it can message them first.

type Dream

type Dream struct {
	ID      ulid.ULID
	Text    string // third person with its name
	Status  string // DreamActive or DreamDropped
	Source  string // DreamFromLife (its creator), DreamFromSelf or DreamFromOwner
	Since   time.Time
	EndedAt time.Time
}

type Evidence

type Evidence struct {
	ID     ulid.ULID
	Skill  string
	WorkID ulid.ULID // zero for feedback on no one work
	Score  float64   // 1 to 10
	Source string    // EvidenceSystem1, EvidenceOwner or EvidenceLife
	Note   string
	At     time.Time
}

type Exchange

type Exchange struct {
	At      time.Time
	Message string
	Reply   string
}

Exchange is one message and the agent's reply ("" if none was recorded). Message is "" when the agent spoke first.

type Fact

type Fact struct {
	ID        ulid.ULID
	PerceptID ulid.ULID
	Subject   string // SubjectSelf, or the person's key (e.g. "telegram:123")
	Text      string // as said; pronouns are resolved to names when used
	At        time.Time
	Areas     []string // e.g. ["home", "family"]; empty if not labelled
}

type Goal

type Goal struct {
	ID        ulid.ULID
	DreamID   ulid.ULID
	Text      string
	DoneWhen  string
	Due       time.Time
	Status    string // GoalProposed, GoalActive, GoalDone or GoalDropped
	Progress  string // from the last review
	Skill     string // if it's about one; it then has a learning plan
	CreatedAt time.Time
	UpdatedAt time.Time
}

type Intention

type Intention struct {
	ID        ulid.ULID
	Subject   string    // SubjectSelf, or who it is for, e.g. "telegram:123"
	Kind      string    // IntentionRemind, IntentionTask or IntentionActivity
	PerceptID ulid.ULID // zero if the agent planned it itself
	ProjectID ulid.ULID
	Text      string
	Ability   string // e.g. "read_book"; "" if it only writes
	Args      map[string]string
	DueAt     time.Time
	Status    string // IntentionPending, IntentionAwaiting, IntentionDone, IntentionMissed or IntentionCancelled
	Result    string // e.g. the title of what it made; "" until done
	CreatedAt time.Time
	DoneAt    time.Time
}

Intention is something the agent means to do later: for a person, a reminder or a promised task; for itself (SubjectSelf), an activity of its day.

type JudgmentCase

type JudgmentCase struct {
	ID        ulid.ULID
	Key       string // the seed file's key; the ID for others
	Type      string // general, engineering, product, autonomy or life
	Situation string
	Options   []string
	Choice    string
	Reason    string // the owner's own words; empty when they gave none
	Status    string
	Source    string
	Outcome   string // set when it came from a call that was looked back on
	At        time.Time
	UpdatedAt time.Time
	// Embedding is nil until embedded; EmbeddedWith names the model.
	Embedding    []float32
	EmbeddedWith string
}

func (JudgmentCase) Text

func (c JudgmentCase) Text() string

Text is what is embedded.

type Label

type Label struct {
	DecisionID ulid.ULID
	Question   string
	Value      string // a choice, or "true" / "false" for a yes/no question
	Source     string // LabelFromChat or LabelFromConsole
	At         time.Time
}

Label is what a System 1 answer should have been, from the owner.

type LearningPlan

type LearningPlan struct {
	ID        ulid.ULID
	GoalID    ulid.ULID
	Skill     string
	Stage     int    // the current stage, from 0
	Status    string // PlanActive, PlanDone or PlanDropped
	Stages    []Stage
	CreatedAt time.Time
	UpdatedAt time.Time
}

type Lesson

type Lesson struct {
	ID        ulid.ULID
	Skill     string
	Text      string
	Source    string // LessonFromOwner, LessonFromSelf or LessonFromOthers
	WorkID    ulid.ULID
	At        time.Time
	RetiredAt time.Time // zero while active
}

type Person

type Person struct {
	Key       string // e.g. "telegram:123"
	Name      string
	Relation  string // e.g. "Busta is Daniel's father."; "" if not known
	Circle    string // family, friend, school, ... or CircleStranger
	Source    string // KnownFromBirth, KnownByMeeting or KnownByTelling
	FirstSeen time.Time
	UpdatedAt time.Time
}

type Principle

type Principle struct {
	ID        ulid.ULID
	Text      string
	Kind      string // PrincipleRule, PrincipleRank or PrincipleLimit
	Rank      int    // a priority's place, 1 first; 0 for the others
	Types     []string
	Status    string   // JudgmentProposed, JudgmentApproved or JudgmentRejected
	Source    string   // JudgmentFromSeed or JudgmentFromReview
	Seed      string   // its text in the seed file; empty for others
	Cases     []string // keys of the cases behind it
	CreatedAt time.Time
	UpdatedAt time.Time
}

type Project

type Project struct {
	ID        ulid.ULID
	Title     string
	Kind      string // music, writing, reading, learning, ...
	Status    string // ProjectActive, ProjectDone or ProjectDropped
	Notes     string // where it got to, so the next session continues from there
	SourceID  ulid.ULID
	Position  int      // in bytes of its text
	Source    *Reading // set only when loaded with the project
	GoalID    ulid.ULID
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (Project) PercentRead

func (p Project) PercentRead() int

type Reading

type Reading struct {
	Kind   string // ReadBook or ReadArticle
	Title  string
	Author string
	Chars  int // in bytes
}

Reading is a book or article, without its text.

type Resource

type Resource struct {
	ID      ulid.ULID
	PlanID  ulid.ULID
	Stage   int
	Ability string
	Query   string
	Why     string
	Status  string    // ResourceTodo or ResourceDone
	Title   string    // what it turned out to be; "" until read
	WorkID  ulid.ULID // its notes on it; zero until read
	AddedAt time.Time
	DoneAt  time.Time
}

type SelfVersion

type SelfVersion struct {
	ID      ulid.ULID
	Section string // SectionCharacter, SectionWork, SectionJudgment
	Doc     string
	Source  string // SelfImported, SelfNew, SelfEdited, SelfRolledBack
	At      time.Time
}

SelfVersion is one version of a section of the person (their character, how they work, their owner's judgment), as YAML; the newest is the one used.

type Skill

type Skill struct {
	Name      string
	Level     float64 // 1 to 10, from recent evidence
	ShownBy   []string
	UpdatedAt time.Time
}

type Source

type Source struct {
	ID ulid.ULID
	Reading
	URL       string
	Text      string
	FetchedAt time.Time
}

type Stage

type Stage struct {
	N        int
	Learn    string
	Practice string
	DoneWhen string
	DoneAt   time.Time
}

type Taste

type Taste struct {
	ID        ulid.ULID
	Kind      string // e.g. "beat_idea"; "" any
	Likes     bool
	Text      string
	WorkID    ulid.ULID
	Source    string // TasteFromTelegram or TasteFromConsole
	At        time.Time
	RetiredAt time.Time // zero while true
}

Taste is something its owner likes or doesn't in its work, beyond how good it is: "likes hooks built on one repeated word".

type Watched

type Watched struct {
	ID   string
	Text string
	// Whole is a result that isn't a list: a new one replaces the last, so
	// what changed is what matters.
	Whole bool
}

Watched is one thing a watched tool returned: its ID tells it apart from what was seen before.

type Work

type Work struct {
	ID          ulid.ULID
	IntentionID ulid.ULID
	ProjectID   ulid.ULID
	Kind        string // journal, lyrics, beat_idea, notes, ...
	Title       string
	Text        string
	CreatedAt   time.Time
	Public      *bool  // whether it may go on its public page; nil until decided
	PublicBy    string // who decided: PublicBySystem1 or PublicByOwner; "" until decided
	// Data is what it carries beside its words, defined by the file made from
	// it (render.DataFormat), like a beat's score; nil if none.
	Data     json.RawMessage
	DataKind string
	// Loaded only by WorksFor. Embedding is nil until embedded; MadeFor is
	// whom it was made for (SubjectSelf for itself), "" if not for an intention.
	Embedding    []float32
	EmbeddedWith string
	MadeFor      string
}

func (Work) Carries

func (w Work) Carries(kind string) bool

Carries is whether w carries data of kind; every work carries its words ("").

Jump to

Keyboard shortcuts

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