clawhub

package
v0.9.0 Latest Latest
Warning

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

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

Documentation

Overview

Package clawhub provides ClawHub skills marketplace integration.

Index

Constants

View Source
const (
	// DefaultHubURL is the default ClawHub API endpoint.
	DefaultHubURL = "https://api.clawhub.ai/v1"
)
View Source
const ManifestFile = "CLAWHUB.json"

ManifestFile is the name of the manifest file in a skill repository.

Variables

This section is empty.

Functions

func ValidateSignature

func ValidateSignature(manifest *Manifest, publicKey string) error

ValidateSignature validates a skill's cryptographic signature.

Types

type Dependency

type Dependency struct {
	// Name is the dependency name (e.g., "@clawhub/web-search").
	Name string `json:"name"`

	// Version is the version constraint (e.g., "^1.0.0", ">=2.0.0").
	Version string `json:"version"`

	// Optional indicates if the dependency is optional.
	Optional bool `json:"optional,omitempty"`
}

Dependency represents a skill dependency.

type DependencyResolver

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

DependencyResolver resolves skill dependencies.

func NewDependencyResolver

func NewDependencyResolver(hub *Hub) *DependencyResolver

NewDependencyResolver creates a new dependency resolver.

func (*DependencyResolver) Resolve

func (r *DependencyResolver) Resolve(ctx context.Context, manifest *Manifest) ([]ResolvedDependency, error)

Resolve resolves all dependencies for a manifest.

type Hub

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

Hub provides access to the ClawHub skills marketplace API.

func New

func New(opts ...Option) *Hub

New creates a new Hub client.

func (*Hub) Get

func (h *Hub) Get(ctx context.Context, name string) (*SkillInfo, error)

Get retrieves information about a specific skill.

func (*Hub) GetVersion

func (h *Hub) GetVersion(ctx context.Context, name, version string) (*SkillInfo, error)

GetVersion retrieves information about a specific version of a skill.

func (*Hub) ListVersions

func (h *Hub) ListVersions(ctx context.Context, name string) ([]string, error)

ListVersions lists all versions of a skill.

func (*Hub) Resolve

func (h *Hub) Resolve(ctx context.Context, ref string) (*SkillInfo, error)

Resolve resolves a skill reference to a SkillInfo with repository details.

func (*Hub) Search

func (h *Hub) Search(ctx context.Context, query string, page, perPage int) (*SearchResult, error)

Search searches for skills matching the query.

type IssueType

type IssueType string

IssueType represents the type of security issue.

const (
	IssueTypeSecretLeak    IssueType = "secret_leak"
	IssueTypeDangerousCmd  IssueType = "dangerous_command"
	IssueTypeNetworkAccess IssueType = "network_access"
	IssueTypeFileAccess    IssueType = "file_access"
	IssueTypeMalicious     IssueType = "malicious"
	IssueTypeUnsigned      IssueType = "unsigned"
)

type Manifest

type Manifest struct {
	// Name is the skill name (required).
	Name string `json:"name"`

	// Version is the semantic version (required).
	Version string `json:"version"`

	// Description is a brief description of the skill.
	Description string `json:"description"`

	// Author is the skill author's name or organization.
	Author string `json:"author"`

	// Repository is the source repository URL.
	Repository string `json:"repository"`

	// License is the SPDX license identifier.
	License string `json:"license"`

	// Keywords are searchable tags for the skill.
	Keywords []string `json:"keywords,omitempty"`

	// Dependencies lists other skills this skill depends on.
	Dependencies []Dependency `json:"dependencies,omitempty"`

	// Permissions lists the permissions the skill requires.
	Permissions []string `json:"permissions,omitempty"`

	// Entry is the entry point file (defaults to SKILL.md).
	Entry string `json:"entry,omitempty"`

	// Signature is the cryptographic signature for verification.
	Signature string `json:"signature,omitempty"`

	// MinAgentVersion is the minimum omniagent version required.
	MinAgentVersion string `json:"minAgentVersion,omitempty"`
}

Manifest represents the CLAWHUB.json manifest file.

func LoadManifest

func LoadManifest(path string) (*Manifest, error)

LoadManifest loads a manifest from a file path.

func ParseManifest

func ParseManifest(data []byte) (*Manifest, error)

ParseManifest parses a manifest from JSON data.

func (*Manifest) EntryFile

func (m *Manifest) EntryFile() string

EntryFile returns the entry point file, defaulting to SKILL.md.

func (*Manifest) FullName

func (m *Manifest) FullName() string

FullName returns the full name including scope if present.

func (*Manifest) HasPermission

func (m *Manifest) HasPermission(perm string) bool

HasPermission checks if the skill requests a specific permission.

func (*Manifest) SaveManifest

func (m *Manifest) SaveManifest(dir string) error

SaveManifest saves a manifest to a file path.

