builtin

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 35 Imported by: 0

Documentation

Overview

Package builtin provides Alchemy blockchain API handler implementation

Package builtin provides blockchain monitoring handler implementation

Package builtin provides IPFS skill implementation using Kubo RPC client.

Package builtin provides crypto utility functions using modern Go crypto libraries

Package builtin provides wallet security monitoring handler implementation

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 BuildAlchemyURL

func BuildAlchemyURL(network, apiKey string) string

BuildAlchemyURL constructs the Alchemy API URL

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 GetChainID

func GetChainID(network string) (int64, error)

GetChainID returns the chain ID for a given network

func GweiToWei

func GweiToWei(gwei int64) *big.Int

GweiToWei converts Gwei to Wei (useful for gas prices)

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 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 RegisterAll

func RegisterAll(registry *tools.Registry, workspace string, configLoader ConfigLoader)

RegisterAll registers all built-in tools with the registry.

func RegisterCryptoTools

func RegisterCryptoTools(registry *tools.Registry, configLoader ConfigLoader)

RegisterCryptoTools registers all crypto/blockchain tools.

func RegisterReadOnlyDevTools

func RegisterReadOnlyDevTools(registry *tools.Registry, workspace string)

RegisterReadOnlyDevTools registers only read-only dev tools (for restricted agent mode).

func ValidateAlchemyNetwork

func ValidateAlchemyNetwork(network string) error

ValidateAlchemyNetwork checks if a network identifier is valid

func WalletSecurityHandlerFunc

func WalletSecurityHandlerFunc(args map[string]any, configLoader ConfigLoader) (any, error)

WalletSecurityHandlerFunc is the exported entry point for wallet security operations. It is used by the monitor daemon to perform periodic wallet checks.

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)

Types

type AlchemyConfig

type AlchemyConfig struct {
	APIKey         string
	DefaultNetwork string
	TimeoutSeconds int
}

AlchemyConfig holds Alchemy API configuration.

type AlchemyTool

type AlchemyTool struct {
	BaseTool
	// contains filtered or unexported fields
}

AlchemyTool provides blockchain data and analytics via Alchemy API.

func NewAlchemyTool

func NewAlchemyTool(configLoader ConfigLoader) *AlchemyTool

NewAlchemyTool creates an AlchemyTool.

func (*AlchemyTool) Execute

