skills

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package skills provides the skill registry and execution system. This file contains built-in skill implementations.

Package skills provides crypto skills registration

Package skills provides Alchemy blockchain API skill implementation

Package skills provides blockchain monitoring skill implementation

Package skills provides IPFS skill implementation using official go-ipfs-http-client

Package skills provides crypto utility functions using modern Go crypto libraries

Package skills provides wallet security monitoring skill implementation

Package skills provides the skill registry and execution system.

Package skills provides the skill registry and execution system.

Index

Constants

This section is empty.

Variables

View Source
var AlchemyNetworks = map[string]struct {
	Name    string
	ChainID int64
}{
	"eth-mainnet":      {"Ethereum Mainnet", 1},
	"eth-sepolia":      {"Ethereum Sepolia Testnet", 11155111},
	"polygon-mainnet":  {"Polygon Mainnet", 137},
	"polygon-amoy":     {"Polygon Amoy Testnet", 80002},
	"arbitrum-mainnet": {"Arbitrum One", 42161},
	"arbitrum-sepolia": {"Arbitrum Sepolia", 421614},
	"optimism-mainnet": {"Optimism Mainnet", 10},
	"optimism-sepolia": {"Optimism Sepolia", 11155420},
	"base-mainnet":     {"Base Mainnet", 8453},
	"base-sepolia":     {"Base Sepolia", 84532},
}

Supported Alchemy networks with chain IDs

Functions

func AlchemyHandler

func AlchemyHandler(args map[string]interface{}, configLoader ConfigLoader) (interface{}, error)

AlchemyHandler handles Alchemy skill execution

func AssertContains

func AssertContains(t *testing.T, str, substr, msg string)

AssertContains checks if a string contains a substring

func AssertEqual

func AssertEqual(t *testing.T, expected, actual interface{}, msg string)

AssertEqual checks if two values are equal

func AssertError

func AssertError(t *testing.T, err error, msg string)

AssertError is a test helper to check that an error occurred

func AssertNoError

func AssertNoError(t *testing.T, err error, msg string)

AssertNoError is a test helper to check for errors

func Base64DecodeHandler

func Base64DecodeHandler(args map[string]interface{}) (interface{}, error)

Base64DecodeHandler decodes a base64 string.

func Base64EncodeHandler

func Base64EncodeHandler(args map[string]interface{}) (interface{}, error)

Base64EncodeHandler encodes text to base64.

func BlockmonHandler

func BlockmonHandler(args map[string]interface{}, configLoader ConfigLoader) (interface{}, error)

BlockmonHandler handles blockchain monitoring skill execution

func BuildAlchemyURL

func BuildAlchemyURL(network, apiKey string) string

BuildAlchemyURL constructs the Alchemy API URL

func CreateDefaultSkillFiles

func CreateDefaultSkillFiles() error

CreateDefaultSkillFiles creates default skill JSON files in ~/.celeste/skills/

func CurrencyConverterHandler

func CurrencyConverterHandler(args map[string]interface{}) (interface{}, error)

CurrencyConverterHandler converts between currencies using exchangerate-api.com.

func EtherToWei

func EtherToWei(etherStr string) (*big.Int, error)

EtherToWei converts Ether string to Wei (*big.Int) Uses params.Ether from go-ethereum for accurate conversion

func FormatResultForLLM

func FormatResultForLLM(toolCallID string, result *ExecutionResult) map[string]interface{}

FormatResultForLLM formats an execution result for sending back to the LLM.

func GetChainID

func GetChainID(network string) (int64, error)

GetChainID returns the chain ID for a given network

func GetNoteHandler

func GetNoteHandler(args map[string]interface{}) (interface{}, error)

GetNoteHandler retrieves a note.

func GweiToWei

func GweiToWei(gwei int64) *big.Int

GweiToWei converts Gwei to Wei (useful for gas prices)

func HashGeneratorHandler

func HashGeneratorHandler(args map[string]interface{}) (interface{}, error)

