id_effect 0.12.0

Effect<A, E, R>: lazy Send effects over a typed capability list, run on a fiber runtime (Tokio executor), with layers, streams, schedules and coordination
Documentation
# AI and MCP

> **Labs crate — unpublished, no API guarantees ([ADR 0010]https://github.com/Industrial/id_effect/blob/main/docs/adrs/0010-crate-tiers.md).**
> `id_effect_ai` lives in [`labs/id_effect_ai`]https://github.com/Industrial/id_effect/tree/main/labs/id_effect_ai.
> Use it via a path or git dependency on `labs/`; it is not on crates.io.

Phase H adds `id_effect_ai` — vendor-neutral LLM traits over Phase A `HttpClient`, with feature-gated vendors.

## Language model trait

<!-- ignore: labs crate id_effect_ai is outside the workspace, not a book_snippets dependency -->
```rust,ignore
use id_effect_ai::{ChatRequest, LanguageModel, complete};
```

`LanguageModel` is a capability (`LanguageModelService`) in the typed environment; `complete::<R, _>(req)` reads it from `R` and returns an `Effect<ChatResponse, AiError, R>`. Provide `provide_mock_language_model::<E>()` in tests; wire OpenAI or Anthropic at the edge with `provide_openai_language_model::<E>(client, config)` / `provide_anthropic_language_model::<E>(..)` — each returns `Result<Layer<HCons<LanguageModelService, HNil>, E>, AiError>`:

<!-- ignore: labs crate id_effect_ai is outside the workspace, not a book_snippets dependency -->
```rust,ignore
use id_effect::{HCons, HNil};
use id_effect_ai::{AiConfig, LanguageModelService, complete, provide_openai_language_model};

let layer = provide_openai_language_model::<AiError>(http_client, AiConfig::from_env())?;
let resp = complete::<HCons<LanguageModelService, HNil>, _>(req)
    .provide_layer(layer);
```

OpenAI and ChatGPT share one adapter (`feature = "openai"`) — model IDs like `gpt-4o` select the model.

## Streaming

`complete_stream` returns an `Effect<Stream<CompletionChunk, AiError>, AiError, R>` — token deltas map to chunks for sinks and UI bridges.

## Anthropic Claude

`feature = "anthropic"` uses the Messages API (`/v1/messages`) with SSE streaming. System prompts map to the top-level `system` field.

## Cursor Cloud Agents

`feature = "cursor"` exposes `CursorAgentsClient` — a **separate** capability from `LanguageModel`:

- `list_models()` — `GET /v1/models`
- `create_agent(prompt)` — `POST /v1/agents`
- `send_followup(agent_id, prompt)` — `POST /v1/agents/{id}/runs`
- `wait_until_idle(agent_id, run_id)` — poll until terminal status

Cursor uses HTTP Basic auth (`CURSOR_API_KEY`).

## Configuration and secrets

Load keys via `AiConfig::from_env()`. API keys are `Secret<String>` from `id_effect_config` — never log `.expose()` output.

Transient HTTP failures (429/502/503/504) retry via `Schedule` in `retry_transient_ai_http`.

## MCP server template

`cargo run --manifest-path labs/Cargo.toml -p id_effect_ai --example mcp_server_template` scaffolds a minimal MCP JSON-RPC loop over stdio using the same `Effect` + capability patterns.