assistant

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 11 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

Overview

Package assistant answers questions about the connected broker with Claude, using read-only broker queries as tools. It never changes broker state: changes are suggested as mqx commands for the user to run.

Index

Constants

View Source
const DefaultModel = "claude-opus-5-5"

DefaultModel is used when the config names none.

Variables

This section is empty.

Functions

func Invoke added in v0.5.0

func Invoke(ctx context.Context, tools []Tool, name string, raw []byte) (string, error)

Invoke runs the tool called name with JSON arguments raw and returns its result as JSON. Errors are meant for the model: they name the bad input or the broker failure so it can retry with something else. Input mistakes are *InputError.

Types

type Call

type Call struct {
	Tool string
	Args string // compact JSON
	Err  string
}

Call is one tool call the model made.

type Context

type Context struct {
	Name     string
	Broker   string // "kafka", "rabbitmq", ...
	ReadOnly bool
}

Context describes the connection the assistant works on.

type Input

type Input map[string]any

Input is a tool call's arguments.

func (Input) Int

func (in Input) Int(name string, def int) int

Int returns the integer argument name, def when absent.

func (Input) String

func (in Input) String(name string) string

String returns the string argument name, "" when absent.

type InputError added in v0.5.0

type InputError struct{ Label, Msg string }

InputError is a tool call the model got wrong: Label is the short form the TUI shows, Error the full text sent back to the model.

func (*InputError) Error added in v0.5.0

func (e *InputError) Error() string

type Options

type Options struct {
	// SendPayloads offers peek_messages, which sends message keys, headers
	// and values to the API. Off unless the config enables it.
	SendPayloads bool
}

Options decide which tools a session offers.

type Sender

Sender sends one Messages API request. Client.Send is the real one; tests pass a fake.

func NewSender

func NewSender() Sender

NewSender returns a Sender that calls the Anthropic API. The SDK finds the credentials: ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN or an `ant auth login` profile.

type Session

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

Session is one conversation. It is not safe for concurrent use: the TUI runs one Step at a time.

func NewSession

func NewSession(send Sender, settings Settings, ctx Context, tools []Tool) *Session

NewSession starts a conversation about ctx using tools.

func (*Session) Ask

func (s *Session) Ask(question string)

Ask starts a new question; Step then works on it until a Turn is Done.

func (*Session) Step

func (s *Session) Step(ctx context.Context) (Turn, error)

Step sends the conversation, runs the tools the model asked for and reports what happened. On an error the current question is dropped, so the user can ask again.

type Settings

type Settings struct {
	Model  string
	Effort string // low, medium, high, xhigh or max; "" means medium
}

Settings are the request settings from the config.

type Tool

type Tool struct {
	Name        string
	Description string
	// Params are the JSON Schema properties of the input; Required lists the
	// mandatory ones.
	Params   map[string]any
	Required []string
	// Run executes the call; its result is sent to the model as JSON.
	Run func(ctx context.Context, in Input) (any, error)
}

Tool is one read-only broker query the model may call.

func Tools

func Tools(b broker.Broker, opts Options) []Tool

Tools returns the read-only tools b supports. None of them changes broker state, so the assistant never needs the mutation guard: it can only suggest commands for the user to run.

type Turn

type Turn struct {
	Text  string
	Calls []Call
	// Done means the answer is complete and the next Step needs a new question.
	Done bool
	// Note explains an early stop (token limit, refusal, too many rounds).
	Note string
}

Turn is what one Step produced.

Jump to

Keyboard shortcuts

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