Documentation
¶
Overview ¶
Package command defines user-invoked local routing. Commands are distinct from model-callable tools and durable asynchronous tasks.
Index ¶
- Constants
- Variables
- type Availability
- type Descriptor
- type Handler
- type Host
- type Invocation
- type Registry
- func (r *Registry) Descriptors(includeHidden bool) []Descriptor
- func (r *Registry) DescriptorsForSurface(includeHidden, nonInteractive bool) []Descriptor
- func (r *Registry) Dispatch(ctx context.Context, invocation Invocation, fromModel bool) (Result, error)
- func (r *Registry) DispatchNonInteractive(ctx context.Context, invocation Invocation, fromModel bool) (Result, error)
- func (r *Registry) Format(state fmt.State, _ rune)
- func (r *Registry) HelpText(includeHidden bool) string
- type Result
- type ResultKind
- type Source
Constants ¶
const ( SourceBuiltin Source = "builtin" ResultLocal ResultKind = "local" ResultPrompt ResultKind = "prompt" ResultExit ResultKind = "exit" )
Variables ¶
var ( ErrUnknown = errors.New("Unknown command") ErrSyntax = errors.New("Commands are in the form `/command [args]`") ErrNonInteractive = errors.New("command is unavailable in noninteractive mode") ErrExecution = errors.New("command execution failed") ErrSource = errors.New("command is not invocable from this source") ErrInvalidDescriptor = errors.New("invalid command descriptor") ErrDuplicate = errors.New("duplicate command name") )
Functions ¶
This section is empty.
Types ¶
type Availability ¶
type Descriptor ¶
type Invocation ¶
type Invocation struct {
Name string
Raw string
RawArguments string
Arguments []string
HistoryForm string
RedactedForm string
}
func Parse ¶
func Parse(input string) (Invocation, bool)
Parse distinguishes a syntactically valid slash command from ordinary model text. Absolute paths and malformed command-like input remain model prompts.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func Builtins ¶
Builtins returns the observable command catalog. A host may report a feature-gated operation as unavailable, but descriptors are not silently omitted simply because an optional service is absent.
func New ¶
func New(descriptors []Descriptor) (*Registry, error)
func (*Registry) Descriptors ¶
func (r *Registry) Descriptors(includeHidden bool) []Descriptor
func (*Registry) DescriptorsForSurface ¶
func (r *Registry) DescriptorsForSurface(includeHidden, nonInteractive bool) []Descriptor
DescriptorsForSurface returns the descriptors that are safe to advertise on the selected surface. Headless and SDK clients must not discover commands that dispatch will later reject as terminal-UI-only operations.
func (*Registry) DispatchNonInteractive ¶
func (r *Registry) DispatchNonInteractive(ctx context.Context, invocation Invocation, fromModel bool) (Result, error)
DispatchNonInteractive enforces the descriptor-owned headless eligibility decision before loading or invoking the command handler.
type Result ¶
type Result struct {
Kind ResultKind
Output string
Prompt string
}
type ResultKind ¶
type ResultKind string