# Agent Configuration

Configuration for `typedialog-ag` binary - single unified binary with CLI and HTTP server modes.

The binary searches for configuration files in:
- `~/.config/typedialog/ag/{TYPEDIALOG_ENV}.toml` (environment-specific)
- `~/.config/typedialog/ag/config.toml` (fallback)
- Hardcoded defaults if no file found

## Files

- **default.toml** - Default configuration for agent CLI execution (LLM settings, validation, output)
- **dev.toml** - Development configuration (increased logging, streaming output)
- **production.toml** - Production configuration (optimized settings, file logging)
- **server-default.toml** - HTTP server configuration (host, port)

## Usage

### Agent CLI Mode
Execute agents from the command line:
```bash
typedialog-ag agent.mdx                      # Execute agent file
typedialog-ag run agent.mdx                  # Explicit run command
typedialog-ag transpile agent.mdx -o out.ncl # Transpile to Nickel
typedialog-ag validate agent.mdx             # Validate without executing
typedialog-ag cache clear|stats              # Manage cache
```text

With custom configuration:
```bash
typedialog-ag -c ~/.config/typedialog/ag/config.toml run agent.mdx
TYPEDIALOG_ENV=dev typedialog-ag run agent.mdx
```text

### Agent HTTP Server Mode
Start HTTP API server for remote agent execution:
```bash
typedialog-ag serve                          # Start server (127.0.0.1:8765)
typedialog-ag serve --port 9000              # Custom port
typedialog-ag serve --host 0.0.0.0           # Public interface
typedialog-ag -c ~/.config/typedialog/ag/server-default.toml serve
```text

Server endpoints:
- `GET /health` - Health check
- `POST /execute` - Execute agent from file
- `POST /agents/{name}/execute` - Execute agent by name
- `POST /transpile` - Transpile MDX to Nickel
- `POST /validate` - Validate agent file

## Configuration Structure

Agent CLI settings:
- `[agent]` - LLM provider and model selection
- `[agent.models]` - Available models per provider
- `[agent.defaults]` - Execution defaults (max_tokens, temperature, streaming)
- `[agent.validation]` - Validation behavior
- `[agent.output]` - Output formatting
- `[agent.logging]` - Log level and destination

Server settings:
- `host` - Server bind address (default: 127.0.0.1)
- `port` - Server port (default: 8765)
