Documentation
¶
Index ¶
- Variables
- type AgentRecord
- type BindingMatch
- type CreateAgentOptions
- type DynamicAgentRegistry
- func (r *DynamicAgentRegistry) Bind(ctx context.Context, agentID string, match BindingMatch) error
- func (r *DynamicAgentRegistry) Create(ctx context.Context, opts CreateAgentOptions) (AgentRecord, error)
- func (r *DynamicAgentRegistry) Get(ctx context.Context, id string) (AgentRecord, bool, error)
- func (r *DynamicAgentRegistry) List(ctx context.Context) ([]AgentRecord, error)
- func (r *DynamicAgentRegistry) Resolve(ctx context.Context, match BindingMatch) (string, bool, error)
- func (r *DynamicAgentRegistry) Unbind(ctx context.Context, match BindingMatch) error
Constants ¶
This section is empty.
Variables ¶
var ErrAgentIDInvalid = errors.New("goncho: dynamic agent name does not normalize to a valid id")
ErrAgentIDInvalid is returned when the normalized AgentID would not match the pattern accepted by config.AgentsCfg (^[a-z][a-z0-9_-]{0,63}$). The caller should report the underlying name back to the operator.
var ErrAgentIDReserved = errors.New("goncho: dynamic agent id reserved by static config")
ErrAgentIDReserved is returned by Create when the requested name would normalize to an AgentID that is already claimed by the static config (passed via CreateAgentOptions.ReservedIDs). Operator-defined identity in config.toml must not be silently shadowed by a runtime spawn.
Functions ¶
This section is empty.
Types ¶
type AgentRecord ¶
AgentRecord describes a runtime-spawned agent persisted in the dynamic registry. Static config.AgentCfg remains the operator-defined surface; AgentRecord is the runtime overlay layered on top of it.
type BindingMatch ¶
BindingMatch describes a (channel, peer) tuple that should resolve to a dynamic AgentID at runtime. ThreadID is optional and stored as an empty string when absent; matches are scoped exactly so the General topic of a Telegram forum and one of its named topics never share a binding row.
type CreateAgentOptions ¶
CreateAgentOptions parameterizes DynamicAgentRegistry.Create. Name is required; the registry normalizes it to an AgentID compatible with config.AgentsCfg. ReservedIDs (typically the set of static AgentCfg.IDs observed at the time of the call) prevents the runtime registry from silently shadowing an operator-defined identity.
type DynamicAgentRegistry ¶
type DynamicAgentRegistry struct {
// contains filtered or unexported fields
}
DynamicAgentRegistry persists runtime-spawned agents and their channel bindings in the Goncho SQLite database. The registry knows nothing about the gateway resolver or channel adapters; callers compose it with the existing config.AgentsCfg overlay at the gateway boundary.
func NewDynamicAgentRegistry ¶
func NewDynamicAgentRegistry(db *sql.DB) (*DynamicAgentRegistry, error)
NewDynamicAgentRegistry opens (or migrates) the dynamic agent tables and returns a registry bound to db. The DDL is idempotent — calling the constructor twice on the same database is safe.
func (*DynamicAgentRegistry) Bind ¶
func (r *DynamicAgentRegistry) Bind(ctx context.Context, agentID string, match BindingMatch) error
Bind associates agentID with match. Re-binding the same tuple replaces the previous AgentID — the most recent runtime decision wins.
func (*DynamicAgentRegistry) Create ¶
func (r *DynamicAgentRegistry) Create(ctx context.Context, opts CreateAgentOptions) (AgentRecord, error)
Create inserts a new dynamic agent. Returns ErrAgentIDReserved if the normalized AgentID is present in opts.ReservedIDs, and ErrAgentIDInvalid if the name does not normalize to a config-compatible AgentID.
func (*DynamicAgentRegistry) Get ¶
func (r *DynamicAgentRegistry) Get(ctx context.Context, id string) (AgentRecord, bool, error)
Get returns the AgentRecord for id, if any. The second return value is false (no error) when the id is unknown.
func (*DynamicAgentRegistry) List ¶
func (r *DynamicAgentRegistry) List(ctx context.Context) ([]AgentRecord, error)
List returns every dynamic AgentRecord ordered by creation time, oldest first. Empty registries return an empty slice with no error.
func (*DynamicAgentRegistry) Resolve ¶
func (r *DynamicAgentRegistry) Resolve(ctx context.Context, match BindingMatch) (string, bool, error)
Resolve returns the dynamic AgentID bound to match, if any. The second return value is false (no error) when no binding exists; callers should then fall back to static config.AgentBindingCfg at the gateway boundary.
func (*DynamicAgentRegistry) Unbind ¶
func (r *DynamicAgentRegistry) Unbind(ctx context.Context, match BindingMatch) error
Unbind removes the binding for match. Unbinding an unknown tuple is a no-op so callers can call Unbind defensively without checking Resolve first. The associated AgentRecord is preserved — Unbind only releases the (channel, peer, thread) -> agent mapping.