api

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 44 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 api serves the HTTP API other programs reach the agent through: the requests an OpenAI client makes, answered by the agent with its tools, the sessions and the runs of each profile, and the routes plugins bring, such as those of the scheduled jobs. Its routes are served by icebath server beside the services, each profile under a key of its own

Index

Constants

View Source
const Source = "api_server"

Surface of the runs and the sessions the API starts

Variables

This section is empty.

Functions

func Decode

func Decode(w http.ResponseWriter, r *http.Request, into any) error

Reads the JSON a request carries into the value, at most as many bytes as a request may be; what it failed for is answered in the shape an OpenAI client reads

func Flag

func Flag(value any, otherwise bool) bool

A flag of a request that clients send as true, as a number or as a word

func Write

func Write(w http.ResponseWriter, status int, value any)

Writes the value as the JSON answer of the status

Types

type API

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

The HTTP API of the profiles of this icebath

func New

func New(cfg *config.Config, host *runner.Runner, stores *sessions.Registry, providers *provider.Registry, sandboxes *terminal.Terminal,
	toolset *tools.Tools, skillset *skills.Registry, apps *gateway.Gateway) *API

func (*API) Listing

func (a *API) Listing(providers Providers)

Has the API tell programs of the providers of a profile and the models each offers what the listing tells, such as the service of the providers tells the app

func (*API) Mount

func (a *API) Mount(mux *http.ServeMux, keyed func(http.Handler) http.Handler)

Mounts the routes of the API on the mux: each as it is for the profile the server runs on, and under /p/<profile> for any other. Keyed wraps a handler so that it answers only a request that carries the key of its profile

func (*API) Register

func (a *API) Register(registrant Registrant)

Adds a registrant; a registry nested in the host reaches it through Host

func (*API) Sources

func (a *API) Sources() []runner.Source

The API is a source of runs: every request the agent answers is one

func (*API) TakeUp

What becomes of a run of the API an icebath left cut off, as icebath stops or as one that ended is found: it is told as cut off and not run again, as alpha tells a run its shutdown interrupted, the program that started it being the one that knows whether to start it again

type Agent

type Agent interface {
	// Answers the approval prompt of the id with one of the choices it takes, deny among them
	Approve(ctx context.Context, session, id, choice string) error
	// Answers one question of the set the agent asked: the choices picked or the text typed
	Answer(ctx context.Context, session, set, question string, values []string) error
	// Has the reply being written take the guidance into account
	Steer(ctx context.Context, session, text string) error
	// The provider and the model the agent of the profile answers with while nothing names another, as the settings write them, every
	// ${NAME} kept: what a program is told of them
	Main(cfg *config.Config) (provider, model string)
	// Holds the session to the model of the provider for every later answer in it, thinking as hard and answering as fast as the hold
	// says where it says so. With neither a provider nor a model it lets go of all of it, so the model of the profile answers in the
	// session again
	Hold(ctx context.Context, session string, to Hold) error
	// What the session is held to, nothing for one that takes the model of the profile as the profile has it
	Held(session *sessionsv1.Session) Hold
}

What answers the prompts of a run that goes on and takes guidance for it, the agent. The registrant that runs sessions says so by having this too

type Apps

type Apps interface {
	Platforms(cfg *config.Config) []gateway.Platform
	Connection(profile, name string) (gateway.Connection, error)
	Statuses(profile string) []gateway.Status
}

The chat apps of the profiles, as far as the API tells how they stand and hands them what they are posted: the host of the chat apps

type Handler

type Handler func(w http.ResponseWriter, r *http.Request, cfg *config.Config) error

What answers one request, for the profile the request names. What it returns it failed for, which is answered in the shape an OpenAI client reads

type Hold

type Hold struct {
	Provider, Model, Effort, Speed string
}

What a session is held to for every answer in it: the model of a provider, how hard it thinks and how fast it answers. Empty for what the session takes from the profile

type Providers

type Providers interface {
	List(ctx context.Context, request *providerv1.ListRequest) (*providerv1.ListResponse, error)
	Models(ctx context.Context, request *providerv1.ModelsRequest) (*providerv1.ModelsResponse, error)
}

What lists the providers of a profile and the models each offers, as the model picker of the app reads them: the service of the providers, which Listing names

type Registrant

type Registrant interface {
	// Routes the registrant serves beside those of the API, none for one that only brings an ability, such as the agent
	Routes() []Route
}

type Registry

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

func (*Registry) Host

func (r *Registry) Host() *API

Host the registry is nested in, through which plugins reach what the API keeps

func (*Registry) Register

func (r *Registry) Register(registrant Registrant)

func (*Registry) Routes

func (r *Registry) Routes() []Route

Every route the registrants serve, in the order they were registered

type Route

type Route struct {
	// What it is called in what the API tells of itself, such as run_status
	Name         string
	Method, Path string
	// Answers a request for the profile the request names
	Handle Handler
	// It answers anyone, with or without the key
	Open bool
}

One thing the API serves, by how it is asked for and where

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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