func (t *AlchemyTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

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

type Base64DecodeTool

type Base64DecodeTool struct {
	BaseTool
}

Base64DecodeTool decodes a base64 string.

func NewBase64DecodeTool

func NewBase64DecodeTool() *Base64DecodeTool

NewBase64DecodeTool creates a Base64DecodeTool.

func (*Base64DecodeTool) Execute

func (t *Base64DecodeTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type Base64EncodeTool

type Base64EncodeTool struct {
	BaseTool
}

Base64EncodeTool encodes text to base64.

func NewBase64EncodeTool

func NewBase64EncodeTool() *Base64EncodeTool

NewBase64EncodeTool creates a Base64EncodeTool.

func (*Base64EncodeTool) Execute

func (t *Base64EncodeTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type BaseTool

type BaseTool struct {
	ToolName        string
	ToolDescription string
	ToolParameters  json.RawMessage
	ReadOnly        bool
	ConcurrencySafe bool
	Interrupt       tools.InterruptBehavior
	RequiredFields  []string
}

BaseTool provides a reusable base implementation of the tools.Tool interface. Concrete tools can embed BaseTool and override Execute.

func (*BaseTool) Description

func (b *BaseTool) Description() string

func (*BaseTool) Execute

func (b *BaseTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

Execute is a default implementation that returns an error. Concrete tools should override this method.

func (*BaseTool) InterruptBehavior

func (b *BaseTool) InterruptBehavior() tools.InterruptBehavior

func (*BaseTool) IsConcurrencySafe

func (b *BaseTool) IsConcurrencySafe(input map[string]any) bool

func (*BaseTool) IsReadOnly

func (b *BaseTool) IsReadOnly() bool

func (*BaseTool) Name

func (b *BaseTool) Name() string

func (*BaseTool) Parameters

func (b *BaseTool) Parameters() json.RawMessage

func (*BaseTool) ValidateInput

func (b *BaseTool) ValidateInput(input map[string]any) error

ValidateInput checks that all required fields are present and non-empty.

type BashTool

type BashTool struct {
	BaseTool
	// contains filtered or unexported fields
}

BashTool executes shell commands in the workspace directory.

func NewBashTool

func NewBashTool(workspace string) *BashTool

NewBashTool creates a BashTool bound to the given workspace directory.

func (*BashTool) Execute

func (t *BashTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type BlockmonConfig

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

BlockmonConfig holds blockchain monitoring configuration.

type BlockmonTool

type BlockmonTool struct {
	BaseTool
	// contains filtered or unexported fields
}

BlockmonTool provides real-time blockchain monitoring.

func NewBlockmonTool

func NewBlockmonTool(configLoader ConfigLoader) *BlockmonTool

NewBlockmonTool creates a BlockmonTool.

func (*BlockmonTool) Execute

func (t *BlockmonTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

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. This interface mirrors skills.ConfigLoader exactly so that config.NewConfigLoader(cfg) satisfies both.

type CurrencyTool

type CurrencyTool struct {
	BaseTool
}

CurrencyTool converts between currencies.

func NewCurrencyTool

func NewCurrencyTool() *CurrencyTool

NewCurrencyTool creates a CurrencyTool.

func (*CurrencyTool) Execute

func (t *CurrencyTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type HashTool

type HashTool struct {
	BaseTool
}

HashTool generates cryptographic hashes.

func NewHashTool

func NewHashTool() *HashTool

NewHashTool creates a HashTool.

func (*HashTool) Execute

func (t *HashTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type IPFSConfig

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

IPFSConfig holds IPFS configuration.

type IPFSTool

type IPFSTool struct {
	BaseTool
	// contains filtered or unexported fields
}

IPFSTool provides IPFS decentralized storage operations.

func NewIPFSTool

func NewIPFSTool(configLoader ConfigLoader) *IPFSTool

NewIPFSTool creates an IPFSTool.

func (*IPFSTool) Execute

func (t *IPFSTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type ListFilesTool

type ListFilesTool struct {
	BaseTool
	// contains filtered or unexported fields
}

ListFilesTool lists files and directories inside the workspace.

func NewListFilesTool

func NewListFilesTool(workspace string) *ListFilesTool

NewListFilesTool creates a ListFilesTool bound to the given workspace directory.

func (*ListFilesTool) Execute

func (t *ListFilesTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

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 NoteGetTool

type NoteGetTool struct {
	BaseTool
}

NoteGetTool retrieves a note by title.

func NewNoteGetTool

func NewNoteGetTool() *NoteGetTool

NewNoteGetTool creates a NoteGetTool.

func (*NoteGetTool) Execute

func (t *NoteGetTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type NoteListTool

type NoteListTool struct {
	BaseTool
}

NoteListTool lists all saved notes.

func NewNoteListTool

func NewNoteListTool() *NoteListTool

NewNoteListTool creates a NoteListTool.

func (*NoteListTool) Execute

func (t *NoteListTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type NoteSaveTool

type NoteSaveTool struct {
	BaseTool
}

NoteSaveTool saves a note.

func NewNoteSaveTool

func NewNoteSaveTool() *NoteSaveTool

NewNoteSaveTool creates a NoteSaveTool.

func (*NoteSaveTool) Execute

func (t *NoteSaveTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type PasswordTool

type PasswordTool struct {
	BaseTool
}

PasswordTool generates secure random passwords.

func NewPasswordTool

func NewPasswordTool() *PasswordTool

NewPasswordTool creates a PasswordTool.

func (*PasswordTool) Execute

func (t *PasswordTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type PatchFileTool

type PatchFileTool struct {
	BaseTool
	// contains filtered or unexported fields
}

PatchFileTool performs surgical string replacements in workspace files.

func NewPatchFileTool

func NewPatchFileTool(workspace string) *PatchFileTool

NewPatchFileTool creates a PatchFileTool bound to the given workspace directory.

func (*PatchFileTool) Execute

func (t *PatchFileTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type QRCodeTool

type QRCodeTool struct {
	BaseTool
}

QRCodeTool generates QR codes from text.

func NewQRCodeTool

func NewQRCodeTool() *QRCodeTool

NewQRCodeTool creates a QRCodeTool.

func (*QRCodeTool) Execute

func (t *QRCodeTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

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 ReadFileTool

type ReadFileTool struct {
	BaseTool
	// contains filtered or unexported fields
}

ReadFileTool reads text files from the workspace.

func NewReadFileTool

func NewReadFileTool(workspace string) *ReadFileTool

NewReadFileTool creates a ReadFileTool bound to the given workspace directory.

func (*ReadFileTool) Execute

func (t *ReadFileTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

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 ReminderListTool

type ReminderListTool struct {
	BaseTool
}

ReminderListTool lists all active reminders.

func NewReminderListTool

func NewReminderListTool() *ReminderListTool

NewReminderListTool creates a ReminderListTool.

func (*ReminderListTool) Execute

func (t *ReminderListTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type ReminderSetTool

type ReminderSetTool struct {
	BaseTool
}

ReminderSetTool sets a reminder.

func NewReminderSetTool

func NewReminderSetTool() *ReminderSetTool

NewReminderSetTool creates a ReminderSetTool.

func (*ReminderSetTool) Execute

func (t *ReminderSetTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type SearchTool

type SearchTool struct {
	BaseTool
	// contains filtered or unexported fields
}

SearchTool searches for text patterns in workspace files.

func NewSearchTool

func NewSearchTool(workspace string) *SearchTool

NewSearchTool creates a SearchTool bound to the given workspace directory.

func (*SearchTool) Execute

func (t *SearchTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

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]any `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 TarotConfig

type TarotConfig struct {
	FunctionURL string
	AuthToken   string
}

TarotConfig holds tarot function configuration.

type TarotTool

type TarotTool struct {
	BaseTool
	// contains filtered or unexported fields
}

TarotTool generates tarot card readings.

func NewTarotTool

func NewTarotTool(configLoader ConfigLoader) *TarotTool

NewTarotTool creates a TarotTool.

func (*TarotTool) Execute

func (t *TarotTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type TimezoneConverterTool

type TimezoneConverterTool struct {
	BaseTool
}

TimezoneConverterTool converts time between timezones.

func NewTimezoneConverterTool

func NewTimezoneConverterTool() *TimezoneConverterTool

NewTimezoneConverterTool creates a TimezoneConverterTool.

func (*TimezoneConverterTool) Execute

func (tool *TimezoneConverterTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type TwitchConfig

type TwitchConfig struct {
	ClientID        string
	ClientSecret    string
	DefaultStreamer string
}

TwitchConfig holds Twitch API configuration.

type TwitchTool

type TwitchTool struct {
	BaseTool
	// contains filtered or unexported fields
}

TwitchTool checks if a Twitch streamer is live.

func NewTwitchTool

func NewTwitchTool(configLoader ConfigLoader) *TwitchTool

NewTwitchTool creates a TwitchTool.

func (*TwitchTool) Execute

func (t *TwitchTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type UUIDTool

type UUIDTool struct {
	BaseTool
}

UUIDTool generates UUID v4 values.

func NewUUIDTool

func NewUUIDTool() *UUIDTool

NewUUIDTool creates a UUIDTool.

func (*UUIDTool) Execute

func (t *UUIDTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type UnitConverterTool

type UnitConverterTool struct {
	BaseTool
}

UnitConverterTool converts between units of measurement.

func NewUnitConverterTool

func NewUnitConverterTool() *UnitConverterTool

NewUnitConverterTool creates a UnitConverterTool.

func (*UnitConverterTool) Execute

func (t *UnitConverterTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type UpscaleImageTool

type UpscaleImageTool struct {
	BaseTool
	// contains filtered or unexported fields
}

UpscaleImageTool upscales images using Venice.ai.

func NewUpscaleImageTool

func NewUpscaleImageTool(configLoader ConfigLoader) *UpscaleImageTool

NewUpscaleImageTool creates an UpscaleImageTool.

func (*UpscaleImageTool) Execute

func (t *UpscaleImageTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

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 WalletSecurityTool

type WalletSecurityTool struct {
	BaseTool
	// contains filtered or unexported fields
}

WalletSecurityTool monitors wallet addresses for security threats.

func NewWalletSecurityTool

func NewWalletSecurityTool(configLoader ConfigLoader) *WalletSecurityTool

NewWalletSecurityTool creates a WalletSecurityTool.

func (*WalletSecurityTool) Execute

func (t *WalletSecurityTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type WeatherConfig

type WeatherConfig struct {
	DefaultZipCode string
}

WeatherConfig holds weather skill configuration.

type WeatherTool

type WeatherTool struct {
	BaseTool
	// contains filtered or unexported fields
}

WeatherTool gets weather forecast for a location.

func NewWeatherTool

func NewWeatherTool(configLoader ConfigLoader) *WeatherTool

NewWeatherTool creates a WeatherTool.

func (*WeatherTool) Execute

func (t *WeatherTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type WriteFileTool

type WriteFileTool struct {
	BaseTool
	// contains filtered or unexported fields
}

WriteFileTool writes text files to the workspace.

func NewWriteFileTool

func NewWriteFileTool(workspace string) *WriteFileTool

NewWriteFileTool creates a WriteFileTool bound to the given workspace directory.

func (*WriteFileTool) Execute

func (t *WriteFileTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

type YouTubeConfig

type YouTubeConfig struct {
	APIKey         string
	DefaultChannel string
}

YouTubeConfig holds YouTube API configuration.

type YouTubeTool

type YouTubeTool struct {
	BaseTool
	// contains filtered or unexported fields
}

YouTubeTool gets recent videos from a YouTube channel.

func NewYouTubeTool

func NewYouTubeTool(configLoader ConfigLoader) *YouTubeTool

NewYouTubeTool creates a YouTubeTool.

func (*YouTubeTool) Execute

func (t *YouTubeTool) Execute(ctx context.Context, input map[string]any, progress chan<- tools.ProgressEvent) (tools.ToolResult, error)

Jump to

Keyboard shortcuts

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