Documentation
¶
Overview ¶
Package tool provides persistent storage and management for AI tool providers.
Index ¶
- Constants
- type ListOptions
- type PostgresStore
- func (p *PostgresStore) Add(ctx context.Context, t *Tool) error
- func (p *PostgresStore) Close() error
- func (p *PostgresStore) Delete(ctx context.Context, name string) error
- func (p *PostgresStore) Get(ctx context.Context, name string) (*Tool, error)
- func (p *PostgresStore) InitSchema() error
- func (p *PostgresStore) List(ctx context.Context) ([]*Tool, error)
- func (p *PostgresStore) SeedBuiltins(ctx context.Context) error
- func (p *PostgresStore) SetEnabled(ctx context.Context, name string, enabled bool) error
- func (p *PostgresStore) Update(ctx context.Context, t *Tool) error
- type Store
- func (s *Store) Add(ctx context.Context, t *Tool) error
- func (s *Store) Close() error
- func (s *Store) Delete(ctx context.Context, name string) error
- func (s *Store) Get(ctx context.Context, name string) (*Tool, error)
- func (s *Store) List(ctx context.Context) ([]*Tool, error)
- func (s *Store) ListWithOptions(ctx context.Context, opts ListOptions) ([]*Tool, error)
- func (s *Store) Open() error
- func (s *Store) SetEnabled(ctx context.Context, name string, enabled bool) error
- func (s *Store) Update(ctx context.Context, t *Tool) error
- type Tool
Constants ¶
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) 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 ¶
SetEnabled enables or disables a tool.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides tool management backed by SQLite or TimescaleDB (Postgres).
func OpenStore ¶
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 ¶
Add inserts a new tool. Returns an error if a tool with that name already exists.
func (*Store) ListWithOptions ¶
ListWithOptions returns tools filtered by the given options.
func (*Store) Open ¶
Open initializes the database and seeds built-in tools. Uses the shared workspace database; returns an error if unavailable.
func (*Store) SetEnabled ¶
SetEnabled enables or disables a tool.
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).