AgentForceAgent
AgentForceAgent Class Reference
Section titled “AgentForceAgent Class Reference”AgentForceAgent Main Class Agents
Technical documentation for the AgentForceAgent
class structure and API.
Class Documentation Comment
Section titled “Class Documentation Comment”/** * Represents an AI agent within the AgentForce framework. * This class provides the core functionality for creating and managing AI agents, * including configuration of name, type, AI provider, and model. * * @class AgentForceAgent */
Imports
Section titled “Imports”import { debug, useLLM, serve, systemPrompt, prompt, output, run, execute, saveToFile, getResponse, withTemplate, task,} from "./agent/mod";
import type { AgentConfig, ProviderType, OutputType, AgentForceLogger, ModelConfig,} from "./types";
import { defaultLogger } from "./logger";
Constructor
Section titled “Constructor”constructor(config: AgentConfig)
Parameters:
config: AgentConfig
- Configuration object containing agent initialization settings
Description: Constructs the AgentForceAgent class with the provided configuration. Initializes the agent’s name, tools, skills, and logger from the config object.
Private Properties
Section titled “Private Properties”private name: string;private agentSystemPrompt: string = "You are an AI agent created by AgentForceZone. You can perform various tasks based on the methods provided.";private userPrompt: string = "";private template: string = "";private tools: string[] = [];private skills: string[] = [];private taskList: {description: string, result: string | null}[] = [];private chatHistory: {role: string, content: string}[] = [];private logger: AgentForceLogger;private provider: string = "ollama";private model: string = "gemma3:4b";private modelConfig?: ModelConfig;
Protected Methods
Section titled “Protected Methods”State Getters
Section titled “State Getters”protected getName(): stringprotected getTools(): string[]protected getSkills(): string[]protected getUserPrompt(): stringprotected getSystemPrompt(): stringprotected getTemplate(): stringprotected getModel(): stringprotected getProvider(): stringprotected getModelConfig(): ModelConfig | undefinedprotected getChatHistory(): {role: string, content: string}[]protected getLogger(): AgentForceLoggerprotected getTaskList(): {description: string, result: string | null}[]
State Setters
Section titled “State Setters”protected setUserPrompt(prompt: string): voidprotected setSystemPrompt(prompt: string): voidprotected setTemplate(template: string): voidprotected setModel(model: string): voidprotected setProvider(provider: string): voidprotected setModelConfig(config?: ModelConfig): voidprotected setTaskList(taskList: {description: string, result: string | null}[]): void
Utility Methods
Section titled “Utility Methods”protected pushToChatHistory(role: string, content: string): voidprotected clearTaskList(): voidprotected execute(userPrompt?: string): Promise<string>
Public Methods
Section titled “Public Methods”Chainable Methods
Section titled “Chainable Methods”Returns AgentForceAgent
instance for method chaining:
debug(): AgentForceAgentuseLLM(provider?: ProviderType, model?: string, modelConfig?: ModelConfig): AgentForceAgentsystemPrompt(prompt: string): AgentForceAgentprompt(userPrompt: string): AgentForceAgentwithTemplate(templatePath: string, templateData?: Record<string, unknown>): AgentForceAgenttask(taskDescription: string): AgentForceAgentrun(): Promise<AgentForceAgent>
Execution Methods
Section titled “Execution Methods”Execute the agent and return results (ends the chain):
serve(host?: string, port?: number): Promise<void>output(outputType: OutputType): Promise<string | object>getResponse(): Promise<string>saveToFile(fileName: string): Promise<string>
Method Binding
Section titled “Method Binding”All public methods are bound to their respective implementations from the ./agent/mod
module:
// Chainable methodsdebug: () => AgentForceAgent = debug.bind(this);useLLM: (provider?: ProviderType, model?: string, modelConfig?: ModelConfig) => AgentForceAgent = useLLM.bind(this);systemPrompt: (prompt: string) => AgentForceAgent = systemPrompt.bind(this);prompt: (userPrompt: string) => AgentForceAgent = prompt.bind(this);withTemplate: (templatePath: string, templateData?: Record<string, unknown>) => AgentForceAgent = withTemplate.bind(this);task: (taskDescription: string) => AgentForceAgent = task.bind(this);run: () => Promise<AgentForceAgent> = run.bind(this);
// Execute methodsserve: (host?: string, port?: number) => Promise<void> = serve.bind(this);output: (outputType: OutputType) => Promise<string | object> = output.bind(this);getResponse: () => Promise<string> = getResponse.bind(this);saveToFile: (fileName: string) => Promise<string> = saveToFile.bind(this);