tools

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package tools defines the TerraformTool interface and all Terraform-specific tool implementations that the agent can invoke during a conversation. Each tool satisfies both this package's interface and Eino's tool.BaseTool interface so they can be registered directly with a ChatModelAgent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecRunner

type ExecRunner struct{}

ExecRunner implements Runner by executing the real terraform binary found on PATH. It is the default runner used in production.

func NewExecRunner

func NewExecRunner() (*ExecRunner, error)

NewExecRunner returns a new ExecRunner. It verifies that the terraform binary is available on PATH at construction time.

func (*ExecRunner) Run

func (r *ExecRunner) Run(ctx context.Context, ws *WorkspaceContext, subcommand string, args ...string) (*RunResult, error)

Run executes `terraform <subcommand> [args...]` in the workspace directory and returns the captured stdout, stderr, and exit code.

type GenerateTool

type GenerateTool struct{}

GenerateTool is an Eino tool that writes LLM-generated Terraform HCL files to a target directory on the local filesystem. The agent produces the HCL content and this tool persists it, keeping file I/O out of the LLM context.

func NewGenerateTool

func NewGenerateTool() *GenerateTool

NewGenerateTool constructs a GenerateTool.

func (*GenerateTool) Description

func (t *GenerateTool) Description() string

Description returns the LLM-facing description of this tool.

func (*GenerateTool) Info

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

Info returns the Eino tool metadata including the JSON input schema.

func (*GenerateTool) InvokableRun

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

InvokableRun writes the provided HCL files to disk and returns a summary.

func (*GenerateTool) Name

func (t *GenerateTool) Name() string

Name returns the tool name registered with the agent.

type PlanTool

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

PlanTool is an Eino tool that runs `terraform plan` in a given workspace directory and returns the plan output for the agent to analyse.

func NewPlanTool

func NewPlanTool(runner Runner) *PlanTool

NewPlanTool constructs a PlanTool using the provided Runner.

func (*PlanTool) Description

func (t *PlanTool) Description() string

Description returns the LLM-facing description of this tool.

func (*PlanTool) Info

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

Info returns the Eino tool metadata including the JSON input schema.

func (*PlanTool) InvokableRun

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

InvokableRun executes the tool given a JSON-encoded input string and returns the plan output as a string for the agent to consume.

func (*PlanTool) Name

func (t *PlanTool) Name() string

Name returns the tool name registered with the agent.

type RunResult

type RunResult struct {
	// Stdout is the standard output captured from the terraform process.
	Stdout string

	// Stderr is the standard error captured from the terraform process.
	Stderr string

	// ExitCode is the process exit code (0 = success).
	ExitCode int
}

RunResult holds the output of a terraform CLI invocation.

type Runner

type Runner interface {
	// Run executes the given terraform subcommand with args in the workspace dir.
	Run(ctx context.Context, ws *WorkspaceContext, subcommand string, args ...string) (*RunResult, error)
}

Runner is the interface for executing terraform CLI commands. Abstracting this allows tests to inject a fake runner without spawning real terraform processes.

type StateTool

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

StateTool is an Eino tool that reads and analyses the Terraform state for a given workspace. It supports listing resources, showing individual resource state, and pulling the raw state JSON for deeper inspection.

func NewStateTool

func NewStateTool(runner Runner) *StateTool

NewStateTool constructs a StateTool using the provided Runner.

func (*StateTool) Description

func (t *StateTool) Description() string

Description returns the LLM-facing description of this tool.

func (*StateTool) Info

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

Info returns the Eino tool metadata including the JSON input schema.

func (*StateTool) InvokableRun

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

InvokableRun executes the tool given a JSON-encoded input string.

func (*StateTool) Name

func (t *StateTool) Name() string

Name returns the tool name registered with the agent.

type TerraformTool

type TerraformTool interface {
	// Name returns the unique tool name registered with the agent.
	Name() string

	// Description returns a human-readable description of what the tool does.
	// This text is sent to the LLM as part of the tool schema.
	Description() string
}

TerraformTool is the interface that all Terraform-aware tools must satisfy. It extends the basic Eino tool contract with a Name accessor so the agent can log and route tool calls by name without type assertions.

type WorkspaceContext

type WorkspaceContext struct {
	// Dir is the absolute path to the Terraform working directory.
	Dir string

	// VarFiles is an optional list of .tfvars files to pass to terraform commands.
	VarFiles []string

	// BackendConfig holds optional backend configuration overrides.
	BackendConfig map[string]string
}

WorkspaceContext carries the resolved path and optional configuration for the Terraform workspace the agent is currently operating on.

Jump to

Keyboard shortcuts

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