Documentation
¶
Overview ¶
Package cli implements the user- and agent-facing JetKVM command tree.
Cobra owns command parsing and help generation. Device and MCP behavior is injected so this package remains an adapter over the shared application core.
Index ¶
- Constants
- Variables
- func ExitCode(err error) int
- type App
- type AutomationService
- type ConfirmationIssuer
- type ConfirmationRequest
- type Dependencies
- type InputReleaser
- type Logger
- type MCPServeOptions
- type MCPServer
- type Observer
- type Runtime
- type RuntimeLoader
- type RuntimeLoaderFunc
- type SetupService
- type UpdateService
Constants ¶
const ( ExitOK = 0 ExitInternal = 1 ExitUsage = 2 ExitNotFound = 3 ExitAuth = 4 ExitUnsupported = 6 ExitConflict = 7 ExitAmbiguous = 8 )
Exit codes are part of the CLI's stable machine-facing contract.
Variables ¶
var ( ErrConfirmationRequired = errors.New("action-time confirmation is required") )
Functions ¶
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App owns one configured command tree and its output policy.
type AutomationService ¶
type AutomationService interface {
PrepareOpenControl(automation.OpenControlRequest) (automation.ConfirmationPlan, error)
OpenControl(context.Context, automation.OpenControlRequest) (control.Handle, error)
GetControl(context.Context, automation.ControlRequest) (control.Snapshot, error)
CloseControl(context.Context, automation.ControlRequest) (control.Handle, error)
RunActions(context.Context, automation.RunActionsRequest) (automation.RunActionsResult, error)
PrepareRunActions(automation.RunActionsRequest) (automation.ConfirmationPlan, error)
GetPowerState(context.Context, automation.ControlRequest) (automation.PowerState, error)
PowerAction(context.Context, automation.PowerActionRequest) (operation.Receipt, error)
PreparePowerAction(automation.PowerActionRequest) (automation.ConfirmationPlan, error)
}
AutomationService is the CLI-facing control boundary implemented by the shared automation core. CLI commands never access JetKVM transports or RPCs.
type ConfirmationIssuer ¶
type ConfirmationIssuer interface {
Issue(context.Context, ConfirmationRequest) (context.Context, error)
}
ConfirmationIssuer prompts only when Interactive is true, or redeems an already-issued internal proof for non-interactive execution. It returns a context carrying that proof for the shared core to verify at execution time.
type ConfirmationRequest ¶
type ConfirmationRequest struct {
DeviceID domain.DeviceID
Ref control.Ref
OperationID uuid.UUID
Action string
Summary string
Interactive bool
Binding confirmation.Binding
}
ConfirmationRequest binds an action-time confirmation to the exact device, control generation, operation, and normalized human-readable summary.
type Dependencies ¶
type Dependencies struct {
Devices domain.DeviceService
Automation AutomationService
Releaser InputReleaser
Confirmations ConfirmationIssuer
MCP MCPServer
Version buildinfo.Info
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
IsTerminal func(io.Writer) bool
Logger Logger
Loader RuntimeLoader
ConfigPath string
Updater UpdateService
Setup SetupService
MCPLoader func(context.Context, string) (MCPServer, func() error, error)
OpenBrowser func(context.Context, string) error
InputTerminal func(io.Reader) bool
}
Dependencies are supplied by the executable's composition root.
type InputReleaser ¶
type InputReleaser interface {
ReleaseInput(context.Context, automation.ReleaseInputRequest) (operation.Receipt, error)
}
ReleaseInputRequest identifies an explicit neutralization operation. It is separate from an action batch because an empty or synthetic batch must never masquerade as terminal input release. InputReleaser is the dedicated core capability required by `input release`. A runtime that does not implement it fails closed instead of using close or direct HID as a substitute.
type Logger ¶
Logger deliberately matches the structured shape used by charmbracelet/log without forcing callers or this package to a concrete logging implementation. Logs must be directed to stderr by the composition root.
type MCPServeOptions ¶
type MCPServeOptions struct {
Transport string
Listen string
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
}
MCPServeOptions is the CLI-to-MCP adapter boundary. The MCP implementation owns protocol details; the CLI owns user-facing argument validation.
type MCPServer ¶
type MCPServer interface {
Serve(context.Context, MCPServeOptions) error
}
MCPServer runs the MCP adapter over the shared application core.
type Observer ¶ added in v1.0.2
type Observer interface {
Observe(context.Context, automation.ObserveRequest) (automation.ScreenObservation, error)
}
Observer is optional so control-only adapters do not need video support.
type Runtime ¶
type Runtime struct {
Devices domain.DeviceService
Automation AutomationService
Releaser InputReleaser
Confirmations ConfirmationIssuer
MCP MCPServer
OutputMode string
Close func() error
}
Runtime contains the initialized application services for one CLI process. Close flushes durable state and releases process-owned resources.
type RuntimeLoader ¶
RuntimeLoader creates the shared core after Cobra has parsed the authoritative --config flag. CLI and MCP commands then receive the same service instances.
type RuntimeLoaderFunc ¶
RuntimeLoaderFunc adapts a function to RuntimeLoader.
type SetupService ¶ added in v1.0.1
type SetupService interface {
Plan(context.Context, setupcore.PlanRequest) (setupcore.Plan, error)
Apply(context.Context, setupcore.Plan) (setupcore.Receipt, error)
Uninstall(context.Context, setupcore.Target, bool) (setupcore.Receipt, error)
Doctor(context.Context, setupcore.Target, string) (setupcore.DoctorReport, error)
}
type UpdateService ¶ added in v1.0.1
type UpdateService interface {
Resolve(context.Context, updatecore.Request) (updatecore.Resolution, error)
Check(context.Context, updatecore.Resolution) (updatecore.CheckResult, error)
Plan(updatecore.CheckResult) (updatecore.Plan, error)
Apply(context.Context, updatecore.Plan) (updatecore.Result, error)
Rollback(context.Context) (updatecore.Result, error)
}