tools

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeName

func NormalizeName(name string) string

NormalizeName strips the suffix the server appends to tool names.

func Refused added in v1.7.0

func Refused(result string) bool

Refused reports whether result is what Handle returned for a call that did not run: denied, interrupted at the prompt, or not approvable.

func RunShell added in v1.7.0

func RunShell(ctx context.Context, show UI, command string) string

RunShell runs a command the user typed in the chat ("!cmd"), shown with show like the agent's commands but without asking and without a time limit. It returns the output and exit status, for the model.

func ToolDefinitions

func ToolDefinitions() []docsgpt.Tool

ToolDefinitions returns the tool schemas to send in chat completion requests.

Types

type Session added in v1.7.0

type Session struct {
	AutoApprove bool          // run every call unasked: --auto-approve, "Always approve", /approve
	Timeout     time.Duration // per command or read
	UI          UI            // stderr when nil
	// contains filtered or unexported fields
}

Session runs the model's tool calls for one chat session or ask run. Approval is the only gate: every command and write is shown and asked about, unless AutoApprove is set or the user chose "Always allow" for it earlier in the session. Reads ask only outside the working directory or for files that may hold secrets (readReason).

func (*Session) Handle added in v1.7.0

func (s *Session) Handle(ctx context.Context, cancel context.CancelFunc, tc docsgpt.ToolCall) string

Handle runs one tool call and returns the result for the model. A Ctrl+C (or Esc) at the approval prompt calls cancel, which stops the run.

type UI added in v1.7.0

type UI interface {
	// Open starts the block of a call; another Open before Close ends
	// the first as it is (a command the user edited).
	Open(title, note string)
	Lines(lines []string) // preview lines, safe already
	Output() io.Writer    // a running command's output, until Close
	Close(ok bool, status string)
	Choose(items []ui.Item) (string, error) // ui.ErrCancelled on Esc or Ctrl+C
	Edit(title, value string) (string, error)
}

UI shows tool calls and asks the user about them: on stderr by default (ask), in the transcript and panel of the chat's screen there.

Jump to

Keyboard shortcuts

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