HashGeneratorHandler generates a hash for the given text.

func IPFSHandler

func IPFSHandler(args map[string]interface{}, configLoader ConfigLoader) (interface{}, error)

IPFSHandler handles IPFS skill execution

func IsValidEthereumAddress

func IsValidEthereumAddress(addr string) bool

IsValidEthereumAddress validates an Ethereum address using go-ethereum This uses the official implementation with proper checksum validation

func ListNotesHandler

func ListNotesHandler(args map[string]interface{}) (interface{}, error)

ListNotesHandler lists all notes.

func ListRemindersHandler

func ListRemindersHandler(args map[string]interface{}) (interface{}, error)

ListRemindersHandler lists all reminders.

func NormalizeAddress

func NormalizeAddress(addr string) (string, error)

NormalizeAddress returns a checksummed Ethereum address using EIP-55 This is the proper way to handle Ethereum addresses

func ParseAddress

func ParseAddress(addr string) (common.Address, error)

ParseAddress parses a string into a common.Address (go-ethereum type)

func PasswordGeneratorHandler

func PasswordGeneratorHandler(args map[string]interface{}) (interface{}, error)

PasswordGeneratorHandler generates a secure random password.

func QRCodeGeneratorHandler

func QRCodeGeneratorHandler(args map[string]interface{}) (interface{}, error)

QRCodeGeneratorHandler generates a QR code from text.

func RegisterBuiltinSkills

func RegisterBuiltinSkills(registry *Registry, configLoader ConfigLoader)

RegisterBuiltinSkills registers all built-in skills with the registry.

func RegisterCryptoSkills

func RegisterCryptoSkills(registry *Registry, configLoader ConfigLoader)

RegisterCryptoSkills registers all cryptocurrency and blockchain skills

func SaveNoteHandler

func SaveNoteHandler(args map[string]interface{}) (interface{}, error)

SaveNoteHandler saves a note.

func SetReminderHandler

func SetReminderHandler(args map[string]interface{}) (interface{}, error)

SetReminderHandler sets a reminder.

func TarotHandler

func TarotHandler(args map[string]interface{}, configLoader ConfigLoader) (interface{}, error)

TarotHandler executes a tarot reading.

func TimezoneConverterHandler

func TimezoneConverterHandler(args map[string]interface{}) (interface{}, error)

TimezoneConverterHandler converts time between timezones.

func TwitchLiveCheckHandler

func TwitchLiveCheckHandler(args map[string]interface{}, configLoader ConfigLoader) (interface{}, error)

TwitchLiveCheckHandler checks if a Twitch streamer is live.

func UUIDGeneratorHandler

func UUIDGeneratorHandler(args map[string]interface{}) (interface{}, error)

UUIDGeneratorHandler generates a UUID v4.

func UnitConverterHandler

func UnitConverterHandler(args map[string]interface{}) (interface{}, error)

UnitConverterHandler converts between different units.

func ValidateAlchemyNetwork

func ValidateAlchemyNetwork(network string) error

ValidateAlchemyNetwork checks if a network identifier is valid

func WalletSecurityHandler

func WalletSecurityHandler(args map[string]interface{}, configLoader ConfigLoader) (interface{}, error)

WalletSecurityHandler handles wallet security skill execution

func WeatherHandler

func WeatherHandler(args map[string]interface{}, configLoader ConfigLoader) (interface{}, error)

WeatherHandler gets weather forecast for a location.

func WeiToEther

func WeiToEther(wei *big.Int) string

WeiToEther converts Wei (*big.Int) to Ether as a formatted string Uses params.Ether from go-ethereum for accurate conversion

func WeiToGwei

func WeiToGwei(wei *big.Int) int64

WeiToGwei converts Wei to Gwei (useful for displaying gas prices)

func YouTubeVideosHandler

func YouTubeVideosHandler(args map[string]interface{}, configLoader ConfigLoader) (interface{}, error)