func (*Manifest) Validate

func (m *Manifest) Validate() error

Validate checks that the manifest has all required fields.

type Option

type Option func(*Hub)

Option is a functional option for configuring the Hub.

func WithAPIKey

func WithAPIKey(apiKey string) Option

WithAPIKey sets the API key for authenticated requests.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL sets a custom base URL for the Hub API.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets a custom HTTP client.

type ResolutionError

type ResolutionError struct {
	// Dependency is the name of the dependency that failed.
	Dependency string

	// Constraint is the version constraint that couldn't be satisfied.
	Constraint string

	// Reason is the error reason.
	Reason string
}

ResolutionError represents an error during dependency resolution.

func (*ResolutionError) Error

func (e *ResolutionError) Error() string

type ResolvedDependency

type ResolvedDependency struct {
	// Name is the dependency name.
	Name string

	// Version is the resolved version.
	Version string

	// Repository is the source repository URL.
	Repository string

	// Optional indicates if this is an optional dependency.
	Optional bool

	// Transitive indicates if this is a transitive dependency.
	Transitive bool
}

ResolvedDependency represents a fully resolved dependency.

type ScanResult

type ScanResult struct {
	// Issues is the list of security issues found.
	Issues []SecurityIssue

	// FileHashes contains SHA256 hashes of all files.
	FileHashes map[string]string

	// Passed indicates if the scan passed.
	Passed bool
}

ScanResult contains the results of a security scan.

type SearchResult

type SearchResult struct {
	// Skills is the list of matching skills.
	Skills []SkillInfo `json:"skills"`

	// Total is the total number of matching skills.
	Total int `json:"total"`

	// Page is the current page number.
	Page int `json:"page"`

	// PerPage is the number of results per page.
	PerPage int `json:"perPage"`
}

SearchResult contains the result of a skill search.

type SecurityIssue

type SecurityIssue struct {
	// Severity is the issue severity.
	Severity Severity

	// Type is the issue type.
	Type IssueType

	// File is the file where the issue was found.
	File string

	// Line is the line number (0 if not applicable).
	Line int

	// Description describes the issue.
	Description string

	// Recommendation suggests how to fix the issue.
	Recommendation string
}

SecurityIssue represents a security finding.

type SecurityScanner

type SecurityScanner struct {
	// StrictMode fails on any warning when true.
	StrictMode bool

	// AllowedCommands is a list of allowed shell commands.
	AllowedCommands []string

	// BlockedPatterns are regex patterns that are not allowed.
	BlockedPatterns []*regexp.Regexp
}

SecurityScanner scans skill packages for security issues.

func NewSecurityScanner

func NewSecurityScanner() *SecurityScanner

NewSecurityScanner creates a new security scanner with defaults.

func (*SecurityScanner) Scan

func (s *SecurityScanner) Scan(dir string) (*ScanResult, error)

Scan scans a skill directory for security issues.

type SecurityState

type SecurityState string

SecurityState represents the security verification state of a skill.

const (
	// SecurityStateUnknown indicates the skill has not been verified.
	SecurityStateUnknown SecurityState = "unknown"

	// SecurityStatePending indicates verification is in progress.
	SecurityStatePending SecurityState = "pending"

	// SecurityStateVerified indicates the skill passed security checks.
	SecurityStateVerified SecurityState = "verified"

	// SecurityStateFlagged indicates security issues were found.
	SecurityStateFlagged SecurityState = "flagged"
)

type Severity

type Severity string

Severity represents the severity of a security issue.

const (
	SeverityCritical Severity = "critical"
	SeverityHigh     Severity = "high"
	SeverityMedium   Severity = "medium"
	SeverityLow      Severity = "low"
	SeverityInfo     Severity = "info"
)

type SkillInfo

type SkillInfo struct {
	// Name is the skill name.
	Name string `json:"name"`

	// Version is the latest version.
	Version string `json:"version"`

	// Description is the skill description.
	Description string `json:"description"`

	// Author is the skill author.
	Author string `json:"author"`

	// Repository is the source repository URL.
	Repository string `json:"repository"`

	// Downloads is the total download count.
	Downloads int `json:"downloads"`

	// Stars is the star count.
	Stars int `json:"stars"`

	// License is the SPDX license identifier.
	License string `json:"license"`

	// Keywords are searchable tags.
	Keywords []string `json:"keywords"`

	// CreatedAt is when the skill was first published.
	CreatedAt time.Time `json:"createdAt"`

	// UpdatedAt is when the skill was last updated.
	UpdatedAt time.Time `json:"updatedAt"`

	// SecurityState indicates the security verification state.
	SecurityState SecurityState `json:"securityState"`

	// Versions lists all available versions.
	Versions []string `json:"versions,omitempty"`
}

SkillInfo contains information about a skill from the Hub.

Jump to

Keyboard shortcuts

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