Documentation
¶
Overview ¶
Package person tracks presence state for configured household members and provides context injection into the agent's system prompt.
Package contacts provides vCard-aligned structured storage for people, organizations, groups, and locations.
Index ¶
- Constants
- Variables
- func CardToContact(card vcard.Card) (*Contact, []Property)
- func ContactToCard(c *Contact) vcard.Card
- func EncodeVCard(c *Contact) (string, error)
- func EncodeVCards(contacts []*Contact) (string, error)
- func FilterCardForTrustZone(card vcard.Card, zone string, props []Property) vcard.Card
- func TitleCase(s string) string
- type Contact
- type ContextProvider
- type EmbeddingClient
- type ExportAllVCFArgs
- type ExportVCFArgs
- type ExportVCFQRArgs
- type ForgetContactArgs
- type ImportVCFArgs
- type InteractionMeta
- type ListContactsArgs
- type LookupContactArgs
- type Person
- type PresenceTracker
- func (t *PresenceTracker) EntityIDs() []string
- func (t *PresenceTracker) GetContext(_ context.Context, _ string) (string, error)
- func (t *PresenceTracker) HandleStateChange(entityID, _, newState string)
- func (t *PresenceTracker) Initialize(ctx context.Context, ha StateGetter) error
- func (t *PresenceTracker) OnRoomChange(fn RoomObserver)
- func (t *PresenceTracker) SetDeviceMACs(entityID string, macs []string)
- func (t *PresenceTracker) UpdateRoom(entityID, room, source string)
- type Property
- type RoomObserver
- type SaveContactArgs
- type StateGetter
- type Store
- func (s *Store) AddProperty(contactID uuid.UUID, p *Property) error
- func (s *Store) CTag() (string, error)
- func (s *Store) Close() error
- func (s *Store) Delete(id uuid.UUID) error
- func (s *Store) DeleteAllProperties(contactID uuid.UUID) error
- func (s *Store) DeleteByName(name string) error
- func (s *Store) DeleteContactProperties(contactID uuid.UUID, property string) error
- func (s *Store) DeleteProperty(id int64) error
- func (s *Store) FindByName(name string) (*Contact, error)
- func (s *Store) FindByNickname(name string) (*Contact, error)
- func (s *Store) FindByProperty(property, value string) ([]*Contact, error)
- func (s *Store) FindByPropertyExact(property, value string) ([]*Contact, error)
- func (s *Store) FindByTrustZone(zone string) ([]*Contact, error)
- func (s *Store) Get(id uuid.UUID) (*Contact, error)
- func (s *Store) GetContactsWithoutEmbeddings() ([]*Contact, error)
- func (s *Store) GetProperties(contactID uuid.UUID) ([]Property, error)
- func (s *Store) GetPropertiesMap(contactID uuid.UUID) (map[string][]string, error)
- func (s *Store) GetWithProperties(id uuid.UUID) (*Contact, error)
- func (s *Store) ListAll() ([]*Contact, error)
- func (s *Store) ListAllWithProperties() ([]*Contact, error)
- func (s *Store) ListByKind(kind string) ([]*Contact, error)
- func (s *Store) ResolveContact(name string) (*Contact, error)
- func (s *Store) Search(query string) ([]*Contact, error)
- func (s *Store) SemanticSearch(queryEmbedding []float32, limit int) ([]*Contact, []float32, error)
- func (s *Store) SetEmbedding(id uuid.UUID, embedding []float32) error
- func (s *Store) Stats() map[string]any
- func (s *Store) UpdateLastInteraction(contactID uuid.UUID, t time.Time, meta *InteractionMeta) error
- func (s *Store) Upsert(c *Contact) (*Contact, error)
- func (s *Store) UpsertWithProperties(c *Contact, props []Property) (*Contact, error)
- type Tools
- func (t *Tools) ExportAllVCF(argsJSON string) (string, error)
- func (t *Tools) ExportVCF(argsJSON string) (string, error)
- func (t *Tools) ExportVCFQR(argsJSON string) (string, error)
- func (t *Tools) ForgetContact(argsJSON string) (string, error)
- func (t *Tools) GenerateMissingEmbeddings() (int, error)
- func (t *Tools) ImportVCF(argsJSON string) (string, error)
- func (t *Tools) ListContacts(argsJSON string) (string, error)
- func (t *Tools) LookupContact(argsJSON string) (string, error)
- func (t *Tools) SaveContact(argsJSON string) (string, error)
- func (t *Tools) SetEmbeddingClient(client EmbeddingClient)
- func (t *Tools) SetSelfContactName(name string)
- type ZonePolicy
Constants ¶
const ( // ZoneAdmin is for system administrators (the Thane owner and // designated operators). Full frontier model access, unrestricted // tools, proactive outreach allowed, immediate send. ZoneAdmin = "admin" // ZoneHousehold is for household members and intimate family. // Full frontier model access, most tools available, proactive // outreach allowed, immediate send. ZoneHousehold = "household" // ZoneTrusted is for close friends, extended family, and // professional contacts with an established relationship. // Frontier model access, safe tool subset, limited proactive // outreach, sends require confirmation. ZoneTrusted = "trusted" // ZoneKnown is the default zone for contacts with a record but // no elevated trust. Local models only, read-only tool access, // no proactive outreach, sends blocked without explicit approval. ZoneKnown = "known" // ZoneUnknown represents unrecognized senders with no contact // record. This zone is NOT stored on contacts — it is the // implicit zone for messages from addresses that don't match any // contact. Local model access only (for triage), no tools, no // outreach, no sends. ZoneUnknown = "unknown" )
Trust zone constants define the access levels for contacts. Zones are listed from most-privileged to least-privileged.
Variables ¶
var ValidKinds = map[string]bool{ "individual": true, "group": true, "org": true, "location": true, }
ValidKinds is the set of allowed contact kind values (vCard KIND).
var ValidTrustZones = map[string]bool{ ZoneAdmin: true, ZoneHousehold: true, ZoneTrusted: true, ZoneKnown: true, }
ValidTrustZones is the set of trust zone values that can be stored on a contact record. ZoneUnknown is intentionally excluded — it is the implicit zone for senders with no contact record.
Functions ¶
func CardToContact ¶ added in v0.8.0
CardToContact converts a vcard.Card into a Contact and its Properties. The caller is responsible for setting the Contact ID and handling persistence via the store.
func ContactToCard ¶ added in v0.8.0
ContactToCard converts a Contact with its Properties into a vcard.Card. The contact must have Properties populated (via GetWithProperties).
func EncodeVCard ¶ added in v0.8.0
EncodeVCard serializes a Contact (with Properties populated) into vCard 4.0 text.
func EncodeVCards ¶ added in v0.8.0
EncodeVCards serializes multiple contacts into a multi-vCard text stream (concatenated BEGIN:VCARD ... END:VCARD blocks).
func FilterCardForTrustZone ¶ added in v0.8.0
FilterCardForTrustZone strips or adjusts vCard fields based on the recipient's trust zone. This is used when exporting the self-contact to share with contacts at different trust levels. The props parameter provides zone-tagged PHOTO properties for zone-specific photo resolution.
Types ¶
type Contact ¶
type Contact struct {
ID uuid.UUID `json:"id"`
Kind string `json:"kind"` // vCard KIND: individual, group, org, location
FormattedName string `json:"formatted_name"` // vCard FN (display name)
FamilyName string `json:"family_name,omitempty"` // vCard N component
GivenName string `json:"given_name,omitempty"` // vCard N component
AdditionalNames string `json:"additional_names,omitempty"` // vCard N component
NamePrefix string `json:"name_prefix,omitempty"` // vCard N component
NameSuffix string `json:"name_suffix,omitempty"` // vCard N component
Nickname string `json:"nickname,omitempty"` // vCard NICKNAME
Birthday string `json:"birthday,omitempty"` // vCard BDAY (ISO 8601)
Anniversary string `json:"anniversary,omitempty"` // vCard ANNIVERSARY
Gender string `json:"gender,omitempty"` // vCard GENDER
Org string `json:"org,omitempty"` // vCard ORG
Title string `json:"title,omitempty"` // vCard TITLE
Role string `json:"role,omitempty"` // vCard ROLE
Note string `json:"note,omitempty"` // vCard NOTE
PhotoURI string `json:"photo_uri,omitempty"` // vCard PHOTO URI
TrustZone string `json:"trust_zone"` // X-THANE-TRUST-ZONE
AISummary string `json:"ai_summary,omitempty"` // X-THANE-AI-SUMMARY
Rev string `json:"rev"` // vCard REV (ISO 8601)
ETag string `json:"etag,omitempty"` // CardDAV sync
Embedding []float32 `json:"embedding,omitempty"` // semantic search vector
LastInteraction time.Time `json:"last_interaction,omitempty"`
LastInteractionMeta *InteractionMeta `json:"last_interaction_meta,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Properties []Property `json:"properties,omitempty"` // populated by GetWithProperties
}
Contact represents a vCard-aligned contact record. Fields map to vCard 4.0 (RFC 6350) properties unless noted as Thane extensions.
type ContextProvider ¶
type ContextProvider struct {
// contains filtered or unexported fields
}
ContextProvider provides relevant contacts as context for the system prompt.
func NewContextProvider ¶
func NewContextProvider(store *Store, embeddings EmbeddingClient) *ContextProvider
NewContextProvider creates a context provider. A nil embeddings client is handled gracefully — GetContext returns empty context in that case.
func (*ContextProvider) GetContext ¶
GetContext returns relevant contacts formatted for the system prompt. Implements agent.ContextProvider interface.
func (*ContextProvider) SetMaxContacts ¶
func (p *ContextProvider) SetMaxContacts(n int)
SetMaxContacts configures how many contacts to include. Values less than 1 are clamped to 1.
func (*ContextProvider) SetMinScore ¶
func (p *ContextProvider) SetMinScore(score float32)
SetMinScore configures the minimum similarity threshold.
type EmbeddingClient ¶
EmbeddingClient generates embeddings for semantic search.
type ExportAllVCFArgs ¶ added in v0.8.0
type ExportAllVCFArgs struct {
Kind string `json:"kind,omitempty"`
TrustZone string `json:"trust_zone,omitempty"`
}
ExportAllVCFArgs are arguments for the export_all_vcf tool.
type ExportVCFArgs ¶ added in v0.8.0
type ExportVCFArgs struct {
Name string `json:"name"`
RecipientTrustZone string `json:"recipient_trust_zone,omitempty"`
Format string `json:"format,omitempty"` // "file" (default) or "text"
}
ExportVCFArgs are arguments for the export_vcf tool.
type ExportVCFQRArgs ¶ added in v0.8.0
type ExportVCFQRArgs struct {
Name string `json:"name"`
RecipientTrustZone string `json:"recipient_trust_zone,omitempty"`
}
ExportVCFQRArgs are arguments for the export_vcf_qr tool.
type ForgetContactArgs ¶
type ForgetContactArgs struct {
Name string `json:"name"`
}
ForgetContactArgs are arguments for the forget_contact tool.
type ImportVCFArgs ¶ added in v0.8.0
type ImportVCFArgs struct {
Path string `json:"path,omitempty"`
Text string `json:"text,omitempty"`
Merge *bool `json:"merge,omitempty"` // default true
DryRun bool `json:"dry_run,omitempty"`
}
ImportVCFArgs are arguments for the import_vcf tool.
type InteractionMeta ¶ added in v0.8.0
type InteractionMeta struct {
Channel string `json:"channel,omitempty"` // e.g. "signal", "email"
SessionID string `json:"session_id,omitempty"` // session that last interacted
Topics []string `json:"topics,omitempty"` // LLM-generated session tags
}
InteractionMeta holds structured metadata about a contact's most recent interaction. Stored as JSON in the last_interaction_meta column so new fields can be added without schema migrations.
type ListContactsArgs ¶
type ListContactsArgs struct {
Kind string `json:"kind,omitempty"`
Limit int `json:"limit,omitempty"`
}
ListContactsArgs are arguments for the list_contacts tool.
type LookupContactArgs ¶
type LookupContactArgs struct {
Name string `json:"name,omitempty"`
Query string `json:"query,omitempty"`
Kind string `json:"kind,omitempty"`
Key string `json:"key,omitempty"` // property or fact key filter
Value string `json:"value,omitempty"` // property or fact value filter
}
LookupContactArgs are arguments for the lookup_contact tool.
type Person ¶ added in v0.8.0
type Person struct {
EntityID string
FriendlyName string
State string
Since time.Time
DeviceMACs []string // configured MAC addresses for this person
Room string // inferred from AP association (e.g., "office")
RoomSince time.Time // when the current room was first detected
RoomSource string // AP name that determined the room (e.g., "ap-hor-office")
}
Person represents the current presence state of a tracked household member. State is typically "home", "not_home", or a zone name like "zone.work". Room fields are populated by an external poller (e.g., UniFi AP associations) when available.
type PresenceTracker ¶ added in v0.8.0
type PresenceTracker struct {
// contains filtered or unexported fields
}
PresenceTracker maintains in-memory presence state for configured person entities and provides a context block for system prompt injection. It implements both the StateWatchHandler function signature (for receiving WebSocket state changes) and the agent.ContextProvider interface (for context injection).
func NewPresenceTracker ¶ added in v0.8.0
func NewPresenceTracker(entityIDs []string, timezone string, logger *slog.Logger) *PresenceTracker
NewTracker creates a person tracker for the given entity IDs. All entities start in "Unknown" state until Initialize is called. The timezone is an IANA location string (e.g., "America/Chicago"); an empty or invalid timezone falls back to the system local timezone.
func (*PresenceTracker) EntityIDs ¶ added in v0.8.0
func (t *PresenceTracker) EntityIDs() []string
EntityIDs returns a copy of the tracked entity IDs. This is used to auto-merge person entities into the state watcher's entity filter globs so that person state changes are delivered regardless of the user's subscribe.entity_globs configuration. The returned slice is a defensive copy; callers cannot mutate internal state.
func (*PresenceTracker) GetContext ¶ added in v0.8.0
GetContext returns a formatted presence block for injection into the agent's system prompt. Returns an empty string if no entities are tracked. This method satisfies the agent.ContextProvider interface.
Output uses nested markdown with ISO 8601 timestamps for efficient model consumption. Fields are only emitted when they have values.
func (*PresenceTracker) HandleStateChange ¶ added in v0.8.0
func (t *PresenceTracker) HandleStateChange(entityID, _, newState string)
HandleStateChange updates the tracked person's state when a state_changed event is received. It matches the homeassistant.StateWatchHandler function signature. Untracked entities and no-change events are silently ignored. Room data is cleared when a person transitions to "not_home".
func (*PresenceTracker) Initialize ¶ added in v0.8.0
func (t *PresenceTracker) Initialize(ctx context.Context, ha StateGetter) error
Initialize fetches the current state of all tracked entities from the Home Assistant REST API. Entities that fail to load are logged and left in "Unknown" state. This method is idempotent and safe to call from a connwatch OnReady callback on every reconnection.
Network I/O is performed without holding the lock so that GetContext and HandleStateChange are not blocked during initialization.
func (*PresenceTracker) OnRoomChange ¶ added in v0.8.0
func (t *PresenceTracker) OnRoomChange(fn RoomObserver)
OnRoomChange registers a callback that fires whenever a tracked person's room changes. Observers are called outside the tracker's lock so they may perform blocking I/O (e.g., MQTT publishes). Must be called before the poller starts.
func (*PresenceTracker) SetDeviceMACs ¶ added in v0.8.0
func (t *PresenceTracker) SetDeviceMACs(entityID string, macs []string)
SetDeviceMACs configures the MAC addresses associated with a tracked person. These MACs are used by the UniFi poller to determine which person a wireless device belongs to. Must be called before the poller starts. Untracked entities are silently ignored.
func (*PresenceTracker) UpdateRoom ¶ added in v0.8.0
func (t *PresenceTracker) UpdateRoom(entityID, room, source string)
UpdateRoom sets the room for a tracked person. If the room is unchanged, no update occurs. When a person transitions to not_home, HandleStateChange clears room data automatically; callers may also pass an empty room to clear it explicitly. The source is the AP name or other identifier that determined the room.
Registered RoomObserver callbacks are invoked after the state update, outside the lock, so they may perform blocking operations.
type Property ¶ added in v0.8.0
type Property struct {
ID int64 `json:"id"`
ContactID uuid.UUID `json:"contact_id"`
Property string `json:"property"` // EMAIL, TEL, ADR, IMPP, URL, KEY, etc.
Value string `json:"value"`
Type string `json:"type,omitempty"` // TYPE param: work, home, cell, etc.
Pref int `json:"pref,omitempty"` // PREF param: 1-100, 0 = unset
Label string `json:"label,omitempty"` // LABEL param
MediaType string `json:"mediatype,omitempty"` // MEDIATYPE param
Verified bool `json:"verified,omitempty"` // has Thane verified traffic from this?
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Property represents a structured vCard property on a contact. Repeatable, parameterised properties (EMAIL, TEL, ADR, IMPP, URL, KEY, CATEGORIES, RELATED, MEMBER, etc.) are stored here rather than on the Contact struct directly.
type RoomObserver ¶ added in v0.8.0
type RoomObserver func(entityID, room, source string)
RoomObserver is called when a tracked person's room changes. Parameters are the person's entity ID, the new room name (may be empty when cleared), and the AP or source name that determined the room. Observers are called outside the tracker's lock.
type SaveContactArgs ¶
type SaveContactArgs struct {
Name string `json:"name"` // maps to FormattedName
Kind string `json:"kind,omitempty"` // individual, group, org, location
TrustZone string `json:"trust_zone,omitempty"` // admin, household, trusted, known
GivenName string `json:"given_name,omitempty"` // vCard N given name
FamilyName string `json:"family_name,omitempty"` // vCard N family name
Nickname string `json:"nickname,omitempty"` // vCard NICKNAME
Org string `json:"org,omitempty"` // vCard ORG
Title string `json:"title,omitempty"` // vCard TITLE
Role string `json:"role,omitempty"` // vCard ROLE
Note string `json:"note,omitempty"` // vCard NOTE
AISummary string `json:"ai_summary,omitempty"` // AI-generated context
Facts map[string]string `json:"facts,omitempty"` // freeform AI metadata
}
SaveContactArgs are arguments for the save_contact tool.
type StateGetter ¶ added in v0.8.0
type StateGetter interface {
GetState(ctx context.Context, entityID string) (*homeassistant.State, error)
}
StateGetter abstracts the Home Assistant REST client for fetching entity state. Using an interface keeps the tracker testable without a real HA instance.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages contact persistence in SQLite.
func (*Store) AddProperty ¶ added in v0.8.0
AddProperty adds a vCard property to a contact. If the exact (contact_id, property, value) triple already exists (case-insensitive on value), this is a no-op. Multiple values per property are supported.
func (*Store) CTag ¶ added in v0.8.0
CTag returns the collection tag for the address book. This is the maximum updated_at timestamp across all active contacts, formatted as RFC 3339. CardDAV clients compare this value to decide whether a full sync is needed.
func (*Store) DeleteAllProperties ¶ added in v0.8.0
DeleteAllProperties removes all properties from a contact.
func (*Store) DeleteByName ¶
DeleteByName soft-deletes a contact by name, using [ResolveContact] for cascading name resolution.
func (*Store) DeleteContactProperties ¶ added in v0.8.0
DeleteContactProperties removes all properties of a given type from a contact.
func (*Store) DeleteProperty ¶ added in v0.8.0
DeleteProperty removes a single property row by its ID.
func (*Store) FindByName ¶
FindByName returns the first active contact with a case-insensitive formatted name match. Returns sql.ErrNoRows if not found.
func (*Store) FindByNickname ¶ added in v0.8.0
FindByNickname returns the first active contact with a case-insensitive nickname match. Returns sql.ErrNoRows if not found.
func (*Store) FindByProperty ¶ added in v0.8.0
FindByProperty returns contacts with a LIKE-matched property value.
func (*Store) FindByPropertyExact ¶ added in v0.8.0
FindByPropertyExact returns contacts with an exact property-value match. The value comparison is case-insensitive.
func (*Store) FindByTrustZone ¶
FindByTrustZone returns all active contacts in the given trust zone.
func (*Store) GetContactsWithoutEmbeddings ¶
GetContactsWithoutEmbeddings returns contacts that need embeddings.
func (*Store) GetProperties ¶ added in v0.8.0
GetProperties returns all properties for a contact, ordered by property name then preference.
func (*Store) GetPropertiesMap ¶ added in v0.8.0
GetPropertiesMap returns all properties for a contact grouped by property name as a map of name→values. This is a convenience view for callers that don't need the full Property metadata.
func (*Store) GetWithProperties ¶ added in v0.8.0
GetWithProperties retrieves a contact by ID and populates its Properties slice.
func (*Store) ListAllWithProperties ¶ added in v0.8.0
ListAllWithProperties returns all active contacts with their Properties slices populated. Unlike [ListAll], there is no row limit — this is intended for full-sync use cases like CardDAV.
Properties are fetched in a single query and grouped in-memory to avoid N+1 query overhead on larger address books.
func (*Store) ListByKind ¶
ListByKind returns all active contacts of the given kind.
func (*Store) ResolveContact ¶ added in v0.8.0
ResolveContact finds a contact by name using cascading resolution strategies: exact formatted name → nickname → search fallback. Returns sql.ErrNoRows if no match is found, or an error listing ambiguous matches if search returns multiple results.
func (*Store) SemanticSearch ¶
SemanticSearch finds contacts similar to the query embedding.
func (*Store) SetEmbedding ¶
SetEmbedding updates a contact's embedding vector.
func (*Store) UpdateLastInteraction ¶ added in v0.8.0
func (s *Store) UpdateLastInteraction(contactID uuid.UUID, t time.Time, meta *InteractionMeta) error
UpdateLastInteraction updates a contact's last interaction timestamp and metadata without touching any other fields. This is a targeted update for the summarizer callback — it avoids a full Upsert which would require populating all contact fields.
func (*Store) Upsert ¶
Upsert creates or updates a contact. If the contact has no ID, a new UUIDv7 is assigned. Soft-deleted contacts with the same ID are resurrected. Rev is automatically set to the current timestamp.
func (*Store) UpsertWithProperties ¶ added in v0.8.0
UpsertWithProperties creates or updates a contact and replaces all its properties in a single transaction. This is used by CardDAV PUT to ensure the contact row and property rows are updated atomically — a partial failure rolls back cleanly.
Unlike [Upsert], a non-nil ID that does not yet exist in the database is INSERT-ed (enabling CardDAV clients to create contacts by PUTing to a new URL).
type Tools ¶
type Tools struct {
// contains filtered or unexported fields
}
Tools provides contact-related tools for the agent.
func (*Tools) ExportAllVCF ¶ added in v0.8.0
ExportAllVCF exports all contacts (optionally filtered) as a multi-vCard file.
func (*Tools) ExportVCF ¶ added in v0.8.0
ExportVCF exports a single contact as a vCard. When name is "self", it resolves via the configured self-contact name. The optional recipient_trust_zone applies trust-zone field filtering (self-contact only).
func (*Tools) ExportVCFQR ¶ added in v0.8.0
ExportVCFQR generates a QR code PNG containing a vCard for the named contact. Returns the path to the generated PNG file. The vCard text must fit within QR code capacity (~4KB).
func (*Tools) ForgetContact ¶
ForgetContact soft-deletes a contact by name.
func (*Tools) GenerateMissingEmbeddings ¶
GenerateMissingEmbeddings creates embeddings for contacts that don't have them.
func (*Tools) ImportVCF ¶ added in v0.8.0
ImportVCF imports contacts from a vCard file or text. When merge is true (default), existing contacts are matched by EMAIL then by name, and only empty fields are filled. TrustZone and AISummary are never overwritten during merge. Properties are additive.
func (*Tools) ListContacts ¶
ListContacts returns contacts from the directory, optionally filtered by kind and capped by a limit.
func (*Tools) LookupContact ¶
LookupContact retrieves contacts from the directory.
func (*Tools) SaveContact ¶
SaveContact creates or updates a contact. When a contact with the given name already exists, only non-empty fields are overwritten. Facts are additive. Email and phone values are stored as vCard properties (EMAIL, TEL) in contact_properties.
Top-level string fields that don't match known SaveContactArgs keys (e.g., "email", "phone") are automatically rescued into the Facts map or contact_properties, since models frequently flatten them.
func (*Tools) SetEmbeddingClient ¶
func (t *Tools) SetEmbeddingClient(client EmbeddingClient)
SetEmbeddingClient sets the embedding client for semantic search.
func (*Tools) SetSelfContactName ¶ added in v0.8.0
SetSelfContactName sets the contact name used to resolve name="self" in export operations.
type ZonePolicy ¶ added in v0.8.0
type ZonePolicy struct {
// Zone is the trust zone this policy applies to.
Zone string
// FrontierModelAccess indicates whether frontier/cloud models
// (e.g., Anthropic) may be used for this contact's requests.
FrontierModelAccess bool
// LocalModelOnly restricts the contact to local models only
// (e.g., Ollama). Mutually exclusive with FrontierModelAccess
// in practice — if both are false, no model access is granted.
LocalModelOnly bool
// ProactiveOutreach describes whether the agent may initiate
// contact: "full", "limited", or "none".
ProactiveOutreach string
// ToolAccess describes the tool permission level:
// "unrestricted", "most", "safe", "readonly", or "none".
ToolAccess string
// SendGating describes outbound message policy:
// "allowed", "confirmation", or "blocked".
SendGating string
}
ZonePolicy encodes the capability matrix for a trust zone. Each field captures a dimension of what the agent is permitted to do when interacting with a contact at that trust level. Downstream consumers (model routing, notification priority, send gating) can query Policy(zone) instead of hardcoding zone names.
func Policies ¶ added in v0.8.0
func Policies() []ZonePolicy
Policies returns all zone policies in hierarchy order from highest privilege (admin) to lowest (unknown).
func Policy ¶ added in v0.8.0
func Policy(zone string) ZonePolicy
Policy returns the ZonePolicy for the given zone string. Unrecognized zone values fall back to the ZoneUnknown policy.