Documentation
¶
Overview ¶
Package targetmem stores per-target facts across PromptZero sessions. When a scan, detect, or RX tool produces a target identifier (BSSID, card UID, RF frequency+protocol), the agent can record what it learned about that target and recall those facts on future sessions.
Backing store: SQLite. Same database file as the audit log would be conceptually clean but keeps migration simpler to separate for now; targets live in ~/.promptzero/targetmem.db. Schema is key/value per target identifier so operators can attach arbitrary JSON without schema migrations.
Index ¶
Constants ¶
const ( KindBSSID = "bssid" KindNFCUID = "nfc_uid" KindRFIDData = "rfid_data" KindSubGHz = "subghz" KindIButton = "ibutton" )
Known target kinds. Operators / tools are free to introduce new kinds — the store accepts any string — but these constants cover the common cases.
const MaxRecent = 1000
MaxRecent caps the per-call row count returned by Recent. The targets table grows without bound across sessions; a Recent(1000000) call (operator typo, malicious LLM tool call) would tie up SQLite and serialise a multi-MB JSON. 1000 is generous for any reasonable recall flow.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
DefaultPath returns ~/.promptzero/targetmem.db.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the persistent target memory. Safe for concurrent use; a single SQLite connection is serialised internally.
func Open ¶
Open creates or opens the target-memory store at path. The parent directory is created if missing. Schema migrations run idempotently on every open so a fresh install and an existing db reach the same state.
func (*Store) Forget ¶
Forget deletes a target. Safe to call on a non-existent target — returns nil. Intended for /targets forget <id> in the REPL.
func (*Store) Lookup ¶
Lookup returns a target by identifier+kind or (zero, false) when absent. Case-sensitive — BSSIDs are normalised lowercase by convention at the call site, not the store.
func (*Store) Recent ¶
Recent returns the N most recently observed targets, newest first. Useful for the /targets REPL command and for the agent's session- start known-targets context block. n is bounded by MaxRecent so an LLM tool call asking for 1000000 can't push the entire targets table into a JSON tool-result.
type Target ¶
type Target struct {
Identifier string `json:"identifier"`
Kind string `json:"kind"` // "bssid" / "nfc_uid" / "rfid_data" / "subghz" / other
Facts any `json:"facts,omitempty"`
FirstSeen time.Time `json:"first_seen"`
LastSeen time.Time `json:"last_seen"`
}
Target is one remembered target row. Identifier is the stable key (BSSID, card UID hex, freq+protocol tuple); Kind describes what kind of identifier it is so the model knows how to read it.