# `LlmCore.Memory.Hindsight.Discovery`
[🔗](https://github.com/fosferon/llm_core/blob/v0.3.0/lib/llm_core/memory/hindsight/discovery.ex#L1)

Auto-discovery of Hindsight API endpoints.

Probes default endpoints in order:
1. http://localhost:8888
2. http://127.0.0.1:8888

Uses GET /health with 2-second timeout for fast discovery.
Results are cached in ETS for session lifetime.

## Hindsight 0.4+
Uses REST API (not MCP). Health at `/health`, operations at `/v1/default/banks/...`.

# `cached_url`

```elixir
@spec cached_url() :: String.t() | nil
```

Returns cached discovery result without probing.

# `discover`

```elixir
@spec discover() :: String.t() | nil
```

Discovers Hindsight endpoint by probing default URLs.

Returns the first responding endpoint or nil if none found.

# `discover_async`

```elixir
@spec discover_async() :: Task.t()
```

Runs discovery asynchronously (non-blocking).

# `probe_health`

```elixir
@spec probe_health(String.t()) :: {:ok, map()} | {:error, term()}
```

Probes a specific URL for health via GET /health.

# `refresh`

```elixir
@spec refresh() :: String.t() | nil
```

Clears cached discovery and re-probes endpoints.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
