app

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultQueryMaxRows is the default row cap for CLI, Web, and TUI queries.
	DefaultQueryMaxRows = 1000
	// DefaultMCPQueryMaxRows is a lower default for MCP tool responses (smaller agent payloads).
	DefaultMCPQueryMaxRows = 500
	// DefaultMCPMaxRowsLimit is the hard ceiling for MCP query max_rows (requests above are clamped).
	DefaultMCPMaxRowsLimit = 10000
	// DefaultMCPMaxResponseBytes is the default serialized JSON size cap for MCP query results.
	DefaultMCPMaxResponseBytes = 512 * 1024
)
View Source
const MCPResponseTruncationHint = errors.HintMCPResponseTruncated

MCPResponseTruncationHint is appended when MCP byte guard trims rows.

View Source
const QueryTruncationHint = errors.HintQueryResultTruncated

QueryTruncationHint is returned when results are truncated for agents/humans.

Variables

This section is empty.

Functions

func DescribeTable added in v1.0.0

func DescribeTable(ctx context.Context, req TableDescribeRequest) (*db.Table, *errors.XError)

DescribeTable loads the schema for a single table using a resolved profile.

func DumpSchema added in v1.0.0

func DumpSchema(ctx context.Context, req SchemaDumpRequest) (*db.SchemaInfo, *errors.XError)

DumpSchema exports the schema using a resolved profile.

func ListTables added in v1.0.0

func ListTables(ctx context.Context, req TableListRequest) (*db.TableList, *errors.XError)

ListTables loads the lightweight table list using a resolved profile.

func LoadProfileDetail added in v1.0.0

func LoadProfileDetail(opts config.Options, name string) (map[string]any, *errors.XError)

LoadProfileDetail loads a single profile and redacts sensitive fields.

func Query added in v1.0.0

func Query(ctx context.Context, req QueryRequest) (*db.QueryResult, *errors.XError)

Query executes a SQL query using a resolved profile.

func QueryTimeout added in v1.0.0

func QueryTimeout(profile config.Profile, overrideSeconds int, overrideSet bool, fallback time.Duration) time.Duration

QueryTimeout resolves the effective query timeout.

func ResolveMCPMaxResponseBytes added in v1.21.0

func ResolveMCPMaxResponseBytes(mcpCfg config.MCPConfig) int

ResolveMCPMaxResponseBytes returns the MCP JSON response byte cap.

func ResolveMCPMaxRowsLimit added in v1.21.0

func ResolveMCPMaxRowsLimit(mcpCfg config.MCPConfig) int

ResolveMCPMaxRowsLimit returns the configured MCP max_rows ceiling.

func ResolveProfile added in v1.0.0

func ResolveProfile(cfg config.File, name string) (config.Profile, *errors.XError)

ResolveProfile returns a fully prepared profile with ssh config and default ports.

func ResolveQueryMaxRows added in v1.21.0

func ResolveQueryMaxRows(profile config.Profile, envMaxRows string, cliValue int, cliSet bool) (limit int, xe *errors.XError)

ResolveQueryMaxRows returns the effective row limit for CLI/Web/TUI. limit 0 means unlimited. Negative values are invalid.

func ResolveReconnectableSSH added in v0.1.0

func ResolveReconnectableSSH(ctx context.Context, profile config.Profile, allowPlaintext, skipHostKeyCheck bool, onStatus func(ssh.StatusEvent)) (*ssh.ReconnectDialer, *errors.XError)

ResolveReconnectableSSH creates an SSH ReconnectDialer for long-lived connections (e.g. the proxy command). It wraps the SSH connection with automatic keepalive monitoring and reconnection on failure.

func ResolveSSH added in v0.0.9

func ResolveSSH(ctx context.Context, profile config.Profile, allowPlaintext, skipHostKeyCheck bool) (*ssh.Client, *errors.XError)

func SSHOptionsForProfile added in v1.21.0

func SSHOptionsForProfile(profile config.Profile, allowPlaintext, skipHostKeyCheck bool) (ssh.Options, *errors.XError)

SSHOptionsForProfile builds SSH options from a resolved profile, resolving secrets. skipHostKeyCheck is the runtime override (e.g. CLI --ssh-skip-known-hosts-check); profile ssh_proxy.skip_host_key is also honored.

func SchemaTimeout added in v1.0.0

func SchemaTimeout(profile config.Profile, overrideSeconds int, overrideSet bool, fallback time.Duration) time.Duration

