toolset

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 18 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 toolset is what an agent can do with the application's connections, whatever carries the call.

The MCP server offers these tools to an agent outside the window, and the window's own assistant will offer the same ones to a model it calls itself. Neither re-implements an operation. Each adapts these to its caller - how a call arrives, how far it may go, who is asked before anything is destroyed - and everything about the operation itself, from the capability check to the words an answer is given in, is decided here once.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Arguments

func Arguments(input any) json.RawMessage

Arguments is what a write was called with, as an audit log keeps it.

func Canonical

func Canonical(input any) string

Canonical is a call's arguments as an answer to a question is checked against them. The input is a struct, so its fields always marshal in the same order.

func WithCaller

func WithCaller(ctx context.Context, caller Caller) context.Context

WithCaller returns ctx carrying the caller a transport identified.

Types

type Caller

type Caller struct {
	// Confirms is whether the caller can put a question to a person before a
	// destructive call. A tool it cannot use is not one to point it at.
	Confirms bool
}

Caller is who a call comes from, as far as a tool's answer depends on it.

type Confirmable

type Confirmable interface{ Destination() model.DestinationRef }

Confirmable is the input of a tool a person confirms. It names the destination that would be destroyed, which is what the question is about.

type Env

type Env struct {
	Services *app.Services
	// Translate resolves the i18n keys the capability model carries into the
	// language the application is set to. Injected because the translations
	// live with the renderer's, and only the composition root can reach them.
	Translate func(string) string
	// Open resolves the connection a call names. Nil uses only the connections
	// this process already holds, which is what the window needs: a dial from
	// there records no status, and queues the user's own connects behind it.
	// The MCP server dials what its own process has not opened yet.
	Open func(id int) (driver.Conn, error)
	// Allow is how far calls may go on a connection. Nil is read only.
	Allow func(id int) catalog.Blast
	// Offered names the tool that performs each catalogue operation, among the
	// tools the transport registered.
	Offered map[string]string
}

Env is what the tools run against: the application's services, and the choices a transport makes about the connections a call names.

func (*Env) ChangedSince

func (e *Env) ChangedSince(id int, agreed model.ConnectionProfile) error

ChangedSince refuses a write whose connection was pointed elsewhere after the person agreed to it: what they agreed to is the broker they were shown.

func (*Env) Consequence

func (e *Env) Consequence(tool Tool, input any) (string, error)

Consequence is what a write would leave behind on the connection it names, as the connection declares it, for a person approving it to read. A write that could not be made there at all is refused here instead, before anybody is asked about it.

func (*Env) Question

func (e *Env) Question(ctx context.Context, tool Tool, input any) (string, model.ConnectionProfile, error)

* Question is what a destructive call puts to a person, and the connection as * it stands while they read it - what ChangedSince holds the write to once * they have answered. Whatever would be refused anyway is refused here * instead: there is no point in a question whose yes leads nowhere.

type Targeted

type Targeted interface{ Target() int }

Targeted is an input that names the connection it acts on. Every write's is one, so a write is checked and recorded against the connection it reaches.

type Tool

type Tool struct {
	// Name is what a caller calls it by.
	Name string
	// Title is a short name for a person reading a list of them.
	Title       string
	Description string
	// Operation is the catalogue operation it performs. The two tools about
	// the installation itself reach no driver, and have none.
	Operation string
	// Blast is how much one call can do. It comes from the catalogue: two
	// descriptions of the damage a call can do would eventually disagree.
	Blast        catalog.Blast
	InputSchema  *jsonschema.Schema
	OutputSchema *jsonschema.Schema
	// contains filtered or unexported fields
}

Tool is one operation as an agent is offered it.

func All

func All() []Tool

All is every tool, in the order a transport offers them.

func Lookup

func Lookup(name string) (Tool, bool)

Lookup finds a tool by name.

func (Tool) Call

func (t Tool) Call(ctx context.Context, env *Env, arguments json.RawMessage) (any, error)

Call checks arguments as a model sent them and performs the tool.

func (Tool) Check

func (t Tool) Check(arguments json.RawMessage) (any, error)

* Check reads arguments as a model sent them into the tool's input: defaults * applied, then the whole value validated, the way the MCP SDK checks them * before a handler there sees a call. Every input schema is closed, so a * property the input does not declare is refused rather than decoded into * nothing. * * It is separate from running so a caller can look at what a write would do, * and ask a person about it, before anything is done.

func (Tool) Decode

func (t Tool) Decode(arguments json.RawMessage) (any, error)

Decode reads arguments into the tool's input, unchecked: for a transport that has already checked them against InputSchema.

func (Tool) Run

func (t Tool) Run(ctx context.Context, env *Env, input any) (any, error)

Run performs the tool on an input Decode returned.

type Withholding

type Withholding interface{ Logged() any }

Withholding is an input carrying content an audit log does not copy. What Logged returns is kept in its place.

type Written

type Written interface {
	Recorded() (changed, reference string)
}

Written is a write's answer as an audit log keeps it: what changed, and whatever the broker returned to name what was written.

Jump to

Keyboard shortcuts

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