Help us shape the future of Go! Take the 2026 Go Developer Survey

clientcmd

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package clientcmd is the agent's side of lockfile, shared by the CLI and the MCP server: it calls a running console and turns every answer into a value of the closed list of docs/security-model.md. Nothing the console sends is passed on as text: results are decoded into typed values, and every error becomes a registered refusal or a fixed message chosen here.

Index

Constants

This section is empty.

Variables

View Source
var NoConsoleText = "no lockfile console is running: " + client.StartHint

NoConsoleText says that no console runs and how one starts: lockkit's hint, `lox up` only.

Functions

func Answers

func Answers(ctx context.Context, profile, handle string) (answers.Result, error)

Answers returns the answers already given on a handle.

func HeartbeatEvery added in v0.3.0

func HeartbeatEvery(q time.Duration) time.Duration

HeartbeatEvery is the interval of a run's progress notifications for quantum q: q itself, or q divided into equal parts under the 10 s that lockkit's mcpkit.Progress accepts, so that a heartbeat falls on every quantum boundary. 0 (unknown q) leaves lockkit's default.

func Plan

func Plan(ctx context.Context, profile string, p rpc.PlanParams) (rpc.PlanResult, error)

Plan asks the human to approve a plan. In hub mode it answers a *PendingError: the human decides on the hub, and the ticket runs then.

func PlanAndRun

func PlanAndRun(ctx context.Context, profile string, p rpc.PlanParams) (answers.Result, error)

PlanAndRun plans, then runs the plan once approved, on one connection.

func Plugins

func Plugins(ctx context.Context, profile string) ([]rpc.PluginInfo, error)

Plugins lists the plugins profile's console may run.

func Quantum added in v0.3.0

func Quantum(ctx context.Context, profile string) time.Duration

Quantum is profile's approved answer quantum as its console reports it, or 0 when it does not answer within the probe timeout.

func Release

func Release(ctx context.Context, profile, handle string) (rpc.Released, error)

Release deletes a fetched file now.

func ReleasedText added in v0.3.0

func ReleasedText(handle string, r rpc.Released) string

ReleasedText is a release's outcome as text.

func Resolve

func Resolve(pinned, arg string) (string, error)

Resolve picks the profile of a call: pinned (MCP --profile), given, or the only running console's, probing the consoles once. A given profile no console serves is the unknown_profile refusal naming its start command.

func Run

func Run(ctx context.Context, profile, id string, who ipc.Requester) (answers.Result, error)

Run runs an approved plan, or in hub mode a ticket (id is either): a ticket not decided yet answers a *PendingError.

func SetInstance added in v0.7.0

func SetInstance(name string)

SetInstance sets the lock instance every call reaches, the one client.ResolveInstance resolved once per process (the CLI after its flags, mcp before it serves).

func SourceNames

func SourceNames() ([]string, error)

SourceNames lists the profiles of the running consoles.

func Sources

func Sources(ctx context.Context) ([]rpc.Source, error)

Sources lists the profiles of the running consoles, sorted. A socket nobody answers on is left out. A lock instance (SetInstance) whose directory is not mounted here is an error naming --instance, not an empty list.

func StartCommand

func StartCommand() string

StartCommand is the command that starts the consoles: lockkit's, `lox up`, the same for every profile (a console is launched by `lox up` only).

func StatusLines

func StatusLines(out []StatusEntry) []string

StatusLines is a status report as text.

func StatusProfile added in v0.3.0

func StatusProfile(pinned, arg string) (string, error)

StatusProfile is the profile a status call reports on: a pinned server's (the argument may only repeat it), else arg ("" for every running console).

func UnknownProfileHint added in v0.6.0

func UnknownProfileHint(profile string) string

UnknownProfileHint is the unknown_profile hint for profile, a valid profile name or NAME.

Types

type Error

type Error struct {
	Kind    Kind
	Msg     string
	Refusal *refusal.Info
}

Error is an error as the agent reads it: Msg is a closed code or a fixed text, Refusal the structured refusal when there is one.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Tool

func (e *Error) Tool() *mcpkit.ToolError

Tool is e for the MCP server: refusals carry their structured form.

type Kind

type Kind int

Kind classifies an error for the CLI's exit code.

const (
	KindOther     Kind = iota // console error, transport
	KindNoConsole             // no console serves the profile
	KindRefused               // a refusal (E_* code), or an unknown plan
	KindDenied                // the human denied, or did not answer in time
)

type PendingError added in v0.4.0

type PendingError struct{ Ticket, Lock, Instance string }

PendingError is a plan or run waiting for a decision on the approval hub: run Ticket once it is decided.

func (*PendingError) Error added in v0.4.0

func (e *PendingError) Error() string

type Status

type Status struct {
	Profile        string     `json:"profile"`
	Production     bool       `json:"production"`
	AutoApprove    bool       `json:"auto_approve"`
	Level          int        `json:"level"`
	IdleTimeoutInS int        `json:"idle_timeout_in_s"`
	SessionEndsInS int        `json:"session_ends_in_s"`
	Product        rpc.Status `json:"product"`
}

Status is a console's state as the agent sees it: console fields of lockkit's status and lockfile's part, nothing else.

func GetStatus

func GetStatus(ctx context.Context, profile string) (Status, error)

GetStatus asks profile's console for its status.

type StatusEntry

type StatusEntry struct {
	Profile string  `json:"profile"`
	Console *Status `json:"console,omitempty"`
	// Busy: the console is serving another request (waiting for the human
	// on a plan, or a run until its quantum) and did not answer in time.
	Busy  bool   `json:"busy,omitempty"`
	Error string `json:"error,omitempty"`
	Hint  string `json:"hint,omitempty"`
}

StatusEntry is one profile's line of a status report: its console's status, or why there is none.

func Statuses

func Statuses(ctx context.Context, profile string) (out []StatusEntry, ok bool, err error)

Statuses reports on profile, or on every running console when it is "". ok is false when a profile has no console, or none runs.

Jump to

Keyboard shortcuts

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