dynamicagents

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
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

type AgentRecord struct {
	ID        string
	Name      string
	Persona   string
	CreatedAt time.Time
}

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

type BindingMatch struct {
	Channel  string
	PeerKind string
	PeerID   string
	ThreadID string
}

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

type CreateAgentOptions struct {
	Name        string
	Persona     string
	ReservedIDs map[string]struct{}
}

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

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

Get returns the AgentRecord for id, if any. The second return value is false (no error) when the id is unknown.

func (*DynamicAgentRegistry) List

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL