cli

package
v0.0.0-...-4c48340 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 75 Imported by: ? 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 cli is agentop: the commands that inspect and run Cortex — a terminal UI over AuthBridge's in-memory session store, plus subcommands for running Cortex as a service, pointing Claude Code at it, and costing tool definitions.

A package rather than a `main`, so that one binary carries both halves of Cortex: `cortex <command>` calls Main directly, and the standalone `agentop` binary (../main.go) is a shim that execs `cortex`. Two binaries meant two version numbers that could disagree about each other and two things to keep current; one binary makes "is anything out of date?" a single question. See cmd/README.md.

`cortex observe` opens the viewer — a Namespaces → Pods picker, then the session-events view for the pod it port-forwards. Pass --endpoint to skip the picker and connect directly.

A bare `cortex` opens the viewer as well, and that is the documented path now rather than a tolerated leftover. Two cases take precedence over it: with no terminal on either end it writes the root usage to stderr and exits 2, so a container or a CI step gets something it can act on instead of a TUI error; and on a moca host, where MOCA_EGRESS_CONTROL_SOCK is set, it starts the egress proxy, because a viewer there would leave the host with no egress.

Index

Constants

View Source
const MocaControlSockEnv = "MOCA_EGRESS_CONTROL_SOCK"

Variables

This section is empty.

Functions

func Main

func Main(prefix, args []string) int

Main runs an agentop command line and returns the process exit code.

prefix is the command words that reached here: {os.Args[0]} from both hosts, since cmd/cortex passes os.Args[:1]. Nothing sends {os.Args[0], "agentop"} any more. Kept as a parameter rather than read from os.Args here, because setup quotes it back at the user and a test must be able to supply it.

Returns the code rather than calling os.Exit, so that a host `main` owns the exit and the TestMain child in cmd_observe_test.go can drive this the same way.

func SetServe

func SetServe(fn func(args []string) int)

SetServe registers the function that starts the proxy, which is what `cortex serve` and the legacy flags-only command line reach.

Injected rather than imported, because the dependency only runs one way: cmd/cortex imports these commands, so these commands cannot import the proxy. One list of names then drives the dispatch, the usage text and the unknown-command message (approach A in #2313).

func SetVersion

func SetVersion(v, versionLine, rev string)

SetVersion records the host binary's version, the line its `--version` prints, and its build revision, so that `cortex --version`, the service stamp and the viewer's title bar all name the binary actually running.

Called once, before Main, by whatever `main` links these commands in. A caller that does not call it leaves "dev", which is what a local build of the shim's own tests sees.

Types

This section is empty.

Jump to

Keyboard shortcuts

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