YouTubeVideosHandler gets recent videos from a YouTube channel.

Types

type AlchemyConfig

type AlchemyConfig struct {
	APIKey         string
	DefaultNetwork string
	TimeoutSeconds int
}

AlchemyConfig holds Alchemy API configuration.

type AlertsLog

type AlertsLog struct {
	Alerts []SecurityAlert `json:"alerts"`
}

AlertsLog stores all security alerts

type ApprovalEvent

type ApprovalEvent struct {
	Owner         string   // Wallet that granted approval
	Spender       string   // Contract/address that can spend
	Value         *big.Int // Approved amount
	TokenContract string   // ERC20 contract address
	TxHash        string
	BlockNumber   string
	IsUnlimited   bool // True if value == max uint256
}

ApprovalEvent represents an ERC20 token approval

type AssetTransfer

type AssetTransfer struct {
	Category        string
	BlockNum        string
	From            string
	To              string
	Value           float64
	Asset           string
	Hash            string
	RawContract     struct{ Address string }
	TokenId         string
	ERC721TokenId   string
	ERC1155Metadata []struct {
		TokenId string
		Value   string
	}
}

AssetTransfer represents a blockchain asset transfer (from crypto_blockmon.go pattern)

type BlockmonConfig

type BlockmonConfig struct {
	AlchemyAPIKey       string
	WebhookURL          string
	DefaultNetwork      string
	PollIntervalSeconds int
}

BlockmonConfig holds blockchain monitoring configuration.

type ConfigLoader

type ConfigLoader interface {
	GetTarotConfig() (TarotConfig, error)
	GetVeniceConfig() (VeniceConfig, error)
	GetWeatherConfig() (WeatherConfig, error)
	GetTwitchConfig() (TwitchConfig, error)
	GetYouTubeConfig() (YouTubeConfig, error)
	GetIPFSConfig() (IPFSConfig, error)
	GetAlchemyConfig() (AlchemyConfig, error)
	GetBlockmonConfig() (BlockmonConfig, error)
	GetWalletSecurityConfig() (WalletSecuritySettingsConfig, error)
}

ConfigLoader provides access to configuration values.

type ExecutionContext

type ExecutionContext struct {
	Ctx      context.Context
	Registry *Registry
	OnStatus func(status string) // Callback for status updates
}

ExecutionContext provides context for skill execution.

type ExecutionResult

type ExecutionResult struct {
	Success bool        `json:"success"`
	Result  interface{} `json:"result,omitempty"`
	Error   string      `json:"error,omitempty"`
	Time    time.Time   `json:"timestamp"`
}

ExecutionResult represents the result of a skill execution.

type Executor

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

Executor handles skill execution with context and callbacks.

func NewExecutor

func NewExecutor(registry *Registry) *Executor

NewExecutor creates a new skill executor.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, name string, argsJSON string) (*ExecutionResult, error)

Execute runs a skill by name with the given arguments.

func (*Executor) ExecuteFromToolCall

func (e *Executor) ExecuteFromToolCall(ctx context.Context, toolCall ToolCall) (*ExecutionResult, error)

ExecuteFromToolCall executes a skill from an OpenAI tool call format.

type FunctionCall

type FunctionCall struct {
	Name      string `json:"name"`
	Arguments string `json:"arguments"`
}

FunctionCall represents the function details in a tool call.

type IPFSConfig

type IPFSConfig struct {
	Provider       string
	APIKey         string
	APISecret      string
	ProjectID      string
	GatewayURL     string
	TimeoutSeconds int
}

IPFSConfig holds IPFS configuration.

type MockConfigLoader

