stores

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSessionNotFound = errors.New("session not found")

ErrSessionNotFound is returned by LoadSession when the requested session does not exist.

Functions

This section is empty.

Types

type BaseStore

type BaseStore interface {
	SaveSession(context.Context, string, SessionCheckpoint) error
	LoadSession(context.Context, string) (SessionCheckpoint, error)
}

BaseStore is the minimal persistence interface for agent harness session state.

Implementations included in this package:

  • InMemoryStore — sessions live in memory, lost on restart.
  • PostgresStore — sessions persisted via PostgreSQL/pgx.

Users may provide their own implementation (e.g. Redis, SQLite, custom DB). Wire-protocol session envelopes are not part of this API.

type InMemoryStore

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

InMemoryStore implements BaseStore entirely in memory. Sessions are lost when the process exits.

func NewInMemoryStore

func NewInMemoryStore() *InMemoryStore

NewInMemoryStore creates an empty in-memory session store.

func (*InMemoryStore) LoadSession

func (s *InMemoryStore) LoadSession(_ context.Context, sessionID string) (SessionCheckpoint, error)

LoadSession retrieves the session checkpoint for the given sessionID.

func (*InMemoryStore) SaveSession

func (s *InMemoryStore) SaveSession(_ context.Context, sessionID string, checkpoint SessionCheckpoint) error

SaveSession stores the session checkpoint for the given sessionID.

type PendingToolCall

type PendingToolCall struct {
	ToolCall        *streaming.ToolCall
	InterruptActive bool
}

type PostgresStore

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

PostgresStore implements BaseStore against a Postgres connection via pgx.

func NewPostgresStore

func NewPostgresStore(conn *pgx.Conn) *PostgresStore

NewPostgresStore wraps an existing pgx connection.

func (*PostgresStore) LoadSession

func (s *PostgresStore) LoadSession(ctx context.Context, sessionID string) (SessionCheckpoint, error)

func (*PostgresStore) SaveSession

func (s *PostgresStore) SaveSession(ctx context.Context, sessionID string, checkpoint SessionCheckpoint) error

type SessionCheckpoint

type SessionCheckpoint struct {
	ContextWindow []*streaming.Message `json:"contextWindow"`
	State         sessionState         `json:"state"`
}

SessionCheckpoint is the agent harness checkpoint blob. Wire protocols (ACP, …) must not store protocol envelopes here — use a ProtocolWireStore (or equivalent) owned by the protocol.

func NewCheckpoint

func NewCheckpoint(contextWindow []*streaming.Message, pendingToolCalls map[string]PendingToolCall, interruptToRequester map[string]string, runtimeState map[string]any, pendingInterrupts, resolvedInterrupts any) (*SessionCheckpoint, error)

Jump to

Keyboard shortcuts

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