# 4emet ADK (foremet)

**4emet** is a CLI-first Agent Development Kit that turns any SaaS (via OpenAPI) into an AI agent. Run `foremet init` in your repo, answer a few questions, and get a LangGraph agent that can call your API.

## Install

```bash
pip install -e .
# or from PyPI (when published): pip install foremet
```

## Quick start

1. **Init** (in your repo): answer prompts to create `adk.config.json` and generate the agent.

   ```bash
   foremet init
   ```

   You will be asked for: OpenAPI spec URL or path, product name, API base URL, auth env var name, **LLM provider** (openai, anthropic, gemini, or ollama), model name, and optional output directory (default `./agent`).

2. **Set env**: copy `.env.example` to `.env` and set your SaaS API key and the LLM key for your chosen provider.

   ```bash
   cp .env.example .env
   # Edit .env: set SAAS_API_KEY and one of OPENAI_API_KEY, ANTHROPIC_API_KEY, GOOGLE_API_KEY (or run Ollama locally; no key needed)
   ```

3. **Run** the agent (interactive chat):

   ```bash
   foremet run
   ```

## Commands

- `foremet init` – Questionnaire; writes `adk.config.json`, `.env.example`, and generates `agent/` (tools, prompt, run script).
- `foremet run` – Loads config and runs the agent in an interactive loop. Requires `.env` with your SaaS auth env var and the LLM key for your provider (e.g. `OPENAI_API_KEY`, `GOOGLE_API_KEY` for Gemini; Ollama uses local server, optional `OLLAMA_BASE_URL`).
- `foremet refresh` – Re-fetches OpenAPI and regenerates `agent/` from current config.

## Config

`adk.config.json` (created by init) includes: `openapi_url` or `openapi_path`, `product_name`, `product_description`, `base_url`, `auth_type`, `auth_env_var`, `output_dir` (default `./agent`), `llm_provider` (openai, anthropic, gemini, ollama), `model`.

Secrets are never stored in config; only the **name** of the env var (e.g. `SAAS_API_KEY`) is saved. Set the actual key in `.env` or your environment.

## Generated agent

The `agent/` directory (or your custom `output_dir`) contains:

- `tools_generated.py` – LangChain tools for each OpenAPI operation.
- `prompt_generated.py` – System prompt for the agent.
- `run.py` – Standalone script: `python agent/run.py "your message"` (run from repo root).

`foremet run` uses the same runner and is the recommended way to chat.

## Testing

```bash
pip install -e ".[dev]"
pytest tests/ -v
```

See the plan (Section 10) for the full test plan before release (unit, integration, E2E, manual QA, security, packaging).

## LLM providers

- **openai** – Set `OPENAI_API_KEY` in `.env`.
- **anthropic** – Set `ANTHROPIC_API_KEY` in `.env`.
- **gemini** – Set `GOOGLE_API_KEY` in `.env`.
- **ollama** – Run [Ollama](https://ollama.com) locally; optional `OLLAMA_BASE_URL` (default `http://localhost:11434`).

## Requirements

- Python 3.11+
- API key for your chosen LLM provider (or local Ollama). Set the matching env var in `.env`.
