host

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 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 host is the host's broker as the Slack plugin calls it, in the plugin's own types: the items ledger, the agent and the profile layer.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnfit is an answer that is not JSON fitting the schema.
	ErrUnfit = src.ErrUnfit
	// ErrOverBudget is a call that ran over its cost cap.
	ErrOverBudget = errors.New("the call ran over its budget")
	// ErrUnavailable is an agent or a host that cannot answer now.
	ErrUnavailable = src.ErrUnavailable
)

Functions

func AnchorOf

func AnchorOf(a src.Anchor) unit.Anchor

func Category

func Category(i items.Initial) string

Category is the task category of a proposed first state.

func ItemOf

func ItemOf(w src.Item) items.Item

ItemOf is the item the protocol carries.

func OpOf

func OpOf(w src.ItemOp) items.Op

OpOf is the op the protocol carries.

func PersonOf

func PersonOf(p src.Person) items.Person

func WireAnchor

func WireAnchor(a unit.Anchor) src.Anchor

func WireItem

func WireItem(it items.Item) src.Item

WireItem is it as the protocol carries it.

func WireOp

func WireOp(o items.Op) src.ItemOp

WireOp is o as the protocol carries it. A link op's To with no provider is an address the host resolves with every plugin's codec.

func WirePeople

func WirePeople(ps []items.Person) []src.Person

func WirePerson

func WirePerson(p items.Person) src.Person

Types

type Answer

type Answer struct {
	JSON  []byte
	Model string
	// CostUSD is nil when the agent did not report it.
	CostUSD  *float64
	Duration time.Duration
	Tokens   int64
}

Answer is the agent's answer and what it cost.

type Ask

type Ask struct {
	Tier   Tier
	Prompt string
	// Schema is the JSON schema the answer matches.
	Schema string
	// MaxCostUSD caps the call; 0 leaves it to the agent.
	MaxCostUSD float64
	// MeterScope is the host's meter scope the call runs under.
	MeterScope string
}

Ask is a prompt for the host's agent.

type Asker

type Asker interface {
	Ask(ctx context.Context, a Ask) (Answer, error)
}

Asker answers headless calls.

type Broker

type Broker struct{ Host src.Host }

Broker is the host's broker, typed in the plugin's words. Its zero interfaces answer ErrUnsupported.

func (Broker) All

func (b Broker) All(ctx context.Context) (map[unit.Unit][]items.Item, error)

All are the items of every unit of the plugin's, by unit.

func (Broker) Apply

func (b Broker) Apply(ctx context.Context, _ items.Provenance, ops []items.Op) (Result, error)

Apply applies ops to the host's ledger; the host records them as the plugin's, of provenance prov.

func (Broker) Ask

func (b Broker) Ask(ctx context.Context, a Ask) (Answer, error)

Ask asks the host's agent; a call over its cost cap fails with ErrOverBudget, which the host says as ResourceExhausted.

func (Broker) Items

func (b Broker) Items(ctx context.Context, u unit.Unit) ([]items.Item, error)

Items are u's items in the host's ledger.

func (Broker) Load

func (b Broker) Load(ctx context.Context, units []unit.Unit) (map[unit.Unit][]items.Item, error)

Load are the items of units, by unit.

func (Broker) Open

func (b Broker) Open(ctx context.Context, units []unit.Unit) (map[unit.Unit][]items.Item, error)

Open are the open items of the plugin's units, by unit; no units reads every unit's.

func (Broker) Profile

func (b Broker) Profile(ctx context.Context, path string) ([]byte, error)

Profile reads path in the plugin's profile layer.

type Refused

type Refused struct {
	Op     items.Op
	Reason string
}

Refused is an op the ledger refused, and why.

type Result

type Result struct {
	Refused []Refused
}

Result is what an Apply refused.

type Tier

type Tier string

Tier names a model tier the host's agent maps to one of its models.

const (
	// TierFast is the cheapest model, for short mechanical calls.
	TierFast Tier = "fast"
	// TierBalanced is the everyday workhorse.
	TierBalanced Tier = "balanced"
	// TierFrontier is the most capable model.
	TierFrontier Tier = "frontier"
)

func ParseTier

func ParseTier(s string) (Tier, error)

Directories

Path Synopsis
Package hosttest is an in-memory host broker for the Slack plugin's tests: it records what the plugin reports, proposes and writes, applies item ops with the host ledger's rules, and answers asks from a script.
Package hosttest is an in-memory host broker for the Slack plugin's tests: it records what the plugin reports, proposes and writes, applies item ops with the host ledger's rules, and answers asks from a script.

Jump to

Keyboard shortcuts

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