Documentation
¶
Index ¶
- Variables
- func SessionFromContext(ctx context.Context) string
- type AuthManager
- type Client
- type Config
- type OIDCProvider
- type RPCError
- type RPCHandler
- type RPCRequest
- type RPCResponse
- type Server
- func (s *Server) Broadcast(event string, payload interface{})
- func (s *Server) BroadcastToCompanions(event string, payload interface{})
- func (s *Server) BroadcastToSession(sessionKey, event string, payload interface{})
- func (s *Server) HasCompanions() bool
- func (s *Server) OnTurnComplete(cb TurnCallback)
- func (s *Server) RegisterHandler(method string, handler RPCHandler)
- func (s *Server) RequestApproval(ctx context.Context, message string) (approval.ApprovalResponse, error)
- func (s *Server) Router() chi.Router
- func (s *Server) SetAgent(agent *adk.Agent)
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) Start() error
- type TurnCallback
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func SessionFromContext ¶
SessionFromContext extracts the authenticated session key from the request context. Returns empty string if no session is present.
Types ¶
type AuthManager ¶
type AuthManager struct {
// contains filtered or unexported fields
}
AuthManager manages authentication providers
func NewAuthManager ¶
func NewAuthManager(cfg config.AuthConfig, store session.Store) (*AuthManager, error)
NewAuthManager creates a new AuthManager
func (*AuthManager) RegisterRoutes ¶
func (am *AuthManager) RegisterRoutes(r chi.Router)
RegisterRoutes registers auth routes on the router
type Client ¶
type Client struct {
ID string
Type string // "ui" or "companion"
Conn *websocket.Conn
Server *Server
Send chan []byte
SessionKey string
// contains filtered or unexported fields
}
Client represents a connected WebSocket client
type Config ¶
type Config struct {
Host string
Port int
HTTPEnabled bool
WebSocketEnabled bool
AllowedOrigins []string
ApprovalTimeout time.Duration
RequestTimeout time.Duration
}
Config holds gateway server configuration
type OIDCProvider ¶
type OIDCProvider struct {
Name string
Config config.OIDCProviderConfig
OAuthConfig *oauth2.Config
OIDCProvider *oidc.Provider
Verifier *oidc.IDTokenVerifier
}
OIDCProvider handles OIDC authentication for a specific provider
func NewOIDCProvider ¶
func NewOIDCProvider(name string, cfg config.OIDCProviderConfig) (*OIDCProvider, error)
NewOIDCProvider creates a new OIDCProvider
type RPCHandler ¶
type RPCHandler func(client *Client, params json.RawMessage) (interface{}, error)
RPCHandler is a function that handles an RPC method. The client parameter provides the calling client's context (session, type, etc).
type RPCRequest ¶
type RPCRequest struct {
ID string `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
RPCRequest represents an incoming RPC request
type RPCResponse ¶
type RPCResponse struct {
ID string `json:"id"`
Result interface{} `json:"result,omitempty"`
Error *RPCError `json:"error,omitempty"`
}
RPCResponse represents an RPC response
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the gateway server
func New ¶
func New(cfg Config, agent *adk.Agent, provider *security.RPCProvider, store session.Store, auth *AuthManager) *Server
New creates a new gateway server
func (*Server) BroadcastToCompanions ¶
BroadcastToCompanions sends a message to all connected companions
func (*Server) BroadcastToSession ¶
BroadcastToSession sends an event to all UI clients belonging to a specific session. When the session key is empty (no auth), it broadcasts to all UI clients.
func (*Server) HasCompanions ¶
HasCompanions returns true if at least one companion client is connected.
func (*Server) OnTurnComplete ¶
func (s *Server) OnTurnComplete(cb TurnCallback)
OnTurnComplete registers a callback that fires after each agent turn.
func (*Server) RegisterHandler ¶
func (s *Server) RegisterHandler(method string, handler RPCHandler)
RegisterHandler registers an RPC method handler
func (*Server) RequestApproval ¶
func (s *Server) RequestApproval(ctx context.Context, message string) (approval.ApprovalResponse, error)
RequestApproval broadcasts an approval request to companions and waits for response.
type TurnCallback ¶
type TurnCallback func(sessionKey string)
TurnCallback is called after each agent turn completes (for buffer triggers, etc).