core

package
v0.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 41 Imported by: 0

Documentation

Overview

Package core provides shared CLI infrastructure: global flags, session lifecycle, assistant wiring, tool execution, and MCP server connections.

Index

Constants

This section is empty.

Variables

View Source
var EmbeddedConfig embed.FS

EmbeddedConfig holds the embedded .aura configuration.

View Source
var ErrUserAbort = errors.New("user abort")

ErrUserAbort is the cancellation cause set when the user sends SIGINT/SIGTERM. Programmatic cancellations (timeouts, parent context) use different causes, allowing downstream code to distinguish user intent from infrastructure errors.

View Source
var LaunchDir string

LaunchDir holds the CWD at process start, before os.Chdir(--workdir). Set in PersistentPreRunE, used by tasks for template variable expansion.

View Source
var WorkDir string

WorkDir holds the effective working directory after os.Chdir(--workdir). Defaults to LaunchDir when --workdir is not set.

Functions

func ConnectMCP

func ConnectMCP(ctx context.Context, asst *assistant.Assistant, events chan<- ui.Event)

ConnectMCP connects to MCP servers in parallel and registers tools on the assistant. Blocks until all servers are connected or confirmed unreachable.

func ConnectMCPServers

func ConnectMCPServers(
	ctx context.Context,
	mcps config.StringCollection[mcp.Server],
	only []string,
	interactive bool,
) ([]*mcp.Session, []string)

ConnectMCPServers connects to enabled MCP servers and returns sessions + warnings. When only is non-empty, only servers in the whitelist are connected. Used by the tools command for standalone MCP connection.

func ExecuteTool

func ExecuteTool(
	ctx context.Context,
	t tool.Tool,
	args map[string]any,
	eventsCh chan ui.Event,
	interactive bool,
) (string, error)

ExecuteTool runs a tool with a spinner and events bridge when interactive. When interactive is true, a spinner shows progress and tool-emitted SpinnerMessage events update the spinner text. When false, the tool runs silently.

func HeadlessUI

func HeadlessUI(_ Flags) (ui.UI, error)

HeadlessUI creates a headless UI for non-interactive commands.

func InteractiveUI

func InteractiveUI(flags Flags) (ui.UI, error)

InteractiveUI creates a TUI or Simple UI based on flags.

func NewAssistant

func NewAssistant(
	flags Flags,
	events chan<- ui.Event,
	onProgress func(string),
) (*assistant.Assistant, *slash.Registry, error)

NewAssistant creates a configured assistant with slash commands wired. MCP connections are NOT made here — they happen in the background after the UI starts. Returns the assistant and the slash registry (for hint resolution by the TUI).

func NotSet

func NotSet(string) bool

NotSet is the default IsSet function — always returns false.

func OutputError

func OutputError(w io.Writer, jsonOutput bool, err error) error

OutputError handles error output in both plain and JSON formats.

func OutputResult

func OutputResult(w io.Writer, jsonOutput bool, output string, err error) error

OutputResult handles both plain and JSON output for tool results.

func OutputSetupError

func OutputSetupError(w io.Writer, jsonOutput bool, err error) error

OutputSetupError handles setup/infrastructure errors (config, plugins, estimator). Like OutputError, but marks the result as a setup error so the parent process can route it to the user instead of the LLM.

func ProjectConfigDir

func ProjectConfigDir() string

ProjectConfigDir returns .aura in the current directory if it exists, or "".

func Run

func Run() error

Run is the Action handler for the root command (interactive mode).

func RunInteractive

func RunInteractive(ctx context.Context, cancel context.CancelCauseFunc, asst *assistant.Assistant, u ui.UI) error

RunInteractive is the SessionFunc for interactive commands (run, web). It wires the Ask tool, starts the assistant loop, and blocks on the UI.

func RunSession

func RunSession(flags Flags, makeUI func(Flags) (ui.UI, error), work SessionFunc) error

RunSession handles the full assistant session lifecycle: flags, config, UI, assistant, MCP, signal handling, graceful shutdown, auto-save. The work callback does the mode-specific processing.

func RunSingleTool

func RunSingleTool(w io.Writer, toolName string, toolArgs map[string]any) error

RunSingleTool handles the full lifecycle of a single-tool CLI command: flags, config, tool registry, lookup, execute, print output. Used by vision, transcribe, and speak commands.

func StoreFlags

func StoreFlags(f Flags)

StoreFlags saves the parsed flags for later retrieval via GetFlags. Called once from the root Before hook after Destination pointers are resolved.

Types

type Flags