type MockConfigLoader struct {
	TarotCfg          TarotConfig
	VeniceCfg         VeniceConfig
	WeatherCfg        WeatherConfig
	TwitchCfg         TwitchConfig
	YouTubeCfg        YouTubeConfig
	IPFSCfg           IPFSConfig
	AlchemyCfg        AlchemyConfig
	BlockmonCfg       BlockmonConfig
	WalletSecurityCfg WalletSecuritySettingsConfig

	// Error flags to simulate missing config
	TarotError          error
	VeniceError         error
	WeatherError        error
	TwitchError         error
	YouTubeError        error
	IPFSError           error
	AlchemyError        error
	BlockmonError       error
	WalletSecurityError error
}

MockConfigLoader provides a mock implementation of configuration loading for testing

func NewMockConfigLoader

func NewMockConfigLoader() *MockConfigLoader

NewMockConfigLoader creates a mock config loader with default values

func NewMockConfigLoaderWithErrors

func NewMockConfigLoaderWithErrors() *MockConfigLoader

NewMockConfigLoaderWithErrors creates a mock that returns errors for all configs

func (*MockConfigLoader) GetAlchemyConfig

func (m *MockConfigLoader) GetAlchemyConfig() (AlchemyConfig, error)

GetAlchemyConfig returns mock Alchemy configuration

func (*MockConfigLoader) GetBlockmonConfig

func (m *MockConfigLoader) GetBlockmonConfig() (BlockmonConfig, error)

GetBlockmonConfig returns mock blockchain monitoring configuration

func (*MockConfigLoader) GetIPFSConfig

func (m *MockConfigLoader) GetIPFSConfig() (IPFSConfig, error)

GetIPFSConfig returns mock IPFS configuration

func (*MockConfigLoader) GetTarotConfig

func (m *MockConfigLoader) GetTarotConfig() (TarotConfig, error)

GetTarotConfig returns mock tarot configuration

func (*MockConfigLoader) GetTwitchConfig

func (m *MockConfigLoader) GetTwitchConfig() (TwitchConfig, error)

GetTwitchConfig returns mock Twitch configuration

func (*MockConfigLoader) GetVeniceConfig

func (m *MockConfigLoader) GetVeniceConfig() (VeniceConfig, error)

GetVeniceConfig returns mock Venice.ai configuration

func (*MockConfigLoader) GetWalletSecurityConfig

func (m *MockConfigLoader) GetWalletSecurityConfig() (WalletSecuritySettingsConfig, error)

GetWalletSecurityConfig returns mock wallet security configuration

func (*MockConfigLoader) GetWeatherConfig

func (m *MockConfigLoader) GetWeatherConfig() (WeatherConfig, error)

GetWeatherConfig returns mock weather configuration

func (*MockConfigLoader) GetYouTubeConfig

func (m *MockConfigLoader) GetYouTubeConfig() (YouTubeConfig, error)

GetYouTubeConfig returns mock YouTube configuration

type MonitoredWallet

type MonitoredWallet struct {
	Address string    `json:"address"` // EIP-55 checksummed
	Label   string    `json:"label"`
	Network string    `json:"network"`
	AddedAt time.Time `json:"added_at"`
}

MonitoredWallet represents a wallet being monitored

type Note

