memory

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RootPath = "memory/"
	FilePath = "memory.md"
)
View Source
const (
	DefaultFlushToolLoopTimeout = 2 * time.Minute
	DefaultFlushToolLoopTurns   = 6
)
View Source
const (
	DefaultChunkTokens             = memorycore.DefaultChunkTokens
	DefaultChunkOverlap            = memorycore.DefaultChunkOverlap
	DefaultWatchDebounceMs         = memorycore.DefaultWatchDebounceMs
	DefaultSessionDeltaBytes       = memorycore.DefaultSessionDeltaBytes
	DefaultSessionDeltaMessages    = memorycore.DefaultSessionDeltaMessages
	DefaultMaxResults              = memorycore.DefaultMaxResults
	DefaultMinScore                = memorycore.DefaultMinScore
	DefaultHybridCandidateMultiple = memorycore.DefaultHybridCandidateMultiple
	DefaultCacheEnabled            = memorycore.DefaultCacheEnabled
	UnlimitedCacheEntries          = memorycore.UnlimitedCacheEntries
	DefaultMemorySource            = memorycore.DefaultMemorySource
)

Variables

This section is empty.

Functions

func ExecuteCommand

func ExecuteCommand(ctx context.Context, call iruntime.CommandCall, deps CommandExecDeps) (handled bool, err error)

func ExecuteTool

func ExecuteTool(ctx context.Context, call iruntime.ToolCall, deps ToolExecDeps) (handled bool, result string, err error)

func HandleOverflow

func HandleOverflow(
	ctx context.Context,
	call any,
	prompt []openai.ChatCompletionMessageParamUnion,
	deps OverflowDeps,
)

func New

func PurgeTablesBestEffort

func PurgeTablesBestEffort(ctx context.Context, db *dbutil.Database, bridgeID, loginID string)

func RunFlushToolLoop

func RunFlushToolLoop(
	ctx context.Context,
	model string,
	messages []openai.ChatCompletionMessageParamUnion,
	deps FlushToolLoopDeps,
) error

func StopManagersForLogin

func StopManagersForLogin(bridgeID, loginID string)

StopManagersForLogin stops and removes all memory managers for a login. Used during disconnect and purge to release goroutines and timers.

Types

type CacheConfig

type CacheConfig = memorycore.CacheConfig

type ChunkingConfig

type ChunkingConfig = memorycore.ChunkingConfig

type CommandExecDeps

type CommandExecDeps struct {
	GetManager        func(scope iruntime.ToolScope) (execManager, string)
	ResolveSessionKey func(scope iruntime.ToolScope) string
	SplitQuotedArgs   func(raw string) ([]string, error)
	WriteFile         func(ctx context.Context, scope iruntime.CommandScope, mode string, path string, content string, maxBytes int) (updatedPath string, err error)
}

type ExperimentalConfig

type ExperimentalConfig = memorycore.ExperimentalConfig

type FallbackStatus

type FallbackStatus = memorycore.FallbackStatus

type FlushSettings

type FlushSettings struct {
	SoftThresholdTokens int
	Prompt              string
	SystemPrompt        string
}

type FlushToolLoopDeps

type FlushToolLoopDeps struct {
	TimeoutMs int64
	MaxTurns  int

	NextTurn func(ctx context.Context, model string, messages []openai.ChatCompletionMessageParamUnion) (
		assistant openai.ChatCompletionMessageParamUnion,
		calls []ModelToolCall,
		done bool,
		err error,
	)
	ExecuteTool func(ctx context.Context, name string, argsJSON string) (string, error)
	OnToolError func(name string, err error)
}

type HybridConfig

type HybridConfig = memorycore.HybridConfig

type Integration

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

Integration is the self-owned memory integration module. It implements ToolIntegration, PromptIntegration, CommandIntegration, EventIntegration, LoginPurgeIntegration, and LoginLifecycleIntegration directly, wiring all deps from Host capability interfaces.

func (*Integration) AdditionalSystemMessages

func (*Integration) CommandDefinitions

func (*Integration) ExecuteCommand

func (i *Integration) ExecuteCommand(ctx context.Context, call iruntime.CommandCall) (bool, error)

func (*Integration) ExecuteTool

func (i *Integration) ExecuteTool(ctx context.Context, call iruntime.ToolCall) (bool, string, error)

func (*Integration) Name

func (i *Integration) Name() string

func (*Integration) OnCompactionLifecycle

func (i *Integration) OnCompactionLifecycle(ctx context.Context, evt iruntime.CompactionLifecycleEvent)

func (*Integration) OnContextOverflow

func (i *Integration) OnContextOverflow(ctx context.Context, call iruntime.ContextOverflowCall)

func (*Integration) OnFileChanged

func (i *Integration) OnFileChanged(_ context.Context, evt iruntime.FileChangedEvent)

func (*Integration) OnSessionMutation

func (i *Integration) OnSessionMutation(ctx context.Context, evt iruntime.SessionMutationEvent)

func (*Integration) PurgeForLogin

func (i *Integration) PurgeForLogin(ctx context.Context, scope iruntime.LoginScope) error

func (*Integration) StopForLogin

