tool

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package tool defines Alaska's agent tools — the capabilities the model can invoke from inside a chat turn (read/write/edit files, run shell commands).

Each Tool has a JSON schema describing its arguments (sent to the model so it knows what to call) and an Execute method the agent loop calls after permission is granted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BashExec

type BashExec struct{}

BashExec — run a shell command and return its combined stdout+stderr.

func (*BashExec) Description

func (*BashExec) Description() string

func (*BashExec) Execute

func (t *BashExec) Execute(ctx context.Context, argsJSON string) (Result, error)

func (*BashExec) InputSchema

func (*BashExec) InputSchema() json.RawMessage

func (*BashExec) Name

func (*BashExec) Name() string

type Call

type Call struct {
	ID       string
	Name     string
	ArgsJSON string
}

Call is a single tool invocation produced by the model.

type EditFile

type EditFile struct{}

EditFile — replace a unique substring in a file. Refuses if old_string isn't unique so accidental multi-match replacements don't happen.

func (*EditFile) Description

func (*EditFile) Description() string

func (*EditFile) Execute

func (t *EditFile) Execute(_ context.Context, argsJSON string) (Result, error)

func (*EditFile) InputSchema

func (*EditFile) InputSchema() json.RawMessage

func (*EditFile) Name

func (*EditFile) Name() string

type ReadFile

type ReadFile struct{}

ReadFile — read a UTF-8 text file, returns contents up to a line limit.

func (*ReadFile) Description

func (*ReadFile) Description() string

func (*ReadFile) Execute

func (t *ReadFile) Execute(_ context.Context, argsJSON string) (Result, error)

func (*ReadFile) InputSchema

func (*ReadFile) InputSchema() json.RawMessage

func (*ReadFile) Name

func (*ReadFile) Name() string

type Registry

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

Registry indexes tools by name for dispatch.

func Default

func Default() *Registry

Default returns the tool set Alaska ships with.

func NewRegistry

func NewRegistry(tools ...Tool) *Registry

func (*Registry) All

func (r *Registry) All() []Tool

func (*Registry) Get

func (r *Registry) Get(name string) (Tool, bool)

func (*Registry) Names

func (r *Registry) Names() []string

type Result

type Result struct {
	Content string // full output sent back to the model
	Preview string // short human-readable summary for the REPL transcript
	IsError bool
}

Result carries the payload an executor returns to the model. LongText is what's shown in the transcript (usually a truncated preview); Content is what's actually fed back to the model in a tool_result message.

type Tool

type Tool interface {
	Name() string
	Description() string
	InputSchema() json.RawMessage
	Execute(ctx context.Context, argsJSON string) (Result, error)
}

Tool is the contract every Alaska tool implements.

type WriteFile

type WriteFile struct{}

WriteFile — create or overwrite a file. Parent dirs are created.

func (*WriteFile) Description

func (*WriteFile) Description() string

func (*WriteFile) Execute

func (t *WriteFile) Execute(_ context.Context, argsJSON string) (Result, error)

func (*WriteFile) InputSchema

func (*WriteFile) InputSchema() json.RawMessage

func (*WriteFile) Name

func (*WriteFile) Name() string

Jump to

Keyboard shortcuts

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