http

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(addr string, mgr *conversation.Manager) error

ListenAndServe Simple helper to start the server (blocks).

func NewServer

func NewServer(mgr *conversation.Manager, opts ...ServerOption) http.Handler

NewServer returns an http.Handler with routes bound.

func StartApprovalBridge

func StartApprovalBridge(ctx context.Context, exec *execsvc.Service, mgr *conversation.Manager)

startApprovalBridge launches a background goroutine that converts Fluxor approval events into chat messages (role=="policyapproval") and vice versa. It mirrors the behaviour of elicitation and user-interaction bridging so that web users can approve or reject tool executions through the existing chat UI. StartApprovalBridge launches the bridge. It is exported so that higher-level adapters (e.g. the HTTP router) can hook it up during initialisation.

func WithCORS

func WithCORS(next http.Handler) http.Handler

WithCORS is a lightweight middleware that adds permissive CORS headers to each request and handles CORS pre-flight (OPTIONS) requests automatically.

The intent is to make the agently HTTP API consumable from browser based front-ends without requiring an additional proxy. The policy is intentionally very permissive – it allows any origin, common HTTP methods and standard headers. If stricter rules are required the middleware can be expanded to accept a configuration struct but for now the simple default is sufficient.

Types

type Server

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

Server wraps a conversation manager and exposes minimal REST endpoints:

POST /v1/conversations                 -> {"id": "..."}
POST /v1/conversations/{id}/messages         -> accept user message, returns {"id": "..."} (202 Accepted)
GET  /v1/conversations/{id}/messages         -> full history
GET  /v1/conversations/{id}/messages/{msgID} -> single message by ID

The server is designed to be simple and lightweight, suitable for quick

type ServerOption

type ServerOption func(*Server)

ServerOption customises HTTP server behaviour.

func WithApprovalService

func WithApprovalService(svc approval.Service) ServerOption

WithApprovalService injects the Fluxor approval service so that the HTTP callback handler can forward Accept/Decline decisions to the workflow engine. Supplying the service is optional — when nil the server falls back to chat-only status updates.

func WithExecutionStore

func WithExecutionStore(ts *memory.ExecutionStore) ServerOption

WithExecutionStore attaches an in-memory ExecutionTrace store so that GET /v1/api/conversations/{id}/tool-trace can return audit information.

func WithPolicies

func WithPolicies(tp *tool.Policy, fp *fluxpol.Policy) ServerOption

WithPolicies injects default tool & fluxor policies so that API requests inherit the configured mode (auto/ask/deny).

type UsageResponse

type UsageResponse struct {
	Status string         `json:"status"`
	Data   []usagePayload `json:"data"`
}

UsageResponse represents the full JSON body returned by GET /v1/api/conversations/{id}/usage after the standard API envelope encoding. It mirrors the {status, data:[usagePayload]} structure so that callers can marshal/unmarshal strongly typed objects instead of working with generic maps.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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