Documentation
¶
Overview ¶
Package execstore is a memory.Store backed by an external command that speaks the suga exec protocol v1 (see package extproc): every operation runs the command once, writes one JSON request line to its stdin and reads one JSON response line from its stdout.
Wire format for third-party implementations ¶
The envelope is {"v":1,"capability":"memory","op":"<op>","args":{...}} and the answer {"ok":true,"result":{...}} or {"ok":false,"error":"..."}. The scope is always the string "user" or "project:<key>". Per op:
op "index" args {"scope"}
result {"lines":[{"id","title","kind","summary"}],"bytes":0}
op "get" args {"scope","id"}
result entry
op "write" args {"scope","op":{"action":"add|replace|remove","id","title","body","kind","summary","applies_when"}}
result entry; for "add" the backend derives the id from the
title (the request id is empty); for "remove" it returns the
entry as it was before removal, with title and body
op "search" args {"scope","query","limit"} (limit 0: backend default)
result {"hits":[{"id","title","kind","snippet","updated"}]}
An entry is {"id","title","body","kind","summary","applies_when","updated"} with kind one of user, feedback, project, reference and updated an RFC 3339 time (optional). summary is the one-sentence index line description (optional; a backend that ignores it just returns an empty summary).
Ids must satisfy memory.ValidateID (lowercase a-z, 0-9, '-'). A missing entry is reported with ok=false and an error text containing "not found".
Everything the command returns is untrusted: ids and kinds are validated here, and the host wraps the store in memory.Governed, which sanitizes all text before the model sees it.
Index ¶
- Constants
- type Config
- type Store
- func (s *Store) BackendName() string
- func (s *Store) Get(ctx context.Context, sc memory.Scope, id string) (memory.Entry, error)
- func (s *Store) Index(ctx context.Context, sc memory.Scope) (memory.Index, error)
- func (s *Store) Search(ctx context.Context, sc memory.Scope, q string, limit int) ([]memory.Hit, error)
- func (s *Store) Write(ctx context.Context, sc memory.Scope, op memory.Op) (memory.Entry, error)
Constants ¶
const Name = "exec"
Name is the backend name reported by BackendName.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Command string
Args []string
// Env holds extra KEY=VALUE entries for the child (credentials of the
// parent environment are stripped by extproc).
Env []string
// Timeout bounds each call; zero means extproc.DefaultTimeout.
Timeout time.Duration
}
Config describes the external command.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements memory.Store (and memory.Named) over the command.
func (*Store) BackendName ¶
BackendName implements memory.Named.