Skip to content

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:

  1. TypeScript Client: A high-level client that facilitates communication with the Azad agent through WebSocket connections
  2. Local Environment: Manages tool registration, execution, and provides a bridge between tools and the client
  3. Type Definitions: Comprehensive TypeScript type definitions for messages, events, and interfaces
  4. Command-Line Interface: A React-based CLI using Ink for interactive terminal UI

The CLI documentation is organized into several sections:

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:

  1. Clone the Azad repository:
git clone https://github.com/kodu-ai/azad.git
cd azad
  1. Navigate to the CLI directory:
cd azad_cli
  1. Install dependencies:
npm install
# or
yarn install
# or
pnpm install
  1. Build the CLI:
npm run build
# or
yarn build
# or
pnpm build
  1. Run the CLI:
    npm start
    # or
    yarn start
    # or
    pnpm start
    

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 client
  • AzadClient - High-level Azad client
  • Environment - Interface for tool execution environment
  • Tool - Interface for tool implementations
  • Message - Types for various message formats
  • AINetworkEvent - Types for network events

See the implementation files in the azad_cli/src/azad-ts-client directory for detailed type definitions.