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
- func WithAgentFinder(finder agent.Finder) ServerOption
- func WithApprovalService(svc approval.Service) ServerOption
- func WithAuthConfig(cfg *auth.Config) ServerOption
- func WithChatService(c *chat.Service) ServerOption
- func WithCore(c *corellm.Service) ServerOption
- func WithDAO(dao *datly.Service) ServerOption
- func WithDefaults(d *execcfg.Defaults) ServerOption
- func WithFileService(fs *fservice.Service) ServerOption
- func WithInvoker(inv invk.Invoker) ServerOption
- func WithMCPRouter(r elicrouter.ElicitationRouter) ServerOption
- func WithPolicies(tp *tool.Policy) 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 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 WithAgentFinder ¶ added in v0.2.1
func WithAgentFinder(finder agent.Finder) ServerOption
WithAgentFinder returns with agent finder
func WithApprovalService ¶
func WithApprovalService(svc approval.Service) ServerOption
WithApprovalService injects an approval service used by the HTTP callback handler to forward Accept/Decline decisions. Optional; when nil the server falls back to chat-only status updates.
func WithAuthConfig ¶ added in v0.2.2
func WithAuthConfig(cfg *auth.Config) ServerOption
WithAuthConfig passes auth configuration for BFF token refresh.
func WithChatService ¶ added in v0.2.1
func WithChatService(c *chat.Service) ServerOption
WithChatService injects a preconfigured chat service. When provided, NewServer will not attempt to auto-initialize chat from env.
func WithCore ¶ added in v0.2.1
func WithCore(c *corellm.Service) ServerOption
WithCore attaches the LLM core service so Chat can call core.Generate directly.
func WithDAO ¶ added in v0.2.2
func WithDAO(dao *datly.Service) ServerOption
WithDAO passes a shared datly service so the server can read user ids.
func WithDefaults ¶ added in v0.2.1
func WithDefaults(d *execcfg.Defaults) ServerOption
WithDefaults passes summary defaults (model/prompt/lastN) to chat service.
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 WithInvoker ¶ added in v0.2.1
func WithInvoker(inv invk.Invoker) ServerOption
WithInvoker attaches a tool invoker used by transcript extensions with source=invoke.
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) ServerOption
WithPolicies injects default tool policies so that API requests inherit the configured mode (auto/ask/deny).