type Flags struct {
	Config         []string
	Provider       string
	Agent          string
	Model          string
	EnvFile        []string
	Workdir        string
	Show           bool
	Print          bool
	PrintEnv       bool
	Simple         bool
	Auto           bool
	Mode           string
	System         string
	Think          string
	Debug          bool
	Experiments    bool
	WithoutPlugins bool
	UnsafePlugins  bool
	Resume         string
	Continue       bool
	Output         string
	IncludeTools   []string
	ExcludeTools   []string
	IncludeMCPs    []string
	ExcludeMCPs    []string
	MaxSteps       int
	TokenBudget    int
	Providers      []string
	Dry            string

	Set    map[string]string
	Home   string
	Mirror *mirror.Mirror
	Writer io.Writer

	// Subcommand flags (nested by command path).
	Run        RunFlags
	Web        WebFlags
	Models     ModelsFlags
	Tools      ToolsFlags
	Query      QueryFlags
	Init       InitFlags
	Transcribe TranscribeFlags
	Speak      SpeakFlags
	Tasks      TasksFlags
	Plugins    PluginsFlags
	Skills     SkillsFlags
	Login      LoginFlags

	// IsSet reports whether a root-level flag was explicitly set via CLI or env var.
	// Wired to cmd.IsSet in the Before hook.
	IsSet func(string) bool
}

Flags holds all CLI flag values, resolved via urfave/cli Destination pointers. Persistent (root) flags are top-level fields; subcommand flags are nested in per-command sub-structs. Precedence: CLI flag > AURA_* env var > default value.

func GetFlags

func GetFlags() Flags

GetFlags returns the flags stored during the root Before hook.

func (Flags) ConfigOptions

func (f Flags) ConfigOptions() config.Options

ConfigOptions returns the base config.Options derived from CLI flags. Callers that need additional fields (WithPlugins, ExtraTaskFiles, etc.) can mutate the returned struct before passing it to config.New.

func (Flags) Homes

func (f Flags) Homes() []string

Homes returns all config directories in merge order: global home first, then the --config entries. Files.Load iterates left-to-right with last-wins dedup.

func (Flags) LoadEnvFiles

func (f Flags) LoadEnvFiles(explicit bool) error

LoadEnvFiles loads environment files from the EnvFile list. When explicit is true (CLI flag or AURA_ENV_FILE), every file must exist. When false (default), missing files are silently ignored.

func (Flags) ToEnv

func (f Flags) ToEnv() []string

ToEnv returns AURA_KEY=value pairs for every flag explicitly set via CLI or env var.

func (Flags) WriteHome

func (f Flags) WriteHome() string

WriteHome returns the primary config directory for writes (sessions, debug, auth, plugins). This is the last non-empty element of Config, falling back to Home (global config home).

type InitFlags

type InitFlags struct {
	Dir string
}

type LoginFlags

type LoginFlags struct {
	Local bool
}

type ModelsFlags

type ModelsFlags struct {
	SortBy string
	Filter []string
}

type PluginsAddFlags

type PluginsAddFlags struct {
	Name     string
	Global   bool
	Ref      string
	NoVendor bool
	Subpath  string
}

type PluginsFlags

type PluginsFlags struct {
	Add    PluginsAddFlags
	Update PluginsUpdateFlags
}

type PluginsUpdateFlags

type PluginsUpdateFlags struct {
	All      bool
	NoVendor bool
}

type QueryFlags

type QueryFlags struct {
	Top int
}

type RunFlags

type RunFlags struct {
	Timeout time.Duration
}

type SessionFunc

type SessionFunc func(ctx context.Context, cancel context.CancelCauseFunc, asst *assistant.Assistant, u ui.UI) error

SessionFunc is the mode-specific work done within a session. It receives a cancellable context, the fully-wired assistant, and the UI. For interactive mode, this runs Loop() + UI.Run(). For batch mode, this runs ProcessInput() calls sequentially.

type SkillsAddFlags

type SkillsAddFlags struct {
	Name    string
	Global  bool
	Ref     string
	Subpath string
}

type SkillsFlags

type SkillsFlags struct {
	Add    SkillsAddFlags
	Update SkillsUpdateFlags
}

type SkillsUpdateFlags

type SkillsUpdateFlags struct {
	All bool
}

type SpeakFlags

type SpeakFlags struct {
	Voice string
}

type TasksFlags

type TasksFlags struct {
	Files []string
	Run   TasksRunFlags
}

type TasksRunFlags

type TasksRunFlags struct {
	Prepend     []string
	Append      []string
	Start       int
	Timeout     time.Duration
	Now         bool
	Concurrency uint

	// IsSet reports whether a tasks-run-level flag was explicitly set.
	IsSet func(string) bool
}

type ToolsFlags

type ToolsFlags struct {
	JSON       bool
	Raw        bool
	RO         bool
	ROPaths    []string
	RWPaths    []string
	Headless   bool
	WithMCP    bool
	MCPServers []string
}

type TranscribeFlags

type TranscribeFlags struct {
	Language string
}

type WebFlags

type WebFlags struct {
	Bind string
}

Jump to

Keyboard shortcuts

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