cliclient

package
v0.16.8 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Message   string `json:"error"`
	RequestID string `json:"request_id,omitempty"`
}

APIError represents an error from the API that includes request_id for log correlation. T023: Added for CLI error display with request ID

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface.

func (*APIError) FormatWithRequestID

func (e *APIError) FormatWithRequestID() string

FormatWithRequestID returns a formatted error message including the request ID.

func (*APIError) HasRequestID

func (e *APIError) HasRequestID() bool

HasRequestID returns true if the error has a request ID for log correlation.

type ActivityFilterParams

type ActivityFilterParams interface {
	ToQueryParams() url.Values
}

ActivityFilterParams contains options for filtering activity records.

type AddServerRequest

type AddServerRequest struct {
	Name        string            `json:"name"`
	URL         string            `json:"url,omitempty"`
	Command     string            `json:"command,omitempty"`
	Args        []string          `json:"args,omitempty"`
	Env         map[string]string `json:"env,omitempty"`
	Headers     map[string]string `json:"headers,omitempty"`
	WorkingDir  string            `json:"working_dir,omitempty"`
	Protocol    string            `json:"protocol,omitempty"`
	Enabled     *bool             `json:"enabled,omitempty"`
	Quarantined *bool             `json:"quarantined,omitempty"`
}

AddServerRequest represents the request body for adding a server.

type AddServerResult

type AddServerResult struct {
	Name        string `json:"name"`
	ID          int    `json:"id"`
	Quarantined bool   `json:"quarantined"`
}

AddServerResult represents the result of adding a server.

type BulkOperationResult

type BulkOperationResult struct {
	Total      int               `json:"total"`
	Successful int               `json:"successful"`
	Failed     int               `json:"failed"`
	Errors     map[string]string `json:"errors"`
}

BulkOperationResult holds the results of a bulk operation across multiple servers.

type CallToolResult

type CallToolResult struct {
	Content  []interface{}          `json:"content"`
	IsError  bool                   `json:"isError"`
	Metadata map[string]interface{} `json:"_meta,omitempty"`
}

CallToolResult represents tool call result.

type Client

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

Client provides HTTP API access for CLI commands.

func NewClient

func NewClient(endpoint string, logger *zap.SugaredLogger) *Client

NewClient creates a new CLI HTTP client. If endpoint is a socket path, creates a client with socket dialer.

func NewClientWithAPIKey

func NewClientWithAPIKey(endpoint, apiKey string, logger *zap.SugaredLogger) *Client

NewClientWithAPIKey creates a new CLI HTTP client with API key authentication. If endpoint is a socket path, creates a client with socket dialer.

func (*Client) AddServer

func (c *Client) AddServer(ctx context.Context, req *AddServerRequest) (*AddServerResult, error)

AddServer adds a new upstream server via the daemon API.

func (*Client) CallTool

func (c *Client) CallTool(
	ctx context.Context,
	toolName string,
	args map[string]interface{},
) (*CallToolResult, error)

CallTool calls a tool on an upstream server via daemon API.

func (*Client) CodeExec

func (c *Client) CodeExec(
	ctx context.Context,
	code string,
	input map[string]interface{},
	timeoutMS int,
	maxToolCalls int,
	allowedServers []string,
) (*CodeExecResult, error)

CodeExec executes JavaScript code via the daemon API.

func (*Client) DisableAll

func (c *Client) DisableAll(ctx context.Context) (*BulkOperationResult, error)

T080: DisableAll disables all configured servers.

func (*Client) EnableAll

func (c *Client) EnableAll(ctx context.Context) (*BulkOperationResult, error)

T080: EnableAll enables all configured servers.

func (*Client) GetActivityDetail

func (c *Client) GetActivityDetail(ctx context.Context, activityID string) (map[string]interface{}, error)

GetActivityDetail retrieves details for a specific activity record.

func (*Client) GetActivitySummary

func (c *Client) GetActivitySummary(ctx context.Context, period, groupBy string) (map[string]interface{}, error)

GetActivitySummary retrieves activity summary statistics.

func (*Client) GetDiagnostics

func (c *Client) GetDiagnostics(ctx context.Context) (map[string]interface{}, error)

GetDiagnostics retrieves diagnostics information from daemon.

func (*Client) GetInfo

func (c *Client) GetInfo(ctx context.Context) (map[string]interface{}, error)

GetInfo retrieves server info including version and update status.

func (*Client) GetInfoWithRefresh

func (c *Client) GetInfoWithRefresh(ctx context.Context, refresh bool) (map[string]interface{}, error)

GetInfoWithRefresh retrieves server info with optional update check refresh. When refresh is true, forces an immediate update check against GitHub.

func (*Client) GetServerLogs

func (c *Client) GetServerLogs(ctx context.Context, serverName string, tail int) ([]contracts.LogEntry, error)

GetServerLogs retrieves logs for a specific server.

func (*Client) GetServerTools

func (c *Client) GetServerTools(ctx context.Context, serverName string) ([]map[string]interface{}, error)

GetServerTools retrieves tools for a specific server from daemon.

func (*Client) GetServers

func (c *Client) GetServers(ctx context.Context) ([]map[string]interface{}, error)

GetServers retrieves list of servers from daemon.

func (*Client) ListActivities

func (c *Client) ListActivities(ctx context.Context, filter ActivityFilterParams) ([]map[string]interface{}, int, error)

ListActivities retrieves activity records with filtering.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping checks if the daemon is reachable.

func (*Client) RemoveServer

func (c *Client) RemoveServer(ctx context.Context, serverName string) error

RemoveServer removes an upstream server via the daemon API.

func (*Client) RestartAll

func (c *Client) RestartAll(ctx context.Context) (*BulkOperationResult, error)

T079: RestartAll restarts all configured servers.

func (*Client) ServerAction

func (c *Client) ServerAction(ctx context.Context, serverName, action string) error

ServerAction performs an action on a server (enable, disable, restart).

func (*Client) TriggerOAuthLogin

func (c *Client) TriggerOAuthLogin(ctx context.Context, serverName string) error

TriggerOAuthLogin initiates OAuth authentication flow for a server. Returns *contracts.OAuthFlowError for structured OAuth errors (Spec 020).

func (*Client) TriggerOAuthLogout

func (c *Client) TriggerOAuthLogout(ctx context.Context, serverName string) error

TriggerOAuthLogout clears OAuth token and disconnects a server.

type CodeExecError

type CodeExecError struct {
	Message string `json:"message"`
	Code    string `json:"code"`
}

CodeExecError represents execution error.

type CodeExecResult

type CodeExecResult struct {
	OK        bool                   `json:"ok"`
	Result    interface{}            `json:"result,omitempty"`
	Error     *CodeExecError         `json:"error,omitempty"`
	Stats     map[string]interface{} `json:"stats,omitempty"`
	RequestID string                 `json:"request_id,omitempty"` // T023: For error correlation
}

CodeExecResult represents code execution result.

Jump to

Keyboard shortcuts

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