Documentation
¶
Index ¶
- func ListenAndServe(addr string, mgr *conversation.Manager) error
- func NewServer(mgr *conversation.Manager, opts ...ServerOption) http.Handler
- func StartApprovalBridge(ctx context.Context, exec *execsvc.Service, mgr *conversation.Manager)
- func WithCORS(next http.Handler) http.Handler
- type Server
- type ServerOption
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 ¶
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 ¶
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 WithFileService ¶ added in v0.2.0
func WithFileService(fs *fservice.Service) ServerOption
WithFileService injects the Forge file service so chat service can reuse the same staging and storage resolution for reading uploaded attachments.
func WithMCPRouter ¶ added in v0.2.0
func WithMCPRouter(r elicrouter.ElicitationRouter) ServerOption
WithMCPRouter attaches an elicitation router to route MCP prompts back to the correct conversation.
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).