func (i *Integration) StopForLogin(bridgeID, loginID string)

func (*Integration) ToolApprovalRequirement

func (i *Integration) ToolApprovalRequirement(toolName string, args map[string]any) (handled bool, required bool, action string)

func (*Integration) ToolAvailability

func (i *Integration) ToolAvailability(_ context.Context, scope iruntime.ToolScope, toolName string) (bool, bool, iruntime.SettingSource, string)

func (*Integration) ToolDefinitions

type MemorySearchCacheStatus

type MemorySearchCacheStatus struct {
	Enabled    bool
	Entries    int
	MaxEntries int
}

type MemorySearchFTSStatus

type MemorySearchFTSStatus struct {
	Enabled   bool
	Available bool
	Error     string
}

type MemorySearchManager

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

func GetMemorySearchManager

func GetMemorySearchManager(host iruntime.Host, agentID string) (*MemorySearchManager, string)

func (*MemorySearchManager) Close

func (m *MemorySearchManager) Close()

Close stops background timers/goroutines. It is safe to call multiple times.

func (*MemorySearchManager) NotifyFileChanged

func (m *MemorySearchManager) NotifyFileChanged(path string)

func (*MemorySearchManager) NotifySessionChanged

func (m *MemorySearchManager) NotifySessionChanged(ctx context.Context, sessionKey string, force bool)

func (*MemorySearchManager) ReadFile

func (m *MemorySearchManager) ReadFile(ctx context.Context, relPath string, from, lines *int) (map[string]any, error)

func (*MemorySearchManager) Search

func (*MemorySearchManager) Status

func (*MemorySearchManager) StatusDetails

func (m *MemorySearchManager) StatusDetails(ctx context.Context) (*MemorySearchStatus, error)

func (*MemorySearchManager) SyncWithProgress

func (m *MemorySearchManager) SyncWithProgress(ctx context.Context, onProgress func(completed, total int, label string)) error

SyncWithProgress forces a reindex and reports indexing progress.

type MemorySearchSourceCount

type MemorySearchSourceCount struct {
	Source string
	Files  int
	Chunks int
}

type MemorySearchStatus

type MemorySearchStatus struct {
	Files        int
	Chunks       int
	Dirty        bool
	WorkspaceDir string
	DBPath       string
	Provider     string
	Model        string
	Sources      []string
	ExtraPaths   []string
	SourceCounts []MemorySearchSourceCount
	Cache        *MemorySearchCacheStatus
	FTS          *MemorySearchFTSStatus
	Fallback     *memorycore.FallbackStatus
}

type ModelToolCall

type ModelToolCall struct {
	ID       string
	Name     string
	ArgsJSON string
}

type OverflowDeps

type OverflowDeps struct {
	IsSimpleMode     func(call any) bool
	ResolveSettings  func() *FlushSettings
	TrimPrompt       func(prompt []openai.ChatCompletionMessageParamUnion) []openai.ChatCompletionMessageParamUnion
	ContextWindow    func(call any) int
	ReserveTokens    func() int
	EffectiveModel   func(call any) string
	EstimateTokens   func(prompt []openai.ChatCompletionMessageParamUnion, model string) int
	AlreadyFlushed   func(call any) bool
	MarkFlushed      func(ctx context.Context, call any)
	RunFlushToolLoop func(ctx context.Context, call any, model string, prompt []openai.ChatCompletionMessageParamUnion) (bool, error)
	OnError          func(ctx context.Context, err error)
}

type PromptAugmentDeps

type PromptAugmentDeps struct {
	ShouldInjectContext   func(scope iruntime.PromptScope) bool
	ShouldBootstrap       func(scope iruntime.PromptScope) bool
	ResolveBootstrapPaths func(scope iruntime.PromptScope) []string
	MarkBootstrapped      func(ctx context.Context, scope iruntime.PromptScope)
	ReadSection           func(ctx context.Context, scope iruntime.PromptScope, path string) string
}

type ProviderStatus

type ProviderStatus = memorycore.ProviderStatus

type QueryConfig

type QueryConfig = memorycore.QueryConfig

type ResolvedConfig

type ResolvedConfig = memorycore.ResolvedConfig

func MergeSearchConfig

func MergeSearchConfig(defaults *agents.MemorySearchConfig, overrides *agents.MemorySearchConfig) *ResolvedConfig

type SearchOptions

type SearchOptions = memorycore.SearchOptions

type SearchResult

type SearchResult = memorycore.SearchResult

type SessionSyncConfig

type SessionSyncConfig = memorycore.SessionSyncConfig

type StoreConfig

type StoreConfig = memorycore.StoreConfig

type SyncConfig

type SyncConfig = memorycore.SyncConfig

type ToolExecDeps

type ToolExecDeps struct {
	GetManager             func(scope iruntime.ToolScope) (execManager, string)
	ResolveSessionKey      func(scope iruntime.ToolScope) string
	ResolveCitationsMode   func(scope iruntime.ToolScope) string
	ShouldIncludeCitations func(ctx context.Context, scope iruntime.ToolScope, mode string) bool
}

Jump to

Keyboard shortcuts

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