memoryruntime

package
v0.107.39 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package memoryruntime owns model-backed memory injection and hidden turn extraction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Store           *memory.Store
	ResolveModel    ModelResolver
	ExtractionModel string
	OrganizerModel  string
	Throttle        time.Duration
	Now             func() time.Time
}

type ModelResolver

type ModelResolver func(context.Context, string) (ai.Client, string, error)

type OrganizerRun

type OrganizerRun struct {
	RunID     string            `json:"runId"`
	Epoch     uint64            `json:"epoch"`
	Executor  string            `json:"executorId"`
	Trigger   OrganizerTrigger  `json:"trigger"`
	Phase     string            `json:"phase"`
	Status    string            `json:"status"`
	Workdir   string            `json:"workdir,omitempty"`
	Model     string            `json:"model,omitempty"`
	Scanned   int               `json:"scanned"`
	Clusters  int               `json:"clusters"`
	Applied   int               `json:"applied"`
	Risk      string            `json:"risk"`
	Pending   []memory.Decision `json:"pending,omitempty"`
	Warnings  []string          `json:"warnings,omitempty"`
	CreatedAt time.Time         `json:"createdAt"`
	UpdatedAt time.Time         `json:"updatedAt"`
}

type OrganizerScheduler added in v0.107.28

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

OrganizerScheduler runs the organizer every interval while enabled. Each countdown starts when the scheduler starts, when Update is called and when the previous scheduled run returns, so runs never overlap.

func (*OrganizerScheduler) Close added in v0.107.28

func (s *OrganizerScheduler) Close()

Close stops the loop, cancelling a run in progress, and waits for it.

func (*OrganizerScheduler) State added in v0.107.28

func (s *OrganizerScheduler) State() (enabled bool, interval time.Duration)

State is the schedule the loop currently follows.

func (*OrganizerScheduler) Update added in v0.107.28

func (s *OrganizerScheduler) Update(enabled bool, interval time.Duration)

Update applies a new schedule without restarting the loop: disabling stops future runs (a run in progress finishes), and enabling or changing the interval restarts the countdown from now. A non-positive interval means 24h.

type OrganizerTrigger

type OrganizerTrigger string
const (
	OrganizerManual    OrganizerTrigger = "manual"
	OrganizerScheduled OrganizerTrigger = "scheduled"
)

type Runtime

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

func New

func New(cfg Config) (*Runtime, error)

func (*Runtime) Abandoned added in v0.107.6

func (r *Runtime) Abandoned(sessionID string, user ai.Message)

Abandoned keeps the user message of a stopped or failed turn for the session's next completed turn; it stays in History, which later turns treat as context only.

func (*Runtime) ApplyOrganizerRun

func (r *Runtime) ApplyOrganizerRun(ctx context.Context, runID string) (OrganizerRun, error)

func (*Runtime) Close

func (r *Runtime) Close() error

func (*Runtime) Completed

func (r *Runtime) Completed(parent context.Context, turn agent.MemoryTurn)

func (*Runtime) Inject

func (r *Runtime) Inject(ctx context.Context, workdir string) (string, error)

func (*Runtime) NewOrganizerScheduler added in v0.107.28

func (r *Runtime) NewOrganizerScheduler(ctx context.Context, workdir string, enabled bool, interval time.Duration) *OrganizerScheduler

NewOrganizerScheduler starts a scheduled organizer loop that can be paused, resumed and given a new interval while it runs (see OrganizerScheduler.Update). A non-positive interval means 24h.

func (*Runtime) OrganizerHistory

func (r *Runtime) OrganizerHistory() []OrganizerRun

func (*Runtime) RunOrganizer

func (r *Runtime) RunOrganizer(ctx context.Context, workdir string, trigger OrganizerTrigger) (OrganizerRun, error)

RunOrganizer executes the auditable scan -> cluster -> plan -> gate -> apply flow. Manual runs stop at gate and can be applied later with ApplyOrganizerRun.

func (*Runtime) StartOrganizerScheduler

func (r *Runtime) StartOrganizerScheduler(ctx context.Context, workdir string, interval time.Duration) func()

StartOrganizerScheduler is a host-owned wakeup loop. It only invokes the K-brain organizer model configured on this Runtime.

func (*Runtime) Tools

func (r *Runtime) Tools(workdir func() string) []tools.Tool

Jump to

Keyboard shortcuts

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