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

cli

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package cli implements CLI subcommands that communicate with a running rysh session via NATS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnsaSend added in v0.2.4

func AnsaSend(store *session.Store, sessionName, asPaneID, to, mode, text string) (*msg.MsgCLIResponse, error)

AnsaSend routes a message to another pane through ANSA.

Deliberately NOT RyshCommandResult with an "ansa send" body: that path focuses the target pane and echoes the command line into its output buffers. For a control channel carrying work orders between dozens of agents, both are disqualifying — routing must not move the human's cursor.

to may be a pane id or an @given-name; it is resolved at the daemon edge, and an ambiguous name comes back as a refusal listing the candidate ids rather than as a guess.

func BoardCaps added in v0.2.11

func BoardCaps(store *session.Store, sessionName, asPaneID string) ([]string, error)

BoardCaps asks the running daemon which board capabilities it has (design 051). An older daemon answers with none.

func BoardFlowPanes added in v0.2.11

func BoardFlowPanes(store *session.Store, sessionName string) ([]board.FlowPane, error)

BoardFlowPanes lists the session's agent panes as the flow model takes them (design 052): ids, names and meta from one workspace snapshot.

func BoardPost added in v0.2.4

func BoardPost(store *session.Store, sessionName, asPaneID, kind, threadID, boardID, text string) (*msg.MsgCLIResponse, error)

BoardPost posts one message to the agents board on behalf of a named pane.

This is deliberately NOT RyshCommandResult with a "board post" body. That path resolves and FOCUSES the target pane and echoes the command line into its output buffers before dispatching, which is fine for a human typing ##board into their own pane and unacceptable for an agent posting a milestone: with dozens of agents posting, focus would jump under the human's hands and every post would land in some pane's scrollback. MsgCLIBoardPost reaches the workspace's board handler directly and does neither.

asPaneID is required and is not inferred: a post names its poster.

There is no envelope, fleet, role or unit parameter by founder ruling (gate 4): a board post is chat — who spoke, under which thread — and fleet routing is a separate concern that does not enter this schema. boardID names the board; "" lets the daemon resolve it from the poster's pane, which is what every pre-028 caller does.

func BoardResolve added in v0.2.11

func BoardResolve(store *session.Store, sessionName, asPaneID string) (*msg.MsgCLIResponse, error)

BoardResolve asks the workspace for a pane's full uuid (resp.ID) and the board it posts to (resp.Output), without focusing or echoing into it.

func BoardSendRequest added in v0.2.11

func BoardSendRequest(store *session.Store, sessionName string, req *msg.MsgCLIBoardPost) (*msg.MsgCLIResponse, error)

BoardSendRequest sends a fully-formed MsgCLIBoardPost — the door for the design-050 kinds (cmd, ack), whose extra fields BoardPost's positional signature does not carry. Same silent agent door, same reply.

func BoardTail added in v0.2.6

func BoardTail(store *session.Store, sessionName, boardID string, q board.Query) (*board.QueryReply, error)

BoardTail asks the session's recorder what is on the agents board.

It ASKS ABLA over msg.BoardQuerySubject; it does not open the board's KV bucket. That is the whole point of the read path and it is not an implementation detail — see internal/board/query.go and F-23, where a second call site deriving the bucket name read an empty board and reported it as a quiet one.

A recorder that does not answer comes back as board.ErrNoRecorder with a NIL reply. Callers must branch on it: "nobody answered" is not "nothing was posted", and the whole value of this command depends on not conflating them. boardID names which board to read; "" is the session board (design 028).

func CronApply added in v0.2.11

func CronApply(store *session.Store, sessionName, jobName, input string) (*msg.MsgCLIResponse, error)

CronApply sends an edited cron job Input to a running session — the non-interactive half of `##cron edit <name>`, invoked by `rysh cron apply` after $EDITOR exits successfully on the temp file `##cron edit` created.

func FleetList added in v0.2.6

func FleetList(store *session.Store, sessionName, name string) (*fleet.Reply, error)

FleetList asks the session's registry which fleets exist. name selects one; empty lists all.

It ASKS THE REGISTRY ACTOR and never opens its KV bucket, which is the rule the board's read path already established — a second call site that derives a bucket name is how F-23 happened, and it failed while looking healthy.

A registry that does not answer comes back as fleet.ErrNoRegistry with a NIL reply. Callers must branch on it: "nobody answered" is not "no fleets exist".

func FleetUpdate added in v0.2.6

func FleetUpdate(store *session.Store, sessionName string, u fleet.Update) (*fleet.UpdateReply, error)

FleetUpdate writes to the registry: register, forget, state, membership.

The reply is returned even when the registry REFUSED, so a caller can print what was wrong rather than a generic failure — `fleetctl` registers a fleet and immediately puts agents in it, and "why" is the difference between retrying and stopping.

func LaneCreate

func LaneCreate(store *session.Store, sessionName, tabID string) error

LaneCreate creates a new lane in the specified tab.

func LaneDelete

func LaneDelete(store *session.Store, sessionName, tabID, laneID string) error

LaneDelete deletes a lane by ID.

func LaneList

func LaneList(store *session.Store, sessionName, tabID string) error

LaneList lists all lanes in a tab.

func PaneCreate

func PaneCreate(store *session.Store, sessionName, tabID, laneID, paneGroupID string) error

PaneCreate creates a new pane in the specified tab and lane. If paneGroupID is empty, a new pane-group is auto-created first. If paneGroupID is provided, a stacked pane is added to the existing group.

func PaneDelete

func PaneDelete(store *session.Store, sessionName, paneID string) error

PaneDelete deletes a pane by ID.

func PaneGroupCreate

func PaneGroupCreate(store *session.Store, sessionName, tabID, laneID string) error

PaneGroupCreate creates a new pane group (split down) in the specified lane.

func PaneGroupDelete

func PaneGroupDelete(store *session.Store, sessionName, tabID, laneID, paneGroupID string) error

PaneGroupDelete deletes a pane group by ID.

func PaneGroupList

func PaneGroupList(store *session.Store, sessionName, tabID, laneID string) error

PaneGroupList lists all pane groups.

func PaneList

func PaneList(store *session.Store, sessionName, tabID, laneID string) error

PaneList lists panes in the specified tab and lane.

func PaneSendInput

func PaneSendInput(store *session.Store, sessionName, paneID, text, mode string) error

PaneSendInput sends input (shell command or AI prompt) to a pane in a running or detached session. If paneID is empty, the input is sent to the active pane via the workspace inbox. If paneID is specified, the input is delivered directly to that pane's inbox as a MsgPaneExecShell or MsgPaneExecPrompt (the PaneActor does not handle MsgSubmitInput directly; that conversion is done by PaneGroupActor in the normal routing chain).

func PeerCommand added in v0.2.11

func PeerCommand(store *session.Store, sessionName, asPaneID string, args []string) (*msg.MsgCLIResponse, error)

func PipelineDisable

func PipelineDisable(store *session.Store, sessionName, tabID string) error

PipelineDisable disables pipeline mode for a tab.

func PipelineEnable

func PipelineEnable(store *session.Store, sessionName, tabID string) error

PipelineEnable enables pipeline mode for a tab.

func PipelineList

func PipelineList(store *session.Store, sessionName string) error

PipelineList lists pipeline state for all tabs.

func RyshCommand

func RyshCommand(store *session.Store, sessionName, tabID, paneID, command string) error

RyshCommand runs a "##" system command on a running/detached session and prints its output. It is the command-line equivalent of typing a "##" command in a pane. command is the rysh command body WITHOUT the leading "##" (e.g. "cmd echo hailo", "pane info", "tab list"). tabID/paneID select the target pane; empty values fall back to the tab's / workspace's active pane.

func RyshCommandResult added in v0.2.3

func RyshCommandResult(store *session.Store, sessionName, tabID, paneID, command string) (*msg.MsgCLIResponse, error)

RyshCommandResult is RyshCommand without the printing: it runs a "##" system command and hands back the daemon's raw response so the caller decides what to do with the output, the OK flag and the error text.

`rysh exec` needs this to render --json, and to keep "the command failed" (resp.OK == false) distinct from "we could not ask" (a transport error) — the two mean different things to a script and want different exit codes.

func StackedPaneCreate

func StackedPaneCreate(store *session.Store, sessionName, tabID, laneID, paneGroupID string) error

StackedPaneCreate creates a new stacked pane in the specified pane group.

func StackedPaneList

func StackedPaneList(store *session.Store, sessionName, paneGroupID string) error

StackedPaneList lists stacked panes in a pane group.

func TabCreate

func TabCreate(store *session.Store, sessionName string) error

TabCreate creates a new tab.

func TabDelete

func TabDelete(store *session.Store, sessionName, tabID string) error

TabDelete deletes a tab by ID.

func TabList

func TabList(store *session.Store, sessionName string) error

TabList lists all tabs in the running session.

Types

type Client

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

Client connects to a running rysh session's NATS server.

func Connect added in v0.2.3

func Connect(store *session.Store, sessionName string) (*Client, error)

Connect opens a client against a running (or detached) session by name, setting the NATS subject prefix to match it.

Exported for `rysh prompt`, which needs a long-lived connection it can subscribe on rather than the single request/reply the helpers here wrap.

func ConnectPersistent added in v0.2.11

func ConnectPersistent(store *session.Store, sessionName string) (*Client, error)

ConnectPersistent is Connect with a connection that reconnects forever, for `rysh board listen`. See NewPersistentClient.

func NewClient

func NewClient(port int, sessionName string) (*Client, error)

NewClient connects to the NATS server at the given port.

func NewPersistentClient added in v0.2.11

func NewPersistentClient(port int, sessionName string) (*Client, error)

NewPersistentClient is NewClient for a LONG-LIVED caller (rysh board listen): it reconnects forever instead of never, so a listener outlives a daemon restart or a NATS host that blips. A one-shot command keeps NewClient's fail-fast behaviour, where a dead session must be an error now.

func (*Client) Close

func (c *Client) Close()

Close drains and closes the NATS connection.

func (*Client) Codecs added in v0.2.11

func (c *Client) Codecs() *msg.CodecRegistry

func (*Client) Conn added in v0.2.11

func (c *Client) Conn() *nats.Conn

Conn, Publisher and Codecs expose the connection to a long-lived caller that subscribes rather than making one request.

func (*Client) Flush added in v0.2.3

func (c *Client) Flush() error

Flush blocks until buffered publishes have reached the server.

func (*Client) Publisher added in v0.2.11

func (c *Client) Publisher() *msg.NATSPublisher

func (*Client) Request

func (c *Client) Request(message interface{}, timeout time.Duration) (interface{}, error)

Request sends a request/reply message to the workspace inbox.

func (*Client) RequestFromSubject

func (c *Client) RequestFromSubject(subject string, message interface{}, timeout time.Duration) (interface{}, error)

RequestFromSubject sends a request/reply to a specific subject.

func (*Client) RequestSnapshot

func (c *Client) RequestSnapshot(timeout time.Duration) (interface{}, error)

RequestSnapshot requests the structural workspace snapshot: ids, titles, layout and per-pane flags, with no output buffers and no command history. Its only callers are the list commands, which read nothing else — and the full snapshot they used to pull measured 4.2 MB / 444 ms on a 22-pane session, once per `rysh tab|lane|pane list`, which agents run in loops.

func (*Client) Send

func (c *Client) Send(message interface{}) error

Send publishes a fire-and-forget message to the workspace inbox. It flushes the connection so the message is delivered before the short-lived CLI process exits (Close drains asynchronously).

func (*Client) SendToSubject

func (c *Client) SendToSubject(subject string, message interface{}) error

SendToSubject publishes a fire-and-forget message to a specific subject. It flushes so the message is delivered before the CLI process exits.

func (*Client) Subscribe added in v0.2.3

func (c *Client) Subscribe(subject string, handler func(interface{})) (*nats.Subscription, error)

Subscribe registers a handler for a subject, decoding each message through the session's codec registry before handing it over. A message that fails to decode is dropped rather than surfaced: the bus carries types this process may not know about, and a CLI watching one conversation must not fall over on somebody else's traffic.

It exists for `rysh prompt`, which has to watch a pane's agentic phase transitions to know when a turn has finished — a request/reply cannot express "tell me when this is done".

Jump to

Keyboard shortcuts

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