Help us shape the future of Go! Take the 2026 Go Developer Survey

clitool

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeEnv

func MergeEnv(base, overrides map[string]string) map[string]string

MergeEnv returns a new map with base overlaid by overrides.

Types

type CliTool

type CliTool struct {
	// Def describes the base command configuration.
	Def Definition
}

Tool exposes a configured CLI command as an invocable tool to the model. Name and description are derived from Definition. Users can provide additional argv, env, workdir, and timeout at call-time.

func (*CliTool) Info

func (t *CliTool) Info(ctx context.Context) (*schema.ToolInfo, error)

Info describes the tool to the model.

func (*CliTool) InvokableRun

func (t *CliTool) InvokableRun(ctx context.Context, argumentsInJSON string, _ ...tool.Option) (string, error)

InvokableRun executes the configured command with request overrides and returns a JSON outcome.

type CliToolRequest

type CliToolRequest struct {
	// Args are extra argv to append to the configured command.
	Args    []string `json:"args,omitempty"`
	Workdir string   `json:"workdir,omitempty"`
}

type Definition

type Definition struct {
	Name    string
	Command string
	Desc    string
	Args    []string          // parsed from command
	Env     map[string]string // merged with envs from command, env map has higher precedence than envs from command.
}

Definition describes a CLI tool that can be exposed to the agent. Name must be unique across all tools. Command is executed without a shell by default via SubprocessExecutor.

func MustNewDefinition

func MustNewDefinition(name, command, desc string, env map[string]string) Definition

func NewDefinition

func NewDefinition(name, command, desc string, env map[string]string) (Definition, error)

type Outcome

type Outcome struct {
	Ran         bool
	Command     string
	ExitCode    int
	Duration    time.Duration
	Stdout      string
	Stderr      string
	StartedAt   time.Time
	CompletedAt time.Time
}

Outcome describes the result of a subprocess execution.

func (Outcome) String

func (o Outcome) String() string

String renders a human-readable summary of the subprocess outcome.

type SubprocessExecutor

type SubprocessExecutor struct{}

SubprocessExecutor runs commands using exec.CommandContext without a shell.

func (*SubprocessExecutor) Execute

func (e *SubprocessExecutor) Execute(ctx context.Context, argv []string, env map[string]string, workdir string) Outcome

Jump to

Keyboard shortcuts

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