memoryruntime

package
v0.107.24 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 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 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) 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