API Reference
Complete API documentation for CoderClaw SDK and CoderClawLink services.
Agent Class
The main class for creating and managing autonomous agents.
Constructor
new Agent(config: AgentConfig) Parameters:
name(string) - Unique agent identifiermodel(string) - LLM model to useinstructions(string) - System prompttools(Tool[]) - Available tools/functionsmemory(MemoryConfig) - Memory configuration
Methods
run(task: Task): Promise<Result>
Execute a task with the agent.
const result = await agent.run({
task: 'Analyze this code',
input: codeString,
timeout: 30000
}); addTool(tool: Tool): void
Add a new tool/function to the agent's capabilities.
setInstructions(instructions: string): void
Update agent's system instructions.
getState(): AgentState
Get current agent state and metrics.
SubAgent Class
Create and manage sub-agents for parallel processing.
Constructor
new SubAgent(config: SubAgentConfig) Methods
spawn(count: number): Promise<SubAgentInstance[]>
Create multiple sub-agent instances.
dispatch(task: Task): Promise<Result>
Dispatch a task to available sub-agents.
waitAll(): Promise<void>
Wait for all sub-agents to complete their tasks.
CoderClawLink API
REST API for orchestrating agents through CoderClawLink mesh.
Endpoints
POST /api/agents
Create a new agent.
GET /api/agents/:id
Get agent details and status.
POST /api/agents/:id/tasks
Submit a task to an agent.
GET /api/tasks/:taskId
Get task status and results.
GET /api/mesh/status
Get mesh network status and connected agents.
Type Definitions
AgentConfig
interface AgentConfig {
name: string;
model: string;
instructions: string;
tools?: Tool[];
memory?: MemoryConfig;
timeout?: number;
} Task
interface Task {
task: string;
input?: any;
timeout?: number;
priority?: 'low' | 'normal' | 'high';
} Result
interface Result {
success: boolean;
output: any;
error?: string;
executionTime: number;
tokens?: {
input: number;
output: number;
};
}