monitorcmd

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	BotDBDefaultName    = "bot.db"
	LegacyBotDBFileName = "korbit-bot.db"
)

BotDBDefaultName is the script-local database's name under a CLI home — deliberately separate from the action journal file (a bot script must never touch the journal), and carrying no product name: the directory already says whose data it is. LegacyBotDBFileName is the name a home created under the earlier product name carries, used for exactly one home (see botDBFileName).

Variables

This section is empty.

Functions

func BotDBPaths

func BotDBPaths(home string) []string

BotDBPaths returns every bot-database file that belongs to home: the database under BOTH spellings, each with its sidecars, for a caller removing the CLI's data (`self uninstall`). Both are listed because a home whose directory was renamed without its files still carries the other spelling.

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 Digital X 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