Azad CLI Reference¶
The Azad CLI is a TypeScript-based command-line interface and client library for interacting with the Azad autonomous coding agent. This section provides documentation for the TypeScript implementation, including the client, environment, and type definitions.
Overview¶
The Azad CLI consists of several key components:
- TypeScript Client: A high-level client that facilitates communication with the Azad agent through WebSocket connections
- Local Environment: Manages tool registration, execution, and provides a bridge between tools and the client
- Type Definitions: Comprehensive TypeScript type definitions for messages, events, and interfaces
- Command-Line Interface: A React-based CLI using Ink for interactive terminal UI
Documentation Links¶
The CLI documentation is organized into several sections:
- Client Documentation - Detailed documentation for the AzadClient
- Environment Documentation - Documentation for the LocalEnvironment
- Tool Creation Guide - Guide for creating custom tools
CLI Architecture¶
The Azad CLI architecture consists of several key components:
┌─────────────┐ ┌────────────────┐ ┌───────────────┐
│ AzadClient │◄────►│ WebSocketClient│◄────►│ Remote Server │
└──────┬──────┘ └────────────────┘ └───────────────┘
│
▼
┌──────────────┐ ┌───────────┐
│ Environment │◄───►│ Tools │
└──────────────┘ └───────────┘
Accessing the CLI¶
The Azad CLI is part of the main Azad repository and not distributed as a separate package. To use the CLI:
- Clone the Azad repository:
- Navigate to the CLI directory:
- Install dependencies:
- Build the CLI:
- Run the CLI:
Basic Usage¶
import { AzadClient } from './server/azad-client';
import { executeCommandTool } from './environment/tools/definitions/execute-command';
// Initialize the client with the current working directory
const client = new AzadClient(process.cwd());
// Execute a task
await client.executeTask({
model: {
id: 'gpt-4',
apiKey: 'your-api-key',
},
tools: [executeCommandTool],
task: 'List all files in the current directory',
// Tool approval callback
onToolApproval: async (toolName, toolCallId, args) => {
return { approved: true, images: [], feedback: null };
},
});
// Disconnect when done
await client.disconnect();
TypeScript Types¶
The Azad CLI includes comprehensive TypeScript type definitions:
WebSocketClient- Low-level WebSocket clientAzadClient- High-level Azad clientEnvironment- Interface for tool execution environmentTool- Interface for tool implementationsMessage- Types for various message formatsAINetworkEvent- Types for network events
See the implementation files in the azad_cli/src/azad-ts-client directory for detailed type definitions.