tool

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package tool provides persistent storage and management for AI tool providers.

Index

Constants

View Source
const (
	ToolTypeCLI      = "cli"      // CLI binary (gh, aws, wrangler)
	ToolTypeMCP      = "mcp"      // MCP server (bc, playwright, github)
	ToolTypeProvider = "provider" // AI provider (claude, gemini, cursor)
)

ToolType classifies a tool.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListOptions

type ListOptions struct {
	Types []string // filter by type (e.g., ["cli", "mcp"])
}

ListOptions controls tool listing behavior.

type PostgresStore

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

PostgresStore provides Postgres-backed tool management.

func NewPostgresStore

func NewPostgresStore(db *sql.DB) *PostgresStore

NewPostgresStore creates a PostgresStore from an existing *sql.DB connection.

func (*PostgresStore) Add

func (p *PostgresStore) Add(ctx context.Context, t *Tool) error

Add inserts a new tool.

func (*PostgresStore) Close

func (p *PostgresStore) Close() error

Close is a no-op — the shared DB is owned by the caller.

func (*PostgresStore) Delete

func (p *PostgresStore) Delete(ctx context.Context, name string) error

Delete removes a tool by name.

func (*PostgresStore) Get

func (p *PostgresStore) Get(ctx context.Context, name string) (*Tool, error)

Get returns a tool by name. Returns nil, nil if not found.

func (*PostgresStore) InitSchema

func (p *PostgresStore) InitSchema() error

InitSchema creates the tools table in Postgres if it doesn't exist.

func (*PostgresStore) List

func (p *PostgresStore) List(ctx context.Context) ([]*Tool, error)

List returns all tools.

func (*PostgresStore) SeedBuiltins

func (p *PostgresStore) SeedBuiltins(ctx context.Context) error

SeedBuiltins seeds built-in tools and MCP servers if they don't exist.

func (*PostgresStore) SetEnabled

func (p *PostgresStore) SetEnabled(ctx context.Context, name string, enabled bool) error

SetEnabled enables or disables a tool.

func (*PostgresStore) Update

func (p *PostgresStore) Update(ctx context.Context, t *Tool) error

Update replaces a tool's mutable fields.

type Store

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

Store provides tool management backed by SQLite or TimescaleDB (Postgres).

func NewStore

func NewStore(stateDir string) *Store

NewStore creates a new tool store for the given workspace state directory.

func OpenStore

func OpenStore(stateDir string) (*Store, error)

OpenStore opens the tool store using the shared workspace database. Uses the shared driver type to determine the backend (timescale or sqlite).

func (*Store) Add

func (s *Store) Add(ctx context.Context, t *Tool) error

Add inserts a new tool. Returns an error if a tool with that name already exists.

func (*Store) Close

func (s *Store) Close() error

Close is a no-op — the shared DB is owned by the caller.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, name string) error

Delete removes a tool by name.

func (*Store) Get

func (s *Store) Get(ctx context.Context, name string) (*Tool, error)

Get returns a tool by name. Returns nil, nil if not found.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]*Tool, error)

List returns all tools, optionally filtered by type.

func (*Store) ListWithOptions

func (s *Store) ListWithOptions(ctx context.Context, opts ListOptions) ([]*Tool, error)

ListWithOptions returns tools filtered by the given options.

func (*Store) Open

func (s *Store) Open() error

Open initializes the database and seeds built-in tools. Uses the shared workspace database; returns an error if unavailable.

func (*Store) SetEnabled

func (s *Store) SetEnabled(ctx context.Context, name string, enabled bool) error

SetEnabled enables or disables a tool.

func (*Store) Update

func (s *Store) Update(ctx context.Context, t *Tool) error

Update replaces a tool's mutable fields (command, install_cmd, upgrade_cmd, slash_cmds, mcp_servers, config, enabled).

type Tool

type Tool struct {
	CreatedAt    time.Time         `json:"created_at"`
	Config       map[string]any    `json:"config,omitempty"`
	Env          map[string]string `json:"env,omitempty"` // env vars, supports ${secret:NAME}
	Name         string            `json:"name"`
	Type         string            `json:"type"` // "cli", "mcp", "provider"
	Command      string            `json:"command"`
	InstallCmd   string            `json:"install_cmd,omitempty"`
	UpgradeCmd   string            `json:"upgrade_cmd,omitempty"`
	VersionCmd   string            `json:"version_cmd,omitempty"`   // e.g., "gh --version"
	Transport    string            `json:"transport,omitempty"`     // "stdio", "sse" (MCP only)
	URL          string            `json:"url,omitempty"`           // SSE endpoint (MCP only)
	HealthStatus string            `json:"health_status,omitempty"` // connected/installed/not_installed/error
	LastChecked  string            `json:"last_checked,omitempty"`  // ISO timestamp
	SlashCmds    []string          `json:"slash_cmds,omitempty"`
	Args         []string          `json:"args,omitempty"`        // stdio args (MCP only)
	MCPServers   []string          `json:"mcp_servers,omitempty"` // associated MCP server names
	Builtin      bool              `json:"builtin,omitempty"`
	Enabled      bool              `json:"enabled"`
}

Tool represents a configured tool in the workspace (CLI, MCP server, or AI provider).

Jump to

Keyboard shortcuts

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