serverless

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package serverless exposes AGNT5 workflows as signed HTTP endpoints without running a persistent worker process.

Index

Constants

View Source
const (
	ProtocolVersion  = "workerless.v1"
	SignatureVersion = "workerless-hmac-sha256.v1"
	ManifestPath     = "/.well-known/agnt5"
	InvokePath       = "/agnt5/invoke"
)

Variables

This section is empty.

Functions

func RegisterAgent

func RegisterAgent(h *Handler, agent Agent) error

func RegisterFunction

func RegisterFunction[In any, Out any](h *Handler, name string, fn func(*Context, In) (Out, error)) error

func RegisterTool

func RegisterTool(h *Handler, tool Tool) error

func RegisterWorkflow

func RegisterWorkflow[In any, Out any](h *Handler, name string, fn func(*Context, In) (Out, error)) error

func Step

func Step[T any](ctx *Context, name string, fn func(context.Context) (T, error)) (T, error)

func WaitForSignal

func WaitForSignal[T any](ctx *Context, signalName, waitingStep string) (T, error)

Types

type Agent

type Agent struct {
	Name        string
	Description string
	Run         func(*Context, AgentInput) (AgentResult, error)
}

type AgentInput

type AgentInput struct {
	Message   string    `json:"message,omitempty"`
	Prompt    string    `json:"prompt,omitempty"`
	Input     string    `json:"input,omitempty"`
	SessionID string    `json:"session_id,omitempty"`
	History   []Message `json:"history,omitempty"`
}

type AgentResult

type AgentResult struct {
	Output   string    `json:"output"`
	Messages []Message `json:"messages,omitempty"`
}

type AgentSessionCheckpoint

type AgentSessionCheckpoint struct {
	Messages    []Message `json:"messages"`
	UpdatedAtMS int64     `json:"updated_at_ms,omitempty"`
}

type Context

type Context struct {
	context.Context
	RunID         string
	Attempt       int
	ComponentName string
	Metadata      map[string]string
	// contains filtered or unexported fields
}

func (*Context) Emit

func (c *Context) Emit(event Event)

func (*Context) Sleep

func (c *Context) Sleep(duration time.Duration, name string) error

func (*Context) WaitForUser

func (c *Context) WaitForUser(input UserInput) (string, error)

func (*Context) YieldIfNeeded

func (c *Context) YieldIfNeeded() error

type Event

type Event struct {
	EventType string            `json:"event_type"`
	Data      any               `json:"data,omitempty"`
	Metadata  map[string]string `json:"metadata,omitempty"`
	Timestamp int64             `json:"timestamp_ns,omitempty"`
}

type Handler

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

func New

func New(opts Options) *Handler

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type Options

type Options struct {
	ServiceName    string
	ServiceVersion string
	SigningSecret  func(*http.Request) string
	Enabled        func(*http.Request) bool
	HTTPClient     *http.Client
}

type OutputRef

type OutputRef struct {
	Kind        string `json:"kind"`
	Ref         string `json:"ref"`
	SizeBytes   int64  `json:"size_bytes"`
	SHA256      string `json:"sha256"`
	ContentType string `json:"content_type"`
}

type OutputUpload

type OutputUpload struct {
	Kind           string `json:"kind"`
	URL            string `json:"url"`
	Method         string `json:"method"`
	Ref            string `json:"ref"`
	ThresholdBytes int64  `json:"threshold_bytes"`
	MaxBytes       int64  `json:"max_bytes"`
	ContentType    string `json:"content_type"`
	ExpiresAtMS    int64  `json:"expires_at_ms"`
}

type PayloadRef

type PayloadRef struct {
	Kind        string `json:"kind"`
	URL         string `json:"url"`
	Method      string `json:"method"`
	SizeBytes   int64  `json:"size_bytes"`
	SHA256      string `json:"sha256"`
	ContentType string `json:"content_type"`
	ExpiresAtMS int64  `json:"expires_at_ms"`
}

type Suspension

type Suspension struct {
	Reason      string
	ReadyAtMS   int64
	TimerKey    string
	SignalName  string
	WaitingStep string
	PauseIndex  int
	StepName    string
	Question    string
	InputType   string
	Options     []UserInputOption
	AllowCustom bool
	Skippable   bool
}

func (*Suspension) Error

func (s *Suspension) Error() string

type Tool

type Tool struct {
	Name        string
	Description string
	Schema      map[string]any
	Handler     func(context.Context, map[string]any) (any, error)
}

type UserInput

type UserInput struct {
	Question    string
	Type        string
	Options     []UserInputOption
	AllowCustom bool
	Skippable   bool
}

type UserInputOption

type UserInputOption struct {
	ID          string `json:"id"`
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
}

Jump to

Keyboard shortcuts

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