Type Reference
All types are exported from the main entry point:
import type {
AgentConfig,
Message,
LLMProvider,
LLMResponse,
ToolCall,
ToolResult,
ReActOptions,
StepInput,
Tool,
StatsConfig,
StatsTimestamp,
LoggerConfig,
LogLevel,
RetryOptions,
PermissionConfig,
PermissionHandler,
PermissionContext,
ApprovalConfig,
ApprovalHandler,
ApprovalContext,
ShortTermMemory,
LongTermMemory,
} from "llm-layer-engine";Core Types
Message
type Message = {
role: "system" | "user" | "assistant" | (string & {});
content: string;
};The base message shape for all conversations. Compatible with LangChain’s message format.
AgentConfig
interface AgentConfig {
provider: LLMProvider;
model: string;
temperature?: number; // Default: 0.7
}Passed to createAgent, reActLoop, and executeStep. temperature is optional — use getTemperature() to normalize it.
LLMProvider
interface LLMProvider {
name: string;
run(input: {
messages: Message[];
config: AgentConfig;
}): Promise<LLMResponse>;
}The interface your LangChain model wrapper must implement. LLM Layer Engine calls provider.run() on every step.
LLMResponse
interface LLMResponse {
content: string;
toolCalls?: ToolCall[];
raw?: RawLLMResponse;
}What your provider returns. toolCalls triggers tool execution in the loop. raw carries token usage stats.
ToolCall
interface ToolCall {
name: string;
input: Record<string, unknown>;
id?: string;
}Represents a single tool call returned by the LLM inside an LLMResponse.
ToolResult
interface ToolResult {
name: string;
results: any;
error?: string;
}Tool Types
Tool
type Tool = {
name: string;
execute: (input: Record<string, unknown>) => Promise<
Record<string, unknown> | string | number | boolean
>;
};The shape of every tool registered with registerTool or passed to reActLoop.
ReActOptions
type ReActOptions = {
config: AgentConfig;
provider: AgentConfig["provider"];
messages: Message[];
tools?: Tool[];
steps?: number;
maxSteps?: number;
};Options passed to reActLoop().
StepInput
type StepInput = {
provider: LLMProvider;
config: AgentConfig;
tools: Tool[];
conversation: Message[];
};Input to executeStep().
Stats Types
StatsConfig
interface StatsConfig {
tokenUsage: number;
numberOfSteps: number;
toolCalls: number;
executionTime: StatsTimestamp;
durationMs: number;
errors: number;
}StatsTimestamp
interface StatsTimestamp {
startTime: Date;
endTime: Date;
}Logger Types
LogLevel
type LogLevel = "debug" | "info" | "warn" | "error";LoggerConfig
type LoggerConfig = {
enabled?: boolean;
level?: LogLevel;
steps?: boolean;
tools?: boolean;
errors?: boolean;
};Retry Types
RetryOptions
type RetryOptions = {
retries?: number;
delay?: number;
factor?: number;
};Permission Types
PermissionContext
type PermissionContext = {
toolName: string;
userId?: string;
userRole?: string;
metadata?: Record<string, unknown>;
};PermissionHandler
type PermissionHandler = (ctx: PermissionContext) => boolean | Promise<boolean>;PermissionConfig
interface PermissionConfig {
handler?: PermissionHandler;
}Approval Types
ApprovalContext
type ApprovalContext = {
toolName: string;
userId?: string;
input?: unknown;
metadata?: Record<string, unknown>;
};ApprovalHandler
type ApprovalHandler = (ctx: ApprovalContext) => boolean | Promise<boolean>;ApprovalConfig
interface ApprovalConfig {
handler?: ApprovalHandler;
}Memory Types
ShortTermMemory
interface ShortTermMemory {
add(message: Message): void;
addMany(messages: Message[]): void;
getAll(): Message[];
clear(): void;
size(): number;
}LongTermMemory
interface LongTermMemory {
save(userId: string, messages: Message[]): Promise<void>;
load(userId: string): Promise<Message[]>;
search?(query: string): Promise<Message[]>;
}Last updated on