SchemaTimeout resolves the effective schema dump timeout.

func TestAIConnection added in v1.20.0

func TestAIConnection(ctx context.Context, aiCfg config.AIConfig) (map[string]any, *errors.XError)

TestAIConnection tests AI configuration and measures latency.

func TestProfileConnection added in v1.20.0

func TestProfileConnection(ctx context.Context, profile config.Profile, allowPlaintext, skipHostKey bool) (map[string]any, *errors.XError)

TestProfileConnection tests a database profile connection and measures latency.

func TestSSHProxyConnection added in v1.20.0

func TestSSHProxyConnection(ctx context.Context, proxy config.SSHProxy, allowPlaintext, skipHostKey bool) (map[string]any, *errors.XError)

TestSSHProxyConnection tests an SSH proxy configuration and measures latency.

Types

type App

type App struct {
	Version string
	Commit  string
	Date    string
}

func New

func New(version, commit, date string) App

func (App) BuildSpec

func (a App) BuildSpec() spec.Spec

func (App) VersionInfo

func (a App) VersionInfo() VersionInfo

type Connection added in v0.0.9

type Connection struct {
	DB        *sql.DB
	SSHClient *ssh.Client
	Profile   config.Profile
	// contains filtered or unexported fields
}

func ResolveConnection added in v0.0.9

func ResolveConnection(ctx context.Context, opts ConnectionOptions) (*Connection, *errors.XError)

func (*Connection) Close added in v0.0.9

func (c *Connection) Close() error

type ConnectionOptions added in v0.0.9

type ConnectionOptions struct {
	Profile          config.Profile
	AllowPlaintext   bool
	SkipHostKeyCheck bool
}

type MCPMaxRowsMeta added in v1.21.0

type MCPMaxRowsMeta struct {
	Requested int
	Clamped   bool
	Limit     int
}

MCPMaxRowsMeta describes MCP max_rows resolution/clamping for response metadata.

func ResolveMCPQueryMaxRows added in v1.21.0

func ResolveMCPQueryMaxRows(profile config.Profile, mcpCfg config.MCPConfig, argValue int, argSet bool) (effective int, meta MCPMaxRowsMeta, xe *errors.XError)

ResolveMCPQueryMaxRows returns the MCP row limit (never unlimited). MCP max_rows 0 means unset (use defaults). Negative values are rejected.

type ProfileListResult added in v1.0.0

type ProfileListResult struct {
	ConfigPath string               `json:"config_path" yaml:"config_path"`
	Profiles   []config.ProfileInfo `json:"profiles" yaml:"profiles"`
}

ProfileListResult is the structured result for profile listing.

func LoadProfiles added in v1.0.0

func LoadProfiles(opts config.Options) (*ProfileListResult, *errors.XError)

LoadProfiles loads and summarizes the configured profiles.

func (*ProfileListResult) ToProfileListData added in v1.0.0

func (r *ProfileListResult) ToProfileListData() (string, []output.ProfileListItem, bool)

ToProfileListData implements output.ProfileListFormatter.

type QueryRequest added in v1.0.0

type QueryRequest struct {
	Profile          config.Profile
	SQL              string
	AllowPlaintext   bool
	SkipHostKeyCheck bool
	UnsafeAllowWrite bool
	MaxRows          int
	TruncationHint   string
}

QueryRequest contains options for a query operation.

type SchemaDumpRequest added in v1.0.0

type SchemaDumpRequest struct {
	Profile          config.Profile
	TablePattern     string
	IncludeSystem    bool
	AllowPlaintext   bool
	SkipHostKeyCheck bool
}

SchemaDumpRequest contains options for a schema dump operation.

type TableDescribeRequest added in v1.0.0

type TableDescribeRequest struct {
	Profile          config.Profile
	Schema           string
	Name             string
	AllowPlaintext   bool
	SkipHostKeyCheck bool
}

TableDescribeRequest contains options for loading a single table schema.

type TableListRequest added in v1.0.0

type TableListRequest struct {
	Profile          config.Profile
	TablePattern     string
	IncludeSystem    bool
	AllowPlaintext   bool
	SkipHostKeyCheck bool
}

TableListRequest contains options for loading the lightweight table list.

type VersionInfo

type VersionInfo struct {
	Version string `json:"version" yaml:"version"`
	Commit  string `json:"commit,omitempty" yaml:"commit,omitempty"`
	Date    string `json:"date,omitempty" yaml:"date,omitempty"`
}

Jump to

Keyboard shortcuts

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