type Note struct {
	Title   string    `json:"title"`
	Content string    `json:"content"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

Note represents a note entry.

type RateLimiter

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

RateLimiter wraps golang.org/x/time/rate.Limiter Provides production-ready token bucket rate limiting

func NewRateLimiter

func NewRateLimiter(requestsPerSecond int) *RateLimiter

NewRateLimiter creates a rate limiter with specified requests per second Uses the official golang.org/x/time/rate package

func (*RateLimiter) Allow

func (rl *RateLimiter) Allow() bool

Allow checks if a request is allowed without blocking

func (*RateLimiter) SetRate

func (rl *RateLimiter) SetRate(requestsPerSecond int)

SetRate updates the rate limit dynamically

func (*RateLimiter) Wait

func (rl *RateLimiter) Wait(ctx context.Context) error

Wait blocks until a token is available or context is cancelled

type Registry

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

Registry manages skill definitions and execution.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new skill registry.

func (*Registry) Count

func (r *Registry) Count() int

Count returns the number of registered skills.

func (*Registry) DeleteSkill

func (r *Registry) DeleteSkill(name string) error

DeleteSkill removes a skill from the registry and deletes its file.

func (*Registry) Execute

func (r *Registry) Execute(name string, args map[string]interface{}) (interface{}, error)

Execute runs a skill by name with the given arguments.

func (*Registry) GetAllSkills

func (r *Registry) GetAllSkills() []Skill

GetAllSkills returns all registered skills.

func (*Registry) GetSkill

func (r *Registry) GetSkill(name string) (Skill, bool)

GetSkill returns a skill by name.

func (*Registry) GetToolDefinitions

func (r *Registry) GetToolDefinitions() []map[string]interface{}

GetToolDefinitions returns skills in OpenAI tool format for API calls.

func (*Registry) HasHandler

func (r *Registry) HasHandler(name string) bool

HasHandler checks if a skill has a registered handler.

func (*Registry) LoadSkills

func (r *Registry) LoadSkills() error

LoadSkills loads all skill definitions from the skills directory.

func (*Registry) RegisterHandler

func (r *Registry) RegisterHandler(name string, handler SkillHandler)

RegisterHandler registers a handler function for a skill.

func (*Registry) RegisterSkill

func (r *Registry) RegisterSkill(skill Skill)

RegisterSkill manually registers a skill definition.

func (*Registry) SaveSkill

func (r *Registry) SaveSkill(skill Skill) error

SaveSkill saves a skill definition to the skills directory.

func (*Registry) SetSkillsDir

func (r *Registry) SetSkillsDir(dir string)

SetSkillsDir sets the directory to load skills from.

type Reminder

type Reminder struct {
	ID      string    `json:"id"`
	Message string    `json:"message"`
	Time    time.Time `json:"time"`
	Created time.Time `json:"created"`
}

Reminder represents a reminder entry.

type SecurityAlert

type SecurityAlert struct {
	ID             string                 `json:"id"`             // alert_<timestamp>_<random>
	WalletAddress  string                 `json:"wallet_address"` // Affected wallet
	AlertType      string                 `json:"alert_type"`     // dust_attack, nft_scam, dangerous_approval, large_transfer
	Severity       string                 `json:"severity"`       // low, medium, high, critical
	TxHash         string                 `json:"tx_hash"`        // Transaction hash
	BlockNumber    string                 `json:"block_number"`
	Description    string                 `json:"description"` // Human-readable description
	Details        map[string]interface{} `json:"details"`     // Type-specific details
	DetectedAt     time.Time              `json:"detected_at"`
	Acknowledged   bool                   `json:"acknowledged"`
	AcknowledgedAt *time.Time             `json:"acknowledged_at,omitempty"`
}

SecurityAlert represents a detected security threat

type Skill

type Skill struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Parameters  map[string]interface{} `json:"parameters"`
	Handler     string                 `json:"handler,omitempty"` // Not used in Go, skills are built-in
}

Skill represents a skill definition loaded from JSON.

func AlchemySkill

func AlchemySkill() Skill

AlchemySkill returns the Alchemy skill definition

func Base64DecodeSkill

func Base64DecodeSkill() Skill

Base64DecodeSkill returns the base64 decoder skill definition.

func Base64EncodeSkill

func Base64EncodeSkill() Skill

Base64EncodeSkill returns the base64 encoder skill definition.

func BlockmonSkill

func BlockmonSkill() Skill

BlockmonSkill returns the blockchain monitoring skill definition

func CurrencyConverterSkill

func CurrencyConverterSkill() Skill

CurrencyConverterSkill returns the currency converter skill definition.

func GetNoteSkill

func GetNoteSkill() Skill

GetNoteSkill returns the get note skill definition.

func HashGeneratorSkill

func HashGeneratorSkill() Skill

HashGeneratorSkill returns the hash generator skill definition.

func IPFSSkill

func IPFSSkill() Skill

IPFSSkill returns the IPFS skill definition

func ListNotesSkill

func ListNotesSkill() Skill

ListNotesSkill returns the list notes skill definition.

func ListRemindersSkill

func ListRemindersSkill() Skill

ListRemindersSkill returns the list reminders skill definition.

func PasswordGeneratorSkill

func PasswordGeneratorSkill() Skill

PasswordGeneratorSkill returns the password generator skill definition.

func QRCodeGeneratorSkill

func QRCodeGeneratorSkill() Skill

QRCodeGeneratorSkill returns the QR code generator skill definition.

func SaveNoteSkill

func SaveNoteSkill() Skill

SaveNoteSkill returns the save note skill definition.

func SetReminderSkill

func SetReminderSkill() Skill

SetReminderSkill returns the set reminder skill definition.

func TarotSkill

func TarotSkill() Skill

TarotSkill returns the tarot reading skill definition.

func TimezoneConverterSkill

func TimezoneConverterSkill() Skill

TimezoneConverterSkill returns the timezone converter skill definition.

func TwitchLiveCheckSkill

func TwitchLiveCheckSkill() Skill

TwitchLiveCheckSkill returns the Twitch live check skill definition.

func UUIDGeneratorSkill

func UUIDGeneratorSkill() Skill

UUIDGeneratorSkill returns the UUID generator skill definition.

func UnitConverterSkill

func UnitConverterSkill() Skill

UnitConverterSkill returns the unit converter skill definition.

func WalletSecuritySkill

func WalletSecuritySkill() Skill

WalletSecuritySkill returns the wallet security monitoring skill definition

func WeatherSkill

func WeatherSkill() Skill

WeatherSkill returns the weather forecast skill definition.

func YouTubeVideosSkill

func YouTubeVideosSkill() Skill

YouTubeVideosSkill returns the YouTube recent videos skill definition.

type SkillHandler

type SkillHandler func(args map[string]interface{}) (interface{}, error)

SkillHandler is a function that executes a skill.

type TarotConfig

type TarotConfig struct {
	FunctionURL string
	AuthToken   string
}

TarotConfig holds tarot function configuration.

type ToolCall

type ToolCall struct {
	ID       string       `json:"id"`
	Type     string       `json:"type"`
	Function FunctionCall `json:"function"`
}

ToolCall represents an OpenAI tool call.

func ParseToolCalls

func ParseToolCalls(response map[string]interface{}) ([]ToolCall, error)

ParseToolCalls extracts tool calls from an LLM response.

type TwitchConfig

type TwitchConfig struct {
	ClientID        string
	ClientSecret    string
	DefaultStreamer string
}

TwitchConfig holds Twitch API configuration.

type VeniceConfig

type VeniceConfig struct {
	APIKey     string
	BaseURL    string
	Model      string // Chat model (venice-uncensored)
	ImageModel string // Image generation model (lustify-sdxl, animewan, hidream, wai-Illustrious)
	Upscaler   string
}

VeniceConfig holds Venice.ai configuration.

type WalletSecurityConfig

type WalletSecurityConfig struct {
	MonitoredWallets    []MonitoredWallet `json:"monitored_wallets"`
	LastCheckedBlock    string            `json:"last_checked_block"`
	PollIntervalSeconds int               `json:"poll_interval_seconds"`
}

WalletSecurityConfig holds wallet security configuration

type WalletSecuritySettingsConfig

type WalletSecuritySettingsConfig struct {
	Enabled      bool
	PollInterval int    // seconds
	AlertLevel   string // minimum severity to alert on
}

WalletSecuritySettingsConfig holds wallet security settings.

type WeatherConfig

type WeatherConfig struct {
	DefaultZipCode string
}

WeatherConfig holds weather skill configuration.

type YouTubeConfig

type YouTubeConfig struct {
	APIKey         string
	DefaultChannel string
}

YouTubeConfig holds YouTube API configuration.

Jump to

Keyboard shortcuts

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