archivist

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package archivist provides the Archivist agent that extracts and manages facts and people from conversations for long-term memory.

Index

Constants

View Source
const (
	// ParamMessages is the key for messages to process ([]storage.Message).
	ParamMessages = "messages"
	// ParamFacts is the key for current facts ([]storage.Fact).
	ParamFacts = "facts"
	// ParamPeople is the key for known people names ([]storage.Person).
	ParamPeople = "people"
	// ParamReferenceDate is the key for the reference date (time.Time).
	ParamReferenceDate = "reference_date"
	// ParamUser is the key for user info (*storage.User, optional).
	ParamUser = "user"
)

Request parameters for Archivist agent.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddedFact

type AddedFact struct {
	Relation   string `json:"relation"`
	Content    string `json:"content"`
	Category   string `json:"category"`
	Type       string `json:"type"`
	Importance int    `json:"importance"`
	Reason     string `json:"reason"`
}

AddedFact represents a new fact to add.

type AddedPerson added in v0.5.1

type AddedPerson struct {
	DisplayName string   `json:"display_name"`
	Aliases     []string `json:"aliases,omitempty"`
	Circle      string   `json:"circle"`
	Bio         string   `json:"bio"`
	Reason      string   `json:"reason"`
}

AddedPerson represents a new person to add.

type Archivist

type Archivist struct {
	// contains filtered or unexported fields
}

Archivist extracts and manages facts and people from conversations.

func New

func New(
	executor *agent.Executor,
	translator *i18n.Translator,
	cfg *config.Config,
	logger *slog.Logger,
	agentLogger *agentlog.Logger,
) *Archivist

New creates a new Archivist agent.

func (*Archivist) Capabilities

func (a *Archivist) Capabilities() agent.Capabilities

Capabilities returns the agent's capabilities.

func (*Archivist) Description

func (a *Archivist) Description() string

Description returns a human-readable description.

func (*Archivist) Execute

func (a *Archivist) Execute(ctx context.Context, req *agent.Request) (*agent.Response, error)

Execute runs the archivist with the given request.

func (*Archivist) SetPeopleRepository added in v0.5.1

func (a *Archivist) SetPeopleRepository(repo PeopleRepository)

SetPeopleRepository sets the people repository for the agent.

func (*Archivist) Type

func (a *Archivist) Type() agent.AgentType

Type returns the agent type.

type FactView

type FactView struct {
	ID         int64  `json:"id"`
	Relation   string `json:"relation"`
	Content    string `json:"content"`
	Category   string `json:"category"`
	Type       string `json:"type"`
	Importance int    `json:"importance"`
}

FactView is a simplified view of a fact for the prompt.

type FactsResult added in v0.5.1

type FactsResult struct {
	Added   []AddedFact   `json:"added"`
	Updated []UpdatedFact `json:"updated"`
	Removed []RemovedFact `json:"removed"`
}

FactsResult contains fact operations.

type LegacyResult added in v0.5.1

type LegacyResult struct {
	Added   []AddedFact   `json:"added"`
	Updated []UpdatedFact `json:"updated"`
	Removed []RemovedFact `json:"removed"`
}

LegacyResult for backward compatibility with old format.

type MergedPerson added in v0.5.1

type MergedPerson struct {
	TargetName string `json:"target_name,omitempty"` // Fallback with warning
	SourceName string `json:"source_name,omitempty"` // Fallback with warning
	TargetID   string `json:"target_id,omitempty"`   // Preferred: "Person:10"
	SourceID   string `json:"source_id,omitempty"`   // Preferred: "Person:5"
	Reason     string `json:"reason"`
}

MergedPerson represents a merge operation for duplicate people.

func (*MergedPerson) GetSourceID added in v0.5.4

func (p *MergedPerson) GetSourceID() (string, bool)

GetSourceID extracts source person ID from MergedPerson. Prefers "Person:5" (string), returns empty string if not found.

func (*MergedPerson) GetTargetID added in v0.5.4

func (p *MergedPerson) GetTargetID() (string, bool)

GetTargetID extracts target person ID from MergedPerson. Prefers "Person:10" (string), returns empty string if not found.

