cli

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package cli is the mast binary, for building your own.

The stock binary is one line over this package:

func main() { os.Exit(cli.Main(context.Background(), os.Args[1:])) }

A custom main.go is the same line with options. The result is the same binary — the same flags, subcommands, servers, governance and exit codes — with your models and tools added:

func main() {
	os.Exit(cli.Main(context.Background(), os.Args[1:],
		cli.WithModels(func(name string) (model.LLM, bool) {
			if strings.HasPrefix(name, "acme-") {
				return acme.New(name), true
			}
			return nil, false // fall through to mast's providers
		}),
		cli.WithTools("tickets", openTicket, closeTicket),
	))
}

Every option takes ADK's own types (model.LLM, tool.Tool, tool.Toolset), so nothing here commits you to a mast type beyond the options themselves.

What you add is governed like what mast ships.

A model you supply is metered from the usage it reports on each response, like any other, and held to the workload's budget by it; a model that reports no usage cannot be held to a cost ceiling by anything. If mast's pricing catalog does not know the model, its calls are priced at the fallback rate and counted as unpriced rather than as free.

A tool you supply is a toolset, reached the way an MCP server is: by a specialist whose tools.mcp allowlist names it, or by one that declares no tools.mcp at all and so inherits every toolset — which startup refuses for a read-only specialist. mast classifies a tool it does not know as mutating, so the workload's on_mutation policy applies to its calls (by default they park for an operator's approval) until the workload's tool_catalog.tools marks it read-only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(ctx context.Context, args []string, opts ...Option) int

Main runs the mast binary over args — the command line without the program name, os.Args[1:] — and returns the process exit status for the caller to hand to os.Exit. The flags, subcommands and exit codes are the ones the stock binary documents.

Cancelling ctx shuts serve mode down the way SIGINT or SIGTERM does: the same drain, the same exit status. Main does not call os.Exit itself, with one exception: if serve mode's teardown hangs past its deadline after the drain, a watchdog dumps every goroutine's stack and exits the process, because nothing is left to return to.

Types

type Option

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

Option is something a custom main.go adds to the binary. Build one with a With function; the zero Option adds nothing.

func WithModels

func WithModels(lookup func(name string) (model.LLM, bool)) Option

WithModels adds a model resolver, asked for every model name before mast's own providers: the --model value, and each specialist's `model:` override. Return the model and true to supply it, or false to fall through to mast's providers.

Given more than once, the resolvers are asked in the order given and the first that answers wins.

A model you return is used as you built it: mast does not wrap it in its own retry, because your client owns that. Under --model=echo or another offline fake the whole process is a test double and every specialist's model collapses to the fake, yours included.

func WithTools

func WithTools(name string, tools ...tool.Tool) Option

WithTools adds tools as one toolset called name — WithToolset for when you have tools rather than a toolset. A specialist reaches them by naming it in tools.mcp.

func WithToolset

func WithToolset(ts tool.Toolset) Option

WithToolset adds a toolset, offered to every Task-mode specialist whose tools.mcp allowlist names it — `- server: <Name()>` — exactly as it would name an MCP server, including the optional tools: list that narrows it to particular tools. Startup refuses an allowlist naming a toolset that does not exist, a toolset whose name is empty or taken by another toolset or by an MCP server in the workload's catalog, and a read-only specialist that would reach a tool it has not enumerated.

Jump to

Keyboard shortcuts

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