tools

package
v0.107.6-beta.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Ask func(ctx context.Context, req AskRequest) (answers []string, ok bool)
View Source
var Browser *browser.Manager
View Source
var ComputerApprover func(app string) bool
View Source
var ComputerPolicy *computer.Policy
View Source
var LSP interface {
	WaitDiagnostics(ctx context.Context, path string) string
}
View Source
var Suggester func(name string) []string

Functions

func AttachImage added in v0.107.3

func AttachImage(ctx context.Context, ext string, data []byte) bool

AttachImage attaches an image of the given extension (png, jpg, gif, webp) to the current tool result when the model supports vision.

func AttachScreenshot added in v0.103.0

func AttachScreenshot(ctx context.Context, jpeg []byte) bool

func Authorize added in v0.103.0

func Authorize(ctx context.Context, tool, command string) error

func BeforeFileMutation added in v0.107.0

func BeforeFileMutation(ctx context.Context, path string)

func BinaryPlaceholder

func BinaryPlaceholder(name string, size int) string

func CommandRule

func CommandRule(command string) string

func Defs

func Defs(ts []Tool) []ai.Tool

func Execute

func Execute(ctx context.Context, ts []Tool, name string, args json.RawMessage) string

func IsBinary

func IsBinary(data []byte) bool

func IsStale

func IsStale(err error) bool

func ResolvePath added in v0.103.0

func ResolvePath(ctx context.Context, path string) string

func SuggestTool

func SuggestTool(name string, candidates []string) []string

func ToolCallID added in v0.107.0

func ToolCallID(ctx context.Context) string

func Truncate

func Truncate(s string) string

func TruncateTail

func TruncateTail(s string) string

func WithAsk added in v0.107.0

func WithAsk(ctx context.Context, ask AskFunc) context.Context

func WithFileMutationObserver added in v0.107.0

func WithFileMutationObserver(ctx context.Context, observe func(string)) context.Context

WithFileMutationObserver records the pre-image immediately before a file tool mutates it.

func WithGate added in v0.103.0

func WithGate(ctx context.Context, gate func(GateRequest) (GateDecision, string)) context.Context

func WithLiveAgentNamedRoots added in v0.107.0

func WithLiveAgentNamedRoots(ctx context.Context, roots map[string]WorkspaceRoot) context.Context

WithLiveAgentNamedRoots maps root:// aliases and enabled skill:// names to explicit grants. Unmapped names never fall back to arbitrary host paths.

func WithOnUpdate

func WithOnUpdate(ctx context.Context, onUpdate func(outputSoFar string)) context.Context

func WithRunIdentity added in v0.107.0

func WithRunIdentity(ctx context.Context, identity RunIdentity) context.Context

func WithToolCallID added in v0.107.0

func WithToolCallID(ctx context.Context, id string) context.Context

func WithWorkingDir added in v0.103.0

func WithWorkingDir(ctx context.Context, dir string) context.Context

func WithWorkspaceRoots added in v0.107.0

func WithWorkspaceRoots(ctx context.Context, roots []WorkspaceRoot) context.Context

func WorkingDir added in v0.103.0

func WorkingDir(ctx context.Context) string

Types

type AskFunc added in v0.107.0

type AskFunc func(context.Context, AskRequest) ([]string, bool)

type AskOption

type AskOption struct {
	Label       string `json:"label"`
	Description string `json:"description"`
	Recommended bool   `json:"recommended,omitempty"`
}

type AskQuestion added in v0.107.0

type AskQuestion struct {
	ID       string      `json:"id,omitempty"`
	Header   string      `json:"header,omitempty"`
	Prompt   string      `json:"prompt"`
	Options  []AskOption `json:"options"`
	Multiple bool        `json:"multiple,omitempty"`
}

type AskRequest

type AskRequest struct {
	Question  string        `json:"question,omitempty"`
	Options   []AskOption   `json:"options,omitempty"`
	Multiple  bool          `json:"multiple,omitempty"`
	Questions []AskQuestion `json:"questions,omitempty"`
}

type GateDecision

type GateDecision int
const (
	GateAllowOnce GateDecision = iota
	GateAllowAlways
	GateReject
)

type GateRequest

type GateRequest struct {
	Context context.Context
	Tool    string
	Command string
	Rule    string
}

type InteractiveRunner

type InteractiveRunner interface {
	Run(ctx context.Context, command string, timeout time.Duration, keys <-chan []byte) string
}
var InteractiveBash InteractiveRunner

type LiveAgentToolMetadata added in v0.107.0

type LiveAgentToolMetadata struct {
	ID            string   `json:"id"`
	Icon          string   `json:"icon"`
	ToolName      string   `json:"toolName"`
	Category      string   `json:"categoryId"`
	ReadOnly      bool     `json:"isReadOnly"`
	RuntimeScope  []string `json:"runtimeScopes"`
	DefaultPolicy string   `json:"defaultPolicy"`
}

LiveAgentToolMetadata mirrors the original builtinToolCatalog entries needed by provider/UI policy code without importing LiveAgent's TypeScript bundle.

func LiveAgentToolCatalogMetadata added in v0.107.0

func LiveAgentToolCatalogMetadata() []LiveAgentToolMetadata

type ManagedProcessManager added in v0.107.0

type ManagedProcessManager = liveagentProcessManager

ManagedProcessManager retains tool processes across model changes in a session.

func NewManagedProcessManager added in v0.107.0

func NewManagedProcessManager() *ManagedProcessManager

type Result added in v0.103.0

type Result struct {
	Text      string
	Parts     []ai.ContentPart
	Failed    bool
	Cancelled bool
}

func ExecuteResult added in v0.103.0

func ExecuteResult(ctx context.Context, ts []Tool, name string, args json.RawMessage, vision bool) Result

type RunIdentity added in v0.107.0

type RunIdentity struct {
	ConversationID string
	RunID          string
}

func RunIdentityFromContext added in v0.107.0

func RunIdentityFromContext(ctx context.Context) (RunIdentity, bool)

type TerminalManager added in v0.107.0

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

func NewTerminalManager added in v0.107.0

func NewTerminalManager() *TerminalManager

func (*TerminalManager) CloseAll added in v0.107.0

func (m *TerminalManager) CloseAll()

func (*TerminalManager) Handle added in v0.107.0

func (*TerminalManager) Read added in v0.107.0

func (m *TerminalManager) Read(ctx context.Context, id string, maxBytes int) (string, error)

func (*TerminalManager) Start added in v0.107.0

func (m *TerminalManager) Start(ctx context.Context, command, cwd string) (string, error)

type TerminalRecord added in v0.107.0

type TerminalRecord struct {
	ID             string `json:"id"`
	ProjectPathKey string `json:"project_path_key"`
	CWD            string `json:"cwd"`
	Shell          string `json:"shell"`
	Title          string `json:"title"`
	PID            int    `json:"pid"`
	Cols           uint16 `json:"cols"`
	Rows           uint16 `json:"rows"`
	CreatedAt      int64  `json:"created_at"`
	UpdatedAt      int64  `json:"updated_at"`
	FinishedAt     int64  `json:"finished_at"`
	ExitCode       int    `json:"exit_code"`
	Running        bool   `json:"running"`
	Kind           string `json:"kind"`
}

type TerminalRequest added in v0.107.0

type TerminalRequest struct {
	Action         string `json:"action"`
	ConversationID string `json:"conversation_id"`
	RunID          string `json:"run_id"`
	SessionID      string `json:"session_id"`
	ProjectPathKey string `json:"project_path_key"`
	CWD            string `json:"cwd"`
	Shell          string `json:"shell"`
	Title          string `json:"title"`
	Data           string `json:"data"`
	Cols           uint16 `json:"cols"`
	Rows           uint16 `json:"rows"`
	MaxBytes       int    `json:"max_bytes"`
}

TerminalRequest and TerminalResponse mirror the local Gateway v2 terminal protocol.

type TerminalResponse added in v0.107.0

type TerminalResponse struct {
	Action            string                `json:"action"`
	ConversationID    string                `json:"conversation_id"`
	RunID             string                `json:"run_id"`
	Session           *TerminalRecord       `json:"session,omitempty"`
	Sessions          []TerminalRecord      `json:"sessions,omitempty"`
	Output            []byte                `json:"output,omitempty"`
	Truncated         bool                  `json:"truncated"`
	OutputStartOffset uint64                `json:"output_start_offset"`
	OutputEndOffset   uint64                `json:"output_end_offset"`
	ShellOptions      []TerminalShellOption `json:"shell_options,omitempty"`
	DefaultShell      string                `json:"default_shell,omitempty"`
}

type TerminalShellOption added in v0.107.0

type TerminalShellOption struct {
	ID      string `json:"id"`
	Label   string `json:"label"`
	Command string `json:"command"`
}

type Tool

type Tool struct {
	Def       ai.Tool
	Run       func(ctx context.Context, args json.RawMessage) (string, error)
	NoInherit bool
}

func All

func All() []Tool

func BrowserExec

func BrowserExec() Tool

func ComputerExec

func ComputerExec() Tool

func LiveAgentCatalog added in v0.107.0

func LiveAgentCatalog(provider ...string) []Tool

LiveAgentCatalog creates session-local tools without changing CLI defaults.

func LiveAgentCatalogWithManagers added in v0.107.0

func LiveAgentCatalogWithManagers(provider []string, terminalManager *TerminalManager, processManager *ManagedProcessManager) []Tool

func QuestionTool

func QuestionTool() Tool

type WorkspaceRoot added in v0.107.0

type WorkspaceRoot struct {
	Path   string
	Access string
}

WorkspaceRoot is the backend's authoritative filesystem boundary.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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