AgentForceServer
AgentForceServer Class Reference
Section titled “AgentForceServer Class Reference”AgentForceServer Server Class HTTP Server
Technical documentation for the AgentForceServer
class structure and API.
Class Documentation Comment
Section titled “Class Documentation Comment”/** * Represents a server instance within the AgentForce framework. * This class provides the core functionality for creating and managing servers, * including configuration of name and logging. * * @class AgentForceServer */
Imports
Section titled “Imports”import { serve, addRouteAgent, addRoute, addFormTrigger, addWorkflowTrigger, useOpenAICompatibleRouting, useOllamaCompatibleRouting, type RouteAgent, type StaticRoute, type RouteAgentSchema,} from "./server/mod";
import type { AgentForceAgent } from "./agent";import type { ServerConfig, AgentForceLogger } from "./types";import { defaultLogger } from "./logger";
Constructor
Section titled “Constructor”constructor(config: ServerConfig)
Parameters:
config: ServerConfig
- Configuration object containing server initialization settings
Description: Constructs the AgentForceServer class with the provided configuration. Initializes the server’s name and logger from the config object.
Private Properties
Section titled “Private Properties”private name: string;private serverLogger: AgentForceLogger;private routeAgents: RouteAgent[] = [];private staticRoutes: StaticRoute[] = [];
Protected Methods
Section titled “Protected Methods”None - All methods are public in this class.
Public Methods
Section titled “Public Methods”State Getters
Section titled “State Getters”public getName(): stringpublic getLogger(): AgentForceLoggerpublic getRouteAgents(): RouteAgent[]public getStaticRoutes(): StaticRoute[]
State Setters
Section titled “State Setters”public addToRouteAgents(routeAgent: RouteAgent): voidpublic addToStaticRoutes(staticRoute: StaticRoute): void
Chainable Methods
Section titled “Chainable Methods”Returns AgentForceServer
instance for method chaining:
addRouteAgent(method: string, path: string, agent: AgentForceAgent, schema?: RouteAgentSchema): AgentForceServeraddRoute(method: string, path: string, responseData: any): AgentForceServeraddFormTrigger(formName: string, htmlFilePath: string, agent: AgentForceAgent, schema?: RouteAgentSchema): AgentForceServeraddWorkflowTrigger(method: string, path: string, workflowFilePath: string): AgentForceServeruseOpenAICompatibleRouting(agent: AgentForceAgent): AgentForceServeruseOllamaCompatibleRouting(agent: AgentForceAgent): AgentForceServer
Execution Methods
Section titled “Execution Methods”Execute the server and return results (ends the chain):
serve(host?: string, port?: number): Promise<void>
Method Binding
Section titled “Method Binding”All public methods are bound to their respective implementations from the ./server/mod
module:
// Chainable methodsaddRouteAgent: (method: string, path: string, agent: AgentForceAgent, schema?: RouteAgentSchema) => AgentForceServer = addRouteAgent.bind(this);addRoute: (method: string, path: string, responseData: any) => AgentForceServer = addRoute.bind(this);addFormTrigger: (formName: string, htmlFilePath: string, agent: AgentForceAgent, schema?: RouteAgentSchema) => AgentForceServer = addFormTrigger.bind(this);addWorkflowTrigger: (method: string, path: string, workflowFilePath: string) => AgentForceServer = addWorkflowTrigger.bind(this);useOpenAICompatibleRouting: (agent: AgentForceAgent) => AgentForceServer = useOpenAICompatibleRouting.bind(this);useOllamaCompatibleRouting: (agent: AgentForceAgent) => AgentForceServer = useOllamaCompatibleRouting.bind(this);
// Terminal/Non-chainable methodsserve: (host?: string, port?: number) => Promise<void> = serve.bind(this);