Skip to main content

Module provider

Module provider 

Source
Expand description

Provider + model resolution. Mirrors the Anthropic-only slice of the TS packages/coding-agent/src/core/model-resolver.ts (resolveCliModel + the provider/id[:thinking] parsing in crate::args).

v1 is Anthropic-only (plan §5.16: “OAuth/Copilot skipped v1; API-key auth only”). The TS ModelRuntime/ModelRegistry multi-provider machinery is not ported; this module builds a single AnthropicProvider from an API key and resolves a Model + ThinkingLevel against its fixed catalog.

§Resolution precedence (mirrors resolveCliModel)

  1. --model may carry provider/id[:thinking]. If the prefix before the first / is the provider (anthropic), strip it and parse the rest as id[:thinking].
  2. Otherwise treat --model as id[:thinking]: if a trailing :level is a valid thinking level, strip it and apply it (overriding --thinking); else the whole string is the id.
  3. A --provider that isn’t anthropic is a hard error (v1 has no other provider). --provider anthropic is accepted and just confirms the default.
  4. The model id is matched exactly, case-insensitively against the catalog. The TS resolver additionally does fuzzy/partial matching; v1 keeps it exact to avoid surprising model picks (partial match is a common source of “got the wrong model” bugs — documented as a divergence in docs/m6-cli-open-questions.md).
  5. No --model ⇒ the default (DEFAULT_MODEL_ID = claude-sonnet-5), mirroring the TS per-provider default.

Structs§

ResolvedModel
The resolved run configuration: the provider handle, the chosen model, and the effective thinking level (after --thinking / :level / model-clamp).

Enums§

ResolveError
A resolution error. The TS resolver returns { error, warning }; v1 folds both into a single enum since the CLI treats them the same (print + non-zero exit) except NoApiKey, which prints guidance then exits.

Constants§

ANTHROPIC_API_KEY_ENV
The env var consulted for the API key. Mirrors TS ANTHROPIC_API_KEY.
DEFAULT_MODEL_ID
The v1-default model id when --model is absent. Mirrors the TS defaultModelPerProvider["anthropic"] (the first current-generation reasoning model in the catalog).
DEFAULT_THINKING_LEVEL
The default thinking level when neither --thinking nor a :level suffix is present. Mirrors the TS DEFAULT_THINKING_LEVEL ("medium", clamped to model capabilities by the harness’s provider build_params).

Functions§

resolve
Resolve the provider + model + thinking level from the CLI flags + env.