# SAL-v4 Harness

Salience-Optimized Agent Operating System

## Quick Start

```bash
# Set your Z.AI API key
export ZAI_API_KEY="your-api-key"

# Run the launcher
python run.py
```

## Interfaces

| Interface | Description |
|-----------|-------------|
| `run.py` | Launcher with menu |
| `tui.py` | Simple step-by-step TUI |
| `tui_live.py` | Split-screen live TUI |
| `chat.py` | Simple chat interface |
| `health.py` | Verify API connection |
| `harness.py` | Run demo loop |

## Commands (in TUI/Chat)

| Command | Description |
|---------|-------------|
| `/thinking` | Toggle thinking mode |
| `/preserve` | Toggle preserved thinking |
| `/show` | Toggle showing thinking output |
| `/model NAME` | Switch model |
| `/clear` | Clear conversation |
| `/status` | Show status |
| `/help` | Show help |
| `/quit` | Exit |

## Thinking Modes

| Mode | Behavior |
|------|----------|
| OFF | Direct response, no reasoning |
| ON | Shows reasoning process |
| ON+Preserve | Keeps reasoning in context |

## Model Pool (9 slots)

```
Router:
  router_small      -> glm-4.7-flash (free)
  router_hybrid     -> glm-4.7 (thinking)
  router_powerhouse -> glm-5 (thinking)

4-way Consensus:
  verifier_v1-v4    -> Various tiers

Duplex Verifier:
  duplex_d1, d2     -> Cross-check
```

## Architecture

```
core/
  salience.py      - S' Lagrangian engine
  blackboard.py    - State management
  scheduler.py     - Budget/governor
  model_pool.py    - Model configuration
  zai_client.py    - Z.AI API client
  model_executor.py - Execution with fallback

agents/
  router.py        - Tiered routing
  tlp.py           - 9-step TLP loop

verifiers/
  consensus.py     - 4-way/duplex verification
```

## Environment

```bash
ZAI_API_KEY=your-key-here
```

Or create `.env` file:
```
ZAI_API_KEY=your-key-here
```