type PeopleRepository added in v0.5.1

type PeopleRepository interface {
	GetPeople(userID int64) ([]storage.Person, error)
}

PeopleRepository is the interface for loading people.

type PeopleResult added in v0.5.1

type PeopleResult struct {
	Added   []AddedPerson   `json:"added,omitempty"`
	Updated []UpdatedPerson `json:"updated,omitempty"`
	Merged  []MergedPerson  `json:"merged,omitempty"`
}

PeopleResult contains people operations.

type RawFact added in v0.5.4

type RawFact struct {
	ID         int64  `json:"id"`
	Content    string `json:"content"`
	Type       string `json:"type"`
	Importance int    `json:"importance"`
	Reason     string `json:"reason"`
}

RawFact represents a fact in the wrong format (LLM returned array of facts instead of operations).

type RawPerson added in v0.5.4

type RawPerson struct {
	DisplayName string   `json:"display_name"`
	Aliases     []string `json:"aliases"`
	Circle      string   `json:"circle"`
	Bio         string   `json:"bio"`
	Reason      string   `json:"reason"`
}

RawPerson represents a person in the wrong format (LLM returned array of people instead of operations).

type RemovedFact

type RemovedFact struct {
	ID     int64  `json:"id,omitempty"`      // Legacy: numeric fallback with warning
	FactID string `json:"fact_id,omitempty"` // Preferred: "Fact:1234" or "1234"
	Reason string `json:"reason"`
}

RemovedFact represents a fact to be deleted.

func (*RemovedFact) GetFactID added in v0.5.4

func (f *RemovedFact) GetFactID() (int64, error)

GetFactID extracts fact ID from RemovedFact. Prefers "Fact:1234" or "1234" (string), falls back to numeric id. Returns 0 if no valid ID found.

type Result

type Result struct {
	Facts  FactsResult  `json:"facts"`
	People PeopleResult `json:"people"`
}

Result contains all memory update decisions.

type ResultWithArrayFields added in v0.5.1

type ResultWithArrayFields struct {
	Facts  []FactsResult  `json:"facts"`
	People []PeopleResult `json:"people"`
}

ResultWithArrayFields handles LLM quirk where "facts" or "people" is wrapped in array.

type ResultWithRawArrays added in v0.5.4

type ResultWithRawArrays struct {
	Facts  []RawFact   `json:"facts"`
	People []RawPerson `json:"people"`
}

ResultWithRawArrays handles LLM error where it returns raw fact/person arrays instead of operations.

type UpdatedFact

type UpdatedFact struct {
	ID         int64  `json:"id,omitempty"`      // Legacy: numeric fallback with warning
	FactID     string `json:"fact_id,omitempty"` // Preferred: "Fact:1522" or "1522"
	Content    string `json:"content"`
	Type       string `json:"type,omitempty"`
	Importance int    `json:"importance"`
	Reason     string `json:"reason"`
}

UpdatedFact represents changes to an existing fact.

func (*UpdatedFact) GetFactID added in v0.5.4

func (f *UpdatedFact) GetFactID() (int64, error)

GetFactID extracts fact ID from UpdatedFact. Prefers "Fact:1522" or "1522" (string), falls back to numeric id. Returns 0 if no valid ID found.

type UpdatedPerson added in v0.5.1

type UpdatedPerson struct {
	DisplayName    string   `json:"display_name,omitempty"`     // Fallback with warning
	PersonID       string   `json:"person_id,omitempty"`        // Preferred: "Person:5"
	NewDisplayName string   `json:"new_display_name,omitempty"` // Rename person, old name goes to aliases
	Aliases        []string `json:"aliases,omitempty"`          // New aliases to add
	Circle         string   `json:"circle,omitempty"`
	Bio            string   `json:"bio"` // Complete rewritten bio
	Reason         string   `json:"reason"`
}

UpdatedPerson represents changes to an existing person.

func (*UpdatedPerson) GetPersonID added in v0.5.4

func (p *UpdatedPerson) GetPersonID() (string, bool)

GetPersonID extracts person ID from UpdatedPerson. Prefers "Person:5" (string), returns empty string if not found.

Jump to

Keyboard shortcuts

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