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
- func DownloadedServerDir() string
- func GenerateKey() (string, error)
- func Home() string
- func LegacyHome() string
- func Open(o Options) (*polign.Backend, error)
- func ReadKey(dir string) (string, error)
- func Resolve(dir string) (string, error)
- func ServerPath(explicit string) (string, error)
- func ValidKey(key string) bool
- func WriteKey(dir, key string) error
- type Connection
- type Options
Constants ¶
const Name = "local"
Name is the registered backend name.
const ServerVersion = "v0.15.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 ¶
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, with the spellings before 0.23.0 ($POLIGN_RECALL_HOME, and a setup saved in ~/.config/polign/recall) still honored. See recallhome.Home.
func LegacyHome ¶
func LegacyHome() string
LegacyHome is where setups before 0.23.0 lived, ~/.config/polign/recall.
func Open ¶
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 ServerPath ¶
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.
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.
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.