ExAthena.Providers.ClaudeCode (ExAthena v0.18.0)

Copy Markdown View Source

Provider that wraps the claude_code SDK — the local claude CLI driven by an Anthropic subscription / OAuth token (CLAUDE_CODE_OAUTH_TOKEN) or a logged-in CLI. No ANTHROPIC_API_KEY is required.

Unlike the HTTP providers, the Claude Code CLI is an autonomous coding agent: it runs its own tools (Read/Edit/Bash/…) inside :cwd and manages its own conversation. So this provider treats Claude as a self-contained agent:

  • native_tool_calls: false — ex_athena does not execute tools for it; the CLI does. Request.tools (JSON function schemas) are not forwarded; use claude_code's own :allowed_tools/:permission_mode via provider_opts.
  • Request.messages are flattened to a single prompt string (the CLI owns multi-turn state; pass :resume/:continue via opts to continue).

Requires the optional :claude_code dependency; calls guard on its presence.

Summary

Functions

list_models_from(source)

@spec list_models_from(module()) :: {:ok, [String.t()]} | {:error, term()}

Like list_models/0, but with an explicit ExAthena.Providers.ClaudeCode.ModelSource.

Maps the CLI's reported models down to a sorted, de-duplicated list of model identifier strings (dropping blanks), which is what the UI dropdown needs.

Named apart from list_models/1 because that arity now belongs to the provider behaviour, where the argument is per-call opts rather than a source module. ExAthena.list_models/2 wraps this provider's strings into ExAthena.Model structs on its behalf — the Claude Code CLI reports a fixed set of models that no configuration can change, so there is nothing for an opts-aware callback to do here.