foley.requirements#

Onboarding — check what foley needs, tell the user how to get it (accompy-style, #12).

Generalizes WEAVE’s binary-only foley.weave.requirements into a single capability audit across everything foley can optionally use: system binaries (ffmpeg / rubberband — reused verbatim from the WEAVE SSOT), API keys (derived from each source adapter’s declared config['auth'] — one SSOT for the env var + sign-up URL), and importable extras (py2mcp for the MCP server, the CLAP / index / provenance stacks). A Requirement carries a probe discriminator (binary / env / importable) so one dispatch handles all three. Nothing here runs an installer — it surfaces the exact per-platform command or sign-up URL so the user (or agent) can opt in. Stdlib-only; keeps import foley dol-only.

Functions

build_requirements()

Assemble the full requirement set: system binaries + API keys + importable extras.

capability_report(*[, runtime])

A JSON-safe capability + posture snapshot for the CLI, docs, and the MCP tool.

check_requirements(*[, names, verbose])

Report which optional foley capabilities are available ({name: is_available}).

declared_keys()

The credentials foley reads, one row per key, for a setup tool to list.

provider_key_env_vars()

Every env var that holds a credential foley reads (the sources' keys, Anthropic's, and foley's own: the LLM endpoint's key and the MCP server's bearer tokens).

verify_and_setup(*[, names])

Return a per-requirement status + guidance report (never runs an installer).

foley.requirements.build_requirements()[source]#

Assemble the full requirement set: system binaries + API keys + importable extras.

Return type:

dict[str, Requirement]

foley.requirements.capability_report(*, runtime=None)[source]#

A JSON-safe capability + posture snapshot for the CLI, docs, and the MCP tool.

Groups requirements into keys (env), extras (importable), system (binary), adds the current offline posture and the available source list, and lists degraded_tools — capabilities whose requirement is unmet.

Parameters:

runtime – A foley.runtime.RuntimeConfig (default: the active one).

Return type:

dict

Returns:

{keys, extras, system, offline, sources, backends, llm, degraded_tools} — all JSON-safe. llm is the provider the SELECT rungs resolve to right now (see foley.agent.llm.resolve_llm()), or the reason it cannot resolve. backends is foley.ledger() (per-source capabilities + planned targets).

foley.requirements.check_requirements(*, names=None, verbose=False)[source]#

Report which optional foley capabilities are available ({name: is_available}).

Parameters:
  • names (tuple[str, ...] | None) – Which requirements to check (default: the full assembled set).

  • verbose (bool) – If True, print an actionable hint for each missing requirement.

Return type:

dict[str, bool]

Returns:

{requirement_name: available}. Everything-absent is fine — foley degrades (deterministic fakes, offline mode, in-process DSP); the report just shows what each capability would unlock.

foley.requirements.declared_keys()[source]#

The credentials foley reads, one row per key, for a setup tool to list.

Exposed under the facade kit’s ocracy.credentials.v1 entry-point group (ocracy.kit.credentials.CREDENTIALS_ENTRY_POINT_GROUP) and built with the kit’s own credential_rows(): provider (the account), env_vars (the canonical name first, then every other name foley reads it under), unlocks and get_key_url. Derived from the same SSOT as check_requirements() (each source’s config['auth']), so a newly added paid source is declared with no edit here. Reads no key.

>>> rows = {r["env_vars"][0]: r for r in declared_keys()}
>>> rows["ELEVENLABS_API_KEY"]["env_vars"]
['ELEVENLABS_API_KEY', 'ELEVEN_API_KEY']
>>> rows["FAL_KEY"]["env_vars"]
['FAL_KEY', 'FAL_API_KEY']
>>> rows["ANTHROPIC_API_KEY"]["provider"], rows["FAL_KEY"]["provider"]
('anthropic', 'fal')
>>> rows["FOLEY_LLM_API_KEY"]["provider"], rows["FOLEY_MCP_TOKEN"]["provider"]
('foley-llm', 'foley-mcp')
Return type:

list[dict]

foley.requirements.provider_key_env_vars()[source]#

Every env var that holds a credential foley reads (the sources’ keys, Anthropic’s, and foley’s own: the LLM endpoint’s key and the MCP server’s bearer tokens).

The union of declared_keys()’ rows, which derive from the same SSOT as check_requirements() (each source’s config['auth']), so a newly added paid source is covered automatically: the test suite scrubs exactly these so no test can spend money by accident.

Return type:

tuple[str, ...]

foley.requirements.verify_and_setup(*, names=None)[source]#

Return a per-requirement status + guidance report (never runs an installer).

Return type:

dict[str, dict]

Returns:

{name: {'available', 'purpose', 'install', 'url', 'probe'}}.