http

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 9 Imported by: ? 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 http provides a generic HTTP/JSON agent bridge, so an agentDecision can be answered by any service that speaks a small, documented envelope — an internal classifier, a model gateway, or a colleague's Python service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bridge

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

Bridge posts agent decisions to an HTTP endpoint.

func New

func New(endpoint string, opts ...Option) *Bridge

New builds an HTTP bridge pointed at endpoint.

func (*Bridge) Invoke

func (b *Bridge) Invoke(ctx context.Context, req agent.Request) (agent.Response, error)

Invoke implements agent.Bridge.

type Option

type Option func(*Bridge)

Option configures a Bridge.

func WithClient

func WithClient(c *http.Client) Option

WithClient supplies the HTTP client. The engine enforces the per-decision latency budget through context cancellation, so a client timeout here is a belt-and-braces upper bound rather than the primary control.

func WithHeader

func WithHeader(k, v string) Option

WithHeader sets a header on every request — an API key, a tenant ID.

type RequestBody

type RequestBody struct {
	DecisionID   string `json:"decision_id"`
	DecisionName string `json:"decision_name,omitempty"`
	Prompt       string `json:"prompt"`
	// Inputs is agent.Request.Inputs as-is: numbers as JSON numbers, every
	// temporal and duration as its FEEL lexical string ("2024-03-05",
	// "2024-03-05T10:00:00", "P1DT2H").
	Inputs      map[string]any `json:"inputs,omitempty"`
	OutputType  TypeSpec       `json:"output_type"`
	SessionHint string         `json:"session_hint,omitempty"`
	Attempt     int            `json:"attempt"`
}

RequestBody is what the bridge POSTs.

type ResponseBody

type ResponseBody struct {
	Value        any    `json:"value"`
	SessionRef   string `json:"session_ref,omitempty"`
	InputTokens  int    `json:"input_tokens,omitempty"`
	OutputTokens int    `json:"output_tokens,omitempty"`
	Model        string `json:"model,omitempty"`
	// Error lets a service report a semantic failure with a 200, which some
	// gateways prefer; a non-empty Error is treated exactly like a transport
	// failure and therefore participates in retry and the failure policy.
	Error string `json:"error,omitempty"`
}

ResponseBody is what the bridge expects back. `value` is the only required field; everything else enriches the trace.

type TypeSpec

type TypeSpec struct {
	TypeRef     string              `json:"type_ref,omitempty"`
	Enumeration []string            `json:"enumeration,omitempty"`
	Collection  bool                `json:"collection,omitempty"`
	Components  map[string]TypeSpec `json:"components,omitempty"`
}

TypeSpec is the JSON projection of the declared output type, so the remote service can build a matching structured-output schema.

Jump to

Keyboard shortcuts

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