command

package
v0.0.0-...-0b7ba76 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("not available in this configuration")

ErrUnsupported is returned by Runtime methods whose capability is unavailable in the current configuration (e.g. allow-list ops with no store).

Functions

This section is empty.

Types

type Definition

type Definition struct {
	Name        string
	Description string
	Usage       string
	Handler     func(ctx context.Context, req Request, rt Runtime) error
}

Definition describes a slash command.

func Builtin

func Builtin() []Definition

Builtin returns the default set of slash commands.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry maps slash command names to their definitions.

func NewRegistry

func NewRegistry(defs []Definition) *Registry

NewRegistry builds a Registry from defs and auto-registers /help.

func (*Registry) All

func (r *Registry) All() []Definition

All returns a copy of all registered definitions.

func (*Registry) Lookup

func (r *Registry) Lookup(name string) (Definition, bool)

Lookup finds a command by name (without the leading slash), case-insensitive.

type Request

type Request struct {
	Text      string
	ChatID    string
	UserID    string
	Connector string
	Reply     func(text string) error
}

Request carries an incoming slash command plus a reply callback.

type Runtime

type Runtime interface {
	ClearHistory() error
	IsAdmin() bool
	FactoryReset() error // admin only: wipes soul + role + memories + history
	Info() UserInfo
	// Allow-list management (admin only), scoped to the request's connector.
	AllowAdd(number string) error
	AllowRemove(number string) error
	AllowList() ([]string, error)
	// ResolveApproval approves (true) or denies (false) a parked tool call by id.
	// It sends its own replies and continues the agent's tool loop.
	ResolveApproval(approve bool, id string)
	// GenerateLinkCode mints a one-time code so another chat can link to this
	// account (see RedeemLinkCode). Returns ErrUnsupported with no store.
	GenerateLinkCode() (string, error)
	// RedeemLinkCode links this identity to the account that generated code,
	// returning a label for the now-shared account.
	RedeemLinkCode(code string) (string, error)
	// Unlink detaches this identity from its linked account.
	Unlink() error
	// LinkStatus reports whether this identity is linked, with a short detail.
	LinkStatus() (linked bool, detail string)
}

Runtime gives command handlers access to agent capabilities scoped to the current request. The agent supplies a concrete implementation per command. Methods backed by a store return ErrUnsupported when none is configured.

type UserInfo

type UserInfo struct {
	Connector string
	UserID    string
	Soul      string
	Role      string
	LLMModel  string
	Provider  string
}

UserInfo carries the resolved identity for the current request.

Jump to

Keyboard shortcuts

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