monitorcmd

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package monitorcmd implements the `monitor` command — the CLI's one streaming command and its experimental JavaScript bot runtime. It runs against the clienv.Cmd seam, so cli (and the mcp/tui frontends) dispatch into it without it importing cli.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(cx *clienv.Cmd, cmd *cobra.Command, args []string) error

Run parses the channel flags, builds the streaming session and the script runtime, and pumps events until the session ends or a stop condition is reached.

func RunError

func RunError(err error) error

RunError classifies a fatal session error for the exit-code contract: a rejected WebSocket handshake carrying a Korbit error envelope is an API rejection (exit 3, with the symbolic code preserved); anything else surfaces as-is (untyped → exit 1).

Types

type Plan

type Plan struct {
	DryRun         bool      `json:"dryRun"`
	Subscriptions  []PlanSub `json:"subscriptions"`
	PublicURL      string    `json:"wsPublicUrl"`
	PrivateURL     string    `json:"wsPrivateUrl,omitempty"`
	RESTBaseURL    string    `json:"restBaseUrl"`
	Auth           bool      `json:"auth"`
	Backfill       bool      `json:"backfill"`
	Where          string    `json:"where,omitempty"`
	Init           string    `json:"init,omitempty"`
	On             string    `json:"on,omitempty"`
	Jq             string    `json:"jq,omitempty"`
	Stateful       bool      `json:"stateful,omitempty"`
	NoReconnect    bool      `json:"noReconnect,omitempty"`
	StreamLogLevel string    `json:"streamLogLevel,omitempty"`
	// Note is an optional caveat about the plan. Additive and monitor leaves it
	// empty; the tui uses it to say its account coverage only resolves at startup.
	Note string `json:"note,omitempty"`
}

Plan is the --dry-run document: what would be streamed, from where, with which recovery and script settings — nothing is dialed. It implements textout.TextFormatter (see format.go) so the emitter renders the human plan and marshals this struct in --json mode. Reused by the tui's --dry-run.

func PlanDoc

func PlanDoc(subs []stream.Subscription, baseURL, publicURL, privateURL string, private bool, where, initSrc, onSrc, jqSrc string, stateful, backfill, noReconnect bool, streamLog string) Plan

PlanDoc builds the --dry-run Plan.

func (Plan) FormatText

func (p Plan) FormatText(w io.Writer)

FormatText renders the --dry-run plan for human output (textout.TextFormatter); the --json path marshals the Plan struct. Empty script rows (where/init/on) and the private URL when public-only are dropped by KVBlock's skip-empty rule.

type PlanSub

type PlanSub struct {
	Channel     string   `json:"channel"`
	Symbols     []string `json:"symbols,omitempty"`
	AccountSeqs []int    `json:"accountSeqs,omitempty"`
	Intervals   []string `json:"intervals,omitempty"`
	History     int      `json:"history,omitempty"`
	// Implicit marks a subscription made only to feed a derived channel (the
	// trade sub under --candles without --trades): it is real on the wire, but
	// its own data lines are suppressed from output.
	Implicit bool `json:"implicit,omitempty"`
}

PlanSub is one subscription line of a Plan. The synthesized candle channel appears as its own entry carrying Intervals (and History when requested), alongside the wire trade subscription that feeds it.

Jump to

Keyboard shortcuts

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