local

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 22 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package local is the backend Recall uses when nothing names a database: a polign_db that Recall runs itself, kept in a directory on this machine.

The first process to open a directory starts a polign-server for it on a free loopback port, with a generated key only this directory knows, and leaves it running; later processes find it through the runtime file the server writes. Nothing listens beyond this host. The server is the polign-server beside the recall binary or on PATH, which pip and Homebrew install with recall; when there is none, the backend downloads the release it was tested with, once, into bin/ under Recall's home (see fetch.go).

Importing this package registers it as the "local" backend:

import _ "github.com/Polign/recall/backend/local"

b, err := recall.OpenBackend("local", recall.BackendOptions{URL: "~/agent-memory"})

An empty URL means Home(), where every agent on the machine shares one memory. The one option is ?server=/path/to/polign-server.

Index

Constants

View Source
const Name = "local"

Name is the registered backend name.

View Source
const ServerVersion = "v0.16.0"

ServerVersion is the polign_db release the local backend downloads when no polign-server is installed. Bump it, and serverArchives with it, from the release's checksums.txt (dl.polign.com/<version>/checksums.txt).

Variables

This section is empty.

Functions

func DownloadedServerDir added in v0.24.0

func DownloadedServerDir() string

DownloadedServerDir is where a downloaded polign-server lives: bin/ under Recall's home ($RECALL_HOME, then ~/.local/share/recall). It is "" when the user's home directory is unknown.

func GenerateKey

func GenerateKey() (string, error)

GenerateKey makes a key in the shape polign-server accepts from -bootstrap-key-file: plgn_<16 hex>_<64 hex>. The server stays the authority and refuses to start on a key it cannot parse.

func Home

func Home() string

Home is the directory Recall keeps its own configuration and, when nothing names a database, its memory in: $RECALL_HOME, else $XDG_DATA_HOME/recall, else ~/.local/share/recall. A setup saved before 0.23.0 in ~/.config/polign/recall is still found. See recallhome.Home.

func LegacyHome

func LegacyHome() string

LegacyHome is where setups before 0.23.0 lived, ~/.config/polign/recall.

func Open

func Open(o Options) (*polign.Backend, error)

Open makes sure the directory's server is running and returns a backend connected to it. Unlike the other backends' constructors it may start a process and wait for it, which takes up to a few seconds the first time.

func ReadKey

func ReadKey(dir string) (string, error)

ReadKey reads the directory's key file.

func Resolve

func Resolve(dir string) (string, error)

Resolve makes dir absolute, expanding a leading ~; empty means Home().

func ServerPath

func ServerPath(explicit string) (string, error)

ServerPath finds the polign-server to run: explicit when given, else the one beside the running binary (a pip environment, Homebrew, a release archive), else the first on PATH, else the one a previous run downloaded into DownloadedServerDir. With none, the error wraps errServerMissing and Ensure downloads one.

func ValidKey

func ValidKey(key string) bool

ValidKey reports whether key has the shape GenerateKey makes.

func WriteKey

func WriteKey(dir, key string) error

WriteKey writes the directory's key file, readable by the owner only.

Types

type Connection

type Connection struct {
	// URL is the server's HTTP address on the loopback interface.
	URL string
	// Key is the API key the server was started with.
	Key string
	// Dir is the directory, made absolute.
	Dir string
}

Connection is where the running server listens and the key it accepts.

func Ensure

func Ensure(ctx context.Context, o Options) (Connection, error)

Ensure starts the directory's server if it is not running and returns how to reach it. It is safe to call from several processes at once: they take turns on a lock file, and the second finds the first one's server.

type Options

type Options struct {
	// Dir is the directory. Empty means Home(). A leading ~ is the user's
	// home directory.
	Dir string
	// Server is the polign-server executable. Empty means the one beside
	// the running binary, then the first on PATH, then the one downloaded
	// earlier; with none of those, it is downloaded.
	Server string
	// Progress hears about a download of polign-server. Nil means stderr,
	// which MCP clients log and recall setup shows.
	Progress io.Writer
}

Options say which directory holds the database and which polign-server runs it.

Jump to

Keyboard